From eb21a5113e5b53529c1d3f3cc47633ac5e4a63b9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 19 Apr 2018 09:34:14 -0400 Subject: [PATCH 1/7] Add a debug line in SignaCheck function --- src/zm_monitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index d410b1399..20313de73 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1184,6 +1184,7 @@ bool Monitor::CheckSignal( const Image *image ) { int index = 0; for ( int i = 0; i < config.signal_check_points; i++ ) { while( true ) { + // Why the casting to long long? also note that on a 64bit cpu, long long is 128bits index = (int)(((long long)rand()*(long long)(pixels-1))/RAND_MAX); if ( !config.timestamp_on_capture || !label_format[0] ) break; @@ -1219,6 +1220,7 @@ bool Monitor::CheckSignal( const Image *image ) { } } } // end for < signal_check_points + Debug(1,"SignalCheck: %d points, colour_val(%d)", config.signal_check_points, colour_val); return false; } // end if signal_check_points return true; From cd70ed3decce146f2869954052602054df570b01 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 19 Apr 2018 09:45:28 -0400 Subject: [PATCH 2/7] always show SignalCheckColour and add a SignalCheckPoints option --- web/skins/classic/views/monitor.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 53c46c2f4..c0532aa78 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -980,19 +980,19 @@ if ( $monitor->Type() == 'Local' ) { DefaultRate() ); ?> DefaultScale() ); ?> -Type() == 'Local' ) { -?> + + + + + + - +      - From c7f672fabd33daa5b81bdc7ca1f7a8a58112d74e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 19 Apr 2018 09:59:10 -0400 Subject: [PATCH 3/7] SIGNAL_CHECK_POINTS is now a per-monitor setting --- .../lib/ZoneMinder/ConfigData.pm.in | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index acd2464bf..addd6239b 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -1723,26 +1723,6 @@ our @options = ( type => $types{abs_path}, category => 'config', }, - { - name => 'ZM_SIGNAL_CHECK_POINTS', - default => '10', - description => 'How many points in a captured image to check for signal loss', - help => q` - For locally attached video cameras ZoneMinder can check for - signal loss by looking at a number of random points on each - captured image. If all of these points are set to the same - fixed colour then the camera is assumed to have lost signal. - When this happens any open events are closed and a short one - frame signal loss event is generated, as is another when the - signal returns. This option defines how many points on each - image to check. Note that this is a maximum, any points found - to not have the check colour will abort any further checks so - in most cases on a couple of points will actually be checked. - Network and file based cameras are never checked. - `, - type => $types{integer}, - category => 'config', - }, { name => 'ZM_V4L_MULTI_BUFFER', default => 'yes', From 983cd8305487a355525882b55fbc6812ff0e07dd Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 19 Apr 2018 10:01:04 -0400 Subject: [PATCH 4/7] Add default for SignalCheckPoints and add it as a hidden field to the non-misc tabs --- web/skins/classic/views/monitor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index c0532aa78..424748410 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -133,6 +133,7 @@ if ( ! $monitor ) { 'DefaultView' => 'Events', 'DefaultRate' => '100', 'DefaultScale' => '100', + 'SignalCheckPoints' => '10', 'SignalCheckColour' => '#0000c0', 'WebColour' => 'red', 'Exif' => '0', @@ -659,8 +660,9 @@ if ( $tab != 'misc' ) { Type()!= 'Local') ) { +if ( $tab != 'misc' ) { ?> + Date: Thu, 19 Apr 2018 10:09:32 -0400 Subject: [PATCH 5/7] Add SignalCheckPoints to Monitors --- db/zm_create.sql.in | 1 + db/zm_update-1.31.42.sql | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 db/zm_update-1.31.42.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 06bdf0f85..9c237b8a0 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -499,6 +499,7 @@ CREATE TABLE `Monitors` ( `DefaultView` enum('Events','Control') NOT NULL default 'Events', `DefaultRate` smallint(5) unsigned NOT NULL default '100', `DefaultScale` smallint(5) unsigned NOT NULL default '100', + `SignalCheckPoints` INT UNSIGNED NOT NULL default '0', `SignalCheckColour` varchar(32) NOT NULL default '#0000BE', `WebColour` varchar(32) NOT NULL default 'red', `Exif` tinyint(1) unsigned NOT NULL default '0', diff --git a/db/zm_update-1.31.42.sql b/db/zm_update-1.31.42.sql new file mode 100644 index 000000000..adb004baf --- /dev/null +++ b/db/zm_update-1.31.42.sql @@ -0,0 +1,12 @@ + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'SignalCheckPoints' + ) > 0, +"SELECT 'Column SignalCheckPoints already exists in Storage'", +"ALTER TABLE `Monitors` ADD `SignalCheckPoints` INT UNSIGNED NOT NULL default '0' AFTER `DefaultScale`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; From 56186a42ef88e6dc30d2dd81f04855be0c46c2e4 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 19 Apr 2018 10:10:14 -0400 Subject: [PATCH 6/7] change signal_check_points to a per-monitor variable instead of parts of config. Only call SignalCheck if signal_check_points is > 0 --- src/zm_monitor.cpp | 16 ++++++++++------ src/zm_monitor.h | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 20313de73..601f9f424 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -77,7 +77,7 @@ std::string load_monitor_sql = "EventPrefix, LabelFormat, LabelX, LabelY, LabelSize," "ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, " "SectionLength, FrameSkip, MotionFrameSkip, " -"FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif, SignalCheckColour FROM Monitors"; +"FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, Exif, SignalCheckPoints, SignalCheckColour FROM Monitors"; std::string CameraType_Strings[] = { "Local", @@ -304,6 +304,7 @@ Monitor::Monitor( int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, + int p_signal_check_points, Rgb p_signal_check_colour, bool p_embed_exif, Purpose p_purpose, @@ -341,6 +342,7 @@ Monitor::Monitor( ref_blend_perc( p_ref_blend_perc ), alarm_ref_blend_perc( p_alarm_ref_blend_perc ), track_motion( p_track_motion ), + signal_check_points(p_signal_check_points), signal_check_colour( p_signal_check_colour ), embed_exif( p_embed_exif ), delta_image( width, height, ZM_COLOUR_GRAY8, ZM_SUBPIX_ORDER_NONE ), @@ -1164,7 +1166,7 @@ bool Monitor::CheckSignal( const Image *image ) { static Rgb colour_val; /* RGB32 color */ static int usedsubpixorder; - if ( config.signal_check_points > 0 ) { + if ( signal_check_points > 0 ) { if ( static_undef ) { static_undef = false; usedsubpixorder = camera->SubpixelOrder(); @@ -1182,7 +1184,7 @@ bool Monitor::CheckSignal( const Image *image ) { int colours = image->Colours(); int index = 0; - for ( int i = 0; i < config.signal_check_points; i++ ) { + for ( int i = 0; i < signal_check_points; i++ ) { while( true ) { // Why the casting to long long? also note that on a 64bit cpu, long long is 128bits index = (int)(((long long)rand()*(long long)(pixels-1))/RAND_MAX); @@ -1220,7 +1222,7 @@ bool Monitor::CheckSignal( const Image *image ) { } } } // end for < signal_check_points - Debug(1,"SignalCheck: %d points, colour_val(%d)", config.signal_check_points, colour_val); + Debug(1,"SignalCheck: %d points, colour_val(%d)", signal_check_points, colour_val); return false; } // end if signal_check_points return true; @@ -1803,6 +1805,7 @@ void Monitor::Reload() { alarm_ref_blend_perc = atoi(dbrow[index++]); track_motion = atoi(dbrow[index++]); + signal_check_points = dbrow[index]?atoi(dbrow[index]):0;index++; if ( dbrow[index][0] == '#' ) signal_check_colour = strtol(dbrow[index]+1,0,16); @@ -2090,7 +2093,7 @@ Monitor *Monitor::Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose) { int ref_blend_perc = atoi(dbrow[col]); col++; int alarm_ref_blend_perc = atoi(dbrow[col]); col++; int track_motion = atoi(dbrow[col]); col++; - + int signal_check_points = dbrow[col] ? atoi(dbrow[col]) : 0;col++; int signal_check_color = strtol(dbrow[col][0] == '#' ? dbrow[col]+1 : dbrow[col], 0, 16); col++; bool embed_exif = (*dbrow[col] != '0'); col++; @@ -2290,6 +2293,7 @@ Monitor *Monitor::Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose) { ref_blend_perc, alarm_ref_blend_perc, track_motion, + signal_check_points, signal_check_color, embed_exif, purpose, @@ -2437,7 +2441,7 @@ int Monitor::Capture() { TimestampImage( capture_image, image_buffer[index].timestamp ); } // Maybe we don't need to do this on all camera types - shared_data->signal = CheckSignal(capture_image); + shared_data->signal = signal_check_points ? CheckSignal(capture_image) : true; shared_data->last_write_index = index; shared_data->last_write_time = image_buffer[index].timestamp->tv_sec; diff --git a/src/zm_monitor.h b/src/zm_monitor.h index c91622f41..0f78b55a4 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -284,6 +284,7 @@ protected: int ref_blend_perc; // Percentage of new image going into reference image. int alarm_ref_blend_perc; // Percentage of new image going into reference image during alarm. bool track_motion; // Whether this monitor tries to track detected motion + int signal_check_points; // Number of points in the image to check for signal Rgb signal_check_colour; // The colour that the camera will emit when no video signal detected bool embed_exif; // Whether to embed Exif data into each image frame or not @@ -384,6 +385,7 @@ public: int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, + int p_signal_check_points, Rgb p_signal_check_colour, bool p_embed_exif, Purpose p_purpose, From bd5f4020cace1f221183495452c887bf2498aba5 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 19 Apr 2018 10:10:23 -0400 Subject: [PATCH 7/7] bump version --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 5ab7277d8..dd8165476 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.41 +1.31.42