Skip to content

Commit

Permalink
Replace analysis interval parameter by analysis framerate
Browse files Browse the repository at this point in the history
  • Loading branch information
manupap1 committed Jul 23, 2015
1 parent d2a3655 commit 649a39b
Show file tree
Hide file tree
Showing 27 changed files with 156 additions and 33 deletions.
1 change: 1 addition & 0 deletions db/zm_create.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ CREATE TABLE `Monitors` (
`FrameSkip` smallint(5) unsigned NOT NULL default '0',
`MotionFrameSkip` smallint(5) unsigned NOT NULL default '0',
`AnalysisFPS` decimal(5,2) default NULL,
`AnalysisUpdateDelay` smallint(5) unsigned NOT NULL default '0',
`MaxFPS` decimal(5,2) default NULL,
`AlarmMaxFPS` decimal(5,2) default NULL,
`FPSReportInterval` smallint(5) unsigned NOT NULL default '250',
Expand Down
17 changes: 17 additions & 0 deletions db/zm_update-1.28.101.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ SET @s = (SELECT IF(
PREPARE stmt FROM @s;
EXECUTE stmt;

--
-- Add AnalysisUpdateDelay column to Monitors
--

SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Monitors'
AND table_schema = DATABASE()
AND column_name = 'AnalysisUpdateDelay'
) > 0,
"SELECT 'Column AnalysisUpdateDelay exists in Monitors'",
"ALTER TABLE Monitors ADD `AnalysisUpdateDelay` smallint(5) unsigned not null default 0 AFTER `AnalysisFPS`"

PREPARE stmt FROM @s;
EXECUTE stmt;

95 changes: 65 additions & 30 deletions src/zm_monitor.cpp

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/zm_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ friend class MonitorStream;
int post_event_count; // How many unalarmed images must occur before the alarm state is reset
int stream_replay_buffer; // How many frames to store to support DVR functions, IGNORED from this object, passed directly into zms now
int section_length; // How long events should last in continuous modes
bool adaptive_skip; // Whether to use the newer adaptive algorithm for this monitor
int frame_skip; // How many frames to skip in continuous modes
int motion_frame_skip; // How many frames to skip in motion detection
double analysis_fps; // Target framerate for video analysis
int analysis_update_delay; // How long we wait before updating analysis parameters
int capture_delay; // How long we wait between capture frames
int alarm_capture_delay; // How long we wait between capture frames when in alarm state
int alarm_frame_count; // How many alarm frames are required before an event is triggered
Expand All @@ -253,7 +255,6 @@ friend class MonitorStream;
Purpose purpose; // What this monitor has been created to do
int event_count;
int image_count;
int processed_image_count;
int ready_count;
int first_alarm_count;
int last_alarm_count;
Expand All @@ -262,7 +263,6 @@ friend class MonitorStream;
State state;
time_t start_time;
time_t last_fps_time;
double last_analysis_time;
time_t auto_resume_time;
unsigned int last_motion_score;

Expand Down Expand Up @@ -301,7 +301,7 @@ friend class MonitorStream;
public:
// OurCheckAlarms seems to be unused. Check it on zm_monitor.cpp for more info.
//bool OurCheckAlarms( Zone *zone, const Image *pImage );
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, double p_analysis_fps, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 );
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, double p_analysis_fps, int p_analysis_update_delay, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 );
~Monitor();

void AddZones( int p_n_zones, Zone *p_zones[] );
Expand Down Expand Up @@ -356,6 +356,9 @@ friend class MonitorStream;
State GetState() const;
int GetImage( int index=-1, int scale=100 );
struct timeval GetTimestamp( int index=-1 ) const;
void UpdateAdaptiveSkip();
useconds_t GetAnalysisRate();
int GetAnalysisUpdateDelay() const { return( analysis_update_delay ); }
int GetCaptureDelay() const { return( capture_delay ); }
int GetAlarmCaptureDelay() const { return( alarm_capture_delay ); }
unsigned int GetLastReadIndex() const;
Expand Down
22 changes: 22 additions & 0 deletions src/zma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,36 @@ int main( int argc, char *argv[] )
sigset_t block_set;
sigemptyset( &block_set );

useconds_t analysis_rate = monitor->GetAnalysisRate();
int analysis_update_delay = monitor->GetAnalysisUpdateDelay();
time_t last_analysis_update_time, cur_time;
monitor->UpdateAdaptiveSkip();
last_analysis_update_time = time( 0 );

while( !zm_terminate )
{
// Process the next image
sigprocmask( SIG_BLOCK, &block_set, 0 );

cur_time = time( 0 );

// Some periodic updates are required for variable capturing framerate
if ( analysis_update_delay && ( ( cur_time - last_analysis_update_time ) > analysis_update_delay ) )
{
analysis_rate = monitor->GetAnalysisRate();
monitor->UpdateAdaptiveSkip();
last_analysis_update_time = cur_time;
}

if ( !monitor->Analyse() )
{
usleep( monitor->Active()?ZM_SAMPLE_RATE:ZM_SUSPENDED_RATE );
}
else if ( analysis_rate )
{
usleep( analysis_rate );
}

if ( zm_reload )
{
monitor->Reload();
Expand Down
2 changes: 2 additions & 0 deletions web/lang/big5_big5.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
'Alert' => '警告',
'All' => '全部',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => '確定',
'ApplyingStateChange' => '確定狀態改變',
'ArchArchived' => 'Archived Only',
Expand Down Expand Up @@ -133,6 +134,7 @@
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Channel must be set to an integer of zero or more',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => 'Device must be set to a valid value',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/cn_zh.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
'Alert' => '警报',
'All' => '全部',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => '应用',
'ApplyingStateChange' => '状态改变生效',
'ArchArchived' => '仅限于存档',
Expand Down Expand Up @@ -129,6 +130,7 @@
'BadAlarmFrameCount' => '报警帧数必须设为大于1的整数',
'BadAlarmMaxFPS' => '报警最大帧率必须是正整数或正浮点数',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => '通道必须设为大于零的整数',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => '必须为器件设置有效值',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/cs_cz.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
'Alert' => 'Pozor',
'All' => 'V¹echny',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Pou¾ít',
'ApplyingStateChange' => 'Aplikuji zmìnu stavu',
'ArchArchived' => 'Pouze archivované',
Expand Down Expand Up @@ -129,6 +130,7 @@
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Channel must be set to an integer of zero or more',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => 'Device must be set to a valid value',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/de_de.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
'Alert' => 'Alarm',
'All' => 'Alle',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Anwenden',
'ApplyingStateChange' => 'Aktiviere neuen Status',
'ArchArchived' => 'Nur Archivierte',
Expand Down Expand Up @@ -131,6 +132,7 @@
'BadAlarmFrameCount' => 'Die Bildanzahl muss ganzzahlig 1 oder größer sein',
'BadAlarmMaxFPS' => 'Alarm-Maximum-FPS muss eine positive Ganzzahl oder eine Gleitkommazahl sein',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Der Kanal muss ganzzahlig 0 oder größer sein',
'BadColours' => 'Zielfarbe muss auf einen gültigen Wert gesetzt werden', // Added - 2011-06-15
'BadDevice' => 'Das Gerät muss eine gültige Systemresource sein',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/dk_dk.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'Alert' => 'Alarm',
'All' => 'Alle',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Aktiver',
'ApplyingStateChange' => 'Aktivere State Ændring',
'ArchArchived' => 'Kun Arkiverede',
Expand Down Expand Up @@ -130,6 +131,7 @@
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Channel must be set to an integer of zero or more',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => 'Device must be set to a valid value',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/en_gb.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
'Alert' => 'Alert',
'All' => 'All',
'AnalysisFPS' => 'Analysis FPS',
'AnalysisUpdateDelay' => 'Analysis Update Delay',
'Apply' => 'Apply',
'ApplyingStateChange' => 'Applying State Change',
'ArchArchived' => 'Archived Only',
Expand Down Expand Up @@ -139,6 +140,7 @@
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value',
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more',
'BadChannel' => 'Channel must be set to an integer of zero or more',
'BadDevice' => 'Device must be set to a valid value',
'BadFormat' => 'Format must be set to a valid value',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/es_ar.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'Alert' => 'Alerta',
'All' => 'Todo',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Aplicar',
'ApplyingStateChange' => 'Aplicar Cambio Estado',
'ArchArchived' => 'Solo Archivados',
Expand Down Expand Up @@ -80,6 +81,7 @@
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Channel must be set to an integer of zero or more',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => 'Device must be set to a valid value',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/es_es.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
'Alert' => 'Alerta',
'All' => 'Todo',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Aplicar',
'ApplyingStateChange' => 'Aplicando cambio de estado...',
'ArchArchived' => 'Sólo archivados',
Expand Down Expand Up @@ -129,6 +130,7 @@
'BadAlarmFrameCount' => 'El número de marcos de alarma debe tener un número entero de uno o más',
'BadAlarmMaxFPS' => 'Máximos MPS de alarma debe ser un valor entero positivo o de punto flotante',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'El canal debe estar establecido en un entero de cero o más',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2015-04-18
'BadDevice' => 'El dispositivo debe tener un valor válido',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/et_ee.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'Alert' => 'Hoiatus',
'All' => 'All',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Apply',
'ApplyingStateChange' => 'Applying State Change',
'ArchArchived' => 'Arhiveeritud Ainult',
Expand Down Expand Up @@ -130,6 +131,7 @@
'BadAlarmFrameCount' => 'Alarmi kaadri hulga ühik peab olema integer. Kas üks või rohkem',
'BadAlarmMaxFPS' => 'Alarmi maksimaalne FPS peab olema positiivne integer või floating point väärtus',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Kanal peab olema integer, null või rohkem',
'BadColours' => 'Sihtmärgi värv peab olema pandud õige väärtus', // Added - 2011-06-15
'BadDevice' => 'Seadmel peab olema õige väärtus',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/fr_fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
'Alert' => 'Alerte',
'All' => 'Tous',
'AnalysisFPS' => 'i/s à traiter en analyse', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Délai mise à jour analyse', // Added - 2015-07-23
'Apply' => 'Appliquer',
'ApplyingStateChange' => 'Appl. chgt état',
'ArchArchived' => 'Archivé seul.',
Expand Down Expand Up @@ -135,6 +136,7 @@
'BadAlarmFrameCount' => 'Le nombre d\'images en alarme doit être un entier supérieur ou égal à 1',
'BadAlarmMaxFPS' => 'Le nombre maximum d\'i/s en alarme doit être un entier ou un nombre à virgule flottante supérieur à 0',
'BadAnalysisFPS' => 'Le nombre d\'i/s à traiter en analyse doit être un entier ou un nombre à virgule flottante supérieur à 0', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Le délai de mise à jour analyse doit être un nombre entier supérieur ou égal à 0', // Added - 2015-07-23
'BadChannel' => 'Le canal doit être un nombre entier supérieur ou égal à 0',
'BadColours' => 'La valeur de la couleur cible est invalide', // Added - 2011-06-15
'BadDevice' => 'Le chemin de l\'équipement être défini',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/he_il.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
'Alert' => 'äúøàä',
'All' => 'äëì',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'äçì',
'ApplyingStateChange' => 'äçì ùéðåé îöá',
'ArchArchived' => 'àøëéá áìáã',
Expand Down Expand Up @@ -129,6 +130,7 @@
'BadAlarmFrameCount' => 'Alarm frame count must be an integer of one or more',
'BadAlarmMaxFPS' => 'Alarm Maximum FPS must be a positive integer or floating point value',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Channel must be set to an integer of zero or more',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => 'Device must be set to a valid value',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/hu_hu.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
'Alert' => 'Figyelem',
'All' => 'Mind',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Alkalmaz',
'ApplyingStateChange' => 'Állapot váltása...',
'ArchArchived' => 'Csak archivált',
Expand Down Expand Up @@ -172,6 +173,7 @@
'BadAlarmFrameCount' => 'Riasztáshoz szükséges képkockák száma legyen legalább 1',
'BadAlarmMaxFPS' => 'Maximális FPS riasztott állapotban legyen megadva',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'A csatorna száma legyen legalább 0',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2015-04-18
'BadDevice' => 'Az eszköz elérése valós legyen',
Expand Down
2 changes: 2 additions & 0 deletions web/lang/it_it.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
'Alert' => 'Attenzione',
'All' => 'Tutto',
'AnalysisFPS' => 'Analysis FPS', // Added - 2015-07-22
'AnalysisUpdateDelay' => 'Analysis Update Delay', // Added - 2015-07-23
'Apply' => 'Applica',
'ApplyingStateChange' => 'Sto applicando le modifiche',
'ArchArchived' => 'Archiviato',
Expand Down Expand Up @@ -134,6 +135,7 @@
'BadAlarmFrameCount' => 'Il numero di frame di un allarme deve essere un numero intero superiore a uno',
'BadAlarmMaxFPS' => 'Il numero massimo di FPS dell\'allarme deve essere un numero intero positivo o un valore in virgola mobile',
'BadAnalysisFPS' => 'Analysis FPS must be a positive integer or floating point value', // Added - 2015-07-22
'BadAnalysisUpdateDelay'=> 'Analysis update delay must be set to an integer of zero or more', // Added - 2015-07-23
'BadChannel' => 'Il canale deve essere settato con un numero intero uguale o maggiore di zero',
'BadColours' => 'Target colour must be set to a valid value', // Added - 2011-06-15
'BadDevice' => 'Il dispositivo deve essere impostato con un valore valido',
Expand Down
Loading

0 comments on commit 649a39b

Please sign in to comment.