Merge pseudo:sandbox/ZoneMinder.connortechnology into event_thread
This commit is contained in:
commit
44b11389ce
|
@ -1 +1 @@
|
||||||
Subproject commit 1b40f1661f93f50fd5805f239d1e466a3bcf888f
|
Subproject commit cd7fd49becad6010a1b8466bfebbd93999a39878
|
|
@ -639,9 +639,9 @@ $log->debug("Have array for $k $$search{$k}") if DEBUG_ALL;
|
||||||
|
|
||||||
if ( ! ( $db_field =~ /\?/ ) ) {
|
if ( ! ( $db_field =~ /\?/ ) ) {
|
||||||
if ( @{$$search{$k}} != 1 ) {
|
if ( @{$$search{$k}} != 1 ) {
|
||||||
push @where, $db_field .' IN ('.join(',', map {'?'} @{$$search{$k}} ) . ')';
|
push @where, '`'.$db_field .'` IN ('.join(',', map {'?'} @{$$search{$k}} ) . ')';
|
||||||
} else {
|
} else {
|
||||||
push @where, $db_field.'=?';
|
push @where, '`'.$db_field.'`=?';
|
||||||
} # end if
|
} # end if
|
||||||
} else {
|
} else {
|
||||||
$log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
|
$log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
|
||||||
|
@ -656,10 +656,10 @@ $log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
|
||||||
foreach my $p_k ( keys %{$$search{$k}} ) {
|
foreach my $p_k ( keys %{$$search{$k}} ) {
|
||||||
my $v = $$search{$k}{$p_k};
|
my $v = $$search{$k}{$p_k};
|
||||||
if ( ref $v eq 'ARRAY' ) {
|
if ( ref $v eq 'ARRAY' ) {
|
||||||
push @where, $db_field.' IN ('.join(',', map {'?'} @{$v} ) . ')';
|
push @where, '`'.$db_field.'` IN ('.join(',', map {'?'} @{$v} ) . ')';
|
||||||
push @values, $p_k, @{$v};
|
push @values, $p_k, @{$v};
|
||||||
} else {
|
} else {
|
||||||
push @where, $db_field.'=?';
|
push @where, '`'.$db_field.'`=?';
|
||||||
push @values, $p_k, $v;
|
push @values, $p_k, $v;
|
||||||
} # end if
|
} # end if
|
||||||
} # end foreach p_k
|
} # end foreach p_k
|
||||||
|
@ -667,7 +667,7 @@ $log->debug("Have question ? for $k $$search{$k} $db_field") if DEBUG_ALL;
|
||||||
push @where, $db_field.' IS NULL';
|
push @where, $db_field.' IS NULL';
|
||||||
} else {
|
} else {
|
||||||
if ( ! ( $db_field =~ /\?/ ) ) {
|
if ( ! ( $db_field =~ /\?/ ) ) {
|
||||||
push @where, $db_field .'=?';
|
push @where, '`'.$db_field .'`=?';
|
||||||
} else {
|
} else {
|
||||||
push @where, $db_field;
|
push @where, $db_field;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ use constant SELECT_TIMEOUT => 0.25;
|
||||||
|
|
||||||
@EXTRA_PERL_LIB@
|
@EXTRA_PERL_LIB@
|
||||||
use ZoneMinder;
|
use ZoneMinder;
|
||||||
|
use ZoneMinder::Monitor;
|
||||||
use ZoneMinder::Trigger::Channel::Inet;
|
use ZoneMinder::Trigger::Channel::Inet;
|
||||||
use ZoneMinder::Trigger::Channel::Unix;
|
use ZoneMinder::Trigger::Channel::Unix;
|
||||||
use ZoneMinder::Trigger::Channel::Serial;
|
use ZoneMinder::Trigger::Channel::Serial;
|
||||||
|
@ -203,14 +204,10 @@ while (!$zm_terminate) {
|
||||||
# Check for alarms that might have happened
|
# Check for alarms that might have happened
|
||||||
my @out_messages;
|
my @out_messages;
|
||||||
foreach my $monitor ( values %monitors ) {
|
foreach my $monitor ( values %monitors ) {
|
||||||
if ($$monitor{Function} eq 'None') {
|
if (!$monitor->connect()) {
|
||||||
$monitor_reload_time = 0;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!zmMemVerify($monitor)) {
|
|
||||||
# Our attempt to verify the memory handle failed. We should reload the monitors.
|
# Our attempt to verify the memory handle failed. We should reload the monitors.
|
||||||
# Don't need to zmMemInvalidate because the monitor reload will do it.
|
# Don't need to zmMemInvalidate because the monitor reload will do it.
|
||||||
|
Debug("Failed connect, putting on reloads");
|
||||||
push @needsReload, $monitor;
|
push @needsReload, $monitor;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
@ -249,6 +246,7 @@ while (!$zm_terminate) {
|
||||||
}
|
}
|
||||||
$monitor->{LastState} = $state;
|
$monitor->{LastState} = $state;
|
||||||
$monitor->{LastEvent} = $last_event;
|
$monitor->{LastEvent} = $last_event;
|
||||||
|
$monitor->disconnect();
|
||||||
} # end foreach monitor
|
} # end foreach monitor
|
||||||
|
|
||||||
foreach my $connection ( @out_connections ) {
|
foreach my $connection ( @out_connections ) {
|
||||||
|
@ -298,15 +296,22 @@ while (!$zm_terminate) {
|
||||||
|
|
||||||
# Reload all monitors from the dB every MONITOR_RELOAD_INTERVAL
|
# Reload all monitors from the dB every MONITOR_RELOAD_INTERVAL
|
||||||
if ( (time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL ) {
|
if ( (time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL ) {
|
||||||
foreach my $monitor ( values(%monitors) ) {
|
|
||||||
zmMemInvalidate( $monitor ); # Free up any used memory handle
|
|
||||||
}
|
|
||||||
loadMonitors();
|
loadMonitors();
|
||||||
@needsReload = (); # We just reloaded all monitors so no need reload a specific monitor
|
@needsReload = (); # We just reloaded all monitors so no need reload a specific monitor
|
||||||
# If we have NOT just reloaded all monitors, reload a specific monitor if its shared mem changed
|
# If we have NOT just reloaded all monitors, reload a specific monitor if its shared mem changed
|
||||||
} elsif ( @needsReload ) {
|
} elsif (@needsReload) {
|
||||||
foreach my $monitor ( @needsReload ) {
|
foreach my $monitor (@needsReload) {
|
||||||
loadMonitor($monitor);
|
$monitor = $monitors{$monitor->Id()} = ZoneMinder::Monitor->find_one(Id=>$monitor->Id());
|
||||||
|
if ( $$monitor{Function} eq 'None' ) {
|
||||||
|
delete $monitors{$monitor->Id()};
|
||||||
|
} elsif ( $Config{ZM_SERVER_ID} and ($$monitor{ServerId} != $Config{ZM_SERVER_ID})) {
|
||||||
|
delete $monitors{$monitor->Id()};
|
||||||
|
} else {
|
||||||
|
if ($monitor->connect()) {
|
||||||
|
$monitor->{LastState} = zmGetMonitorState($monitor);
|
||||||
|
$monitor->{LastEvent} = zmGetLastEvent($monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@needsReload = ();
|
@needsReload = ();
|
||||||
}
|
}
|
||||||
|
@ -317,40 +322,21 @@ while (!$zm_terminate) {
|
||||||
Info('Trigger daemon exiting');
|
Info('Trigger daemon exiting');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
sub loadMonitor {
|
|
||||||
my $monitor = shift;
|
|
||||||
|
|
||||||
Debug('Loading monitor '.$monitor);
|
|
||||||
zmMemInvalidate($monitor);
|
|
||||||
|
|
||||||
if ( zmMemVerify($monitor) ) { # This will re-init shared memory
|
|
||||||
$monitor->{LastState} = zmGetMonitorState($monitor);
|
|
||||||
$monitor->{LastEvent} = zmGetLastEvent($monitor);
|
|
||||||
}
|
|
||||||
} # end sub loadMonitor
|
|
||||||
|
|
||||||
sub loadMonitors {
|
sub loadMonitors {
|
||||||
$monitor_reload_time = time();
|
$monitor_reload_time = time();
|
||||||
|
|
||||||
my %new_monitors = ();
|
%monitors = ();
|
||||||
|
|
||||||
my $sql = 'SELECT * FROM `Monitors`
|
foreach my $monitor ( ZoneMinder::Monitor->find(
|
||||||
WHERE find_in_set( `Function`, \'Modect,Mocord,Nodect,Record\' )'.
|
Function=>['Modect','Mocord','Nodect','Record'],
|
||||||
( $Config{ZM_SERVER_ID} ? ' AND `ServerId`=?' : '' )
|
($Config{ZM_SERVER_ID} ? (ServerId=>$Config{ZM_SERVER_ID}) : ()),
|
||||||
;
|
)) {
|
||||||
my $sth = $dbh->prepare_cached( $sql )
|
if ($monitor->connect()) { # This will re-init shared memory
|
||||||
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
|
|
||||||
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
|
|
||||||
or Fatal( "Can't execute: ".$sth->errstr() );
|
|
||||||
|
|
||||||
while ( my $monitor = $sth->fetchrow_hashref() ) {
|
|
||||||
if ( zmMemVerify($monitor) ) { # This will re-init shared memory
|
|
||||||
$monitor->{LastState} = zmGetMonitorState($monitor);
|
$monitor->{LastState} = zmGetMonitorState($monitor);
|
||||||
$monitor->{LastEvent} = zmGetLastEvent($monitor);
|
$monitor->{LastEvent} = zmGetLastEvent($monitor);
|
||||||
}
|
}
|
||||||
$new_monitors{$monitor->{Id}} = $monitor;
|
$monitors{$monitor->{Id}} = $monitor;
|
||||||
} # end while fetchrow
|
} # end while fetchrow
|
||||||
%monitors = %new_monitors;
|
|
||||||
} # end sub loadMonitors
|
} # end sub loadMonitors
|
||||||
|
|
||||||
sub handleMessage {
|
sub handleMessage {
|
||||||
|
|
|
@ -1077,7 +1077,7 @@ bool Monitor::connect() {
|
||||||
//ONVIF Setup
|
//ONVIF Setup
|
||||||
#ifdef WITH_GSOAP
|
#ifdef WITH_GSOAP
|
||||||
ONVIF_Trigger_State = FALSE;
|
ONVIF_Trigger_State = FALSE;
|
||||||
if (onvif_event_listener) { //Temporarily using this option to enable the feature
|
if (onvif_event_listener) {
|
||||||
Debug(1, "Starting ONVIF");
|
Debug(1, "Starting ONVIF");
|
||||||
ONVIF_Healthy = FALSE;
|
ONVIF_Healthy = FALSE;
|
||||||
if (onvif_options.find("closes_event") != std::string::npos) { //Option to indicate that ONVIF will send a close event message
|
if (onvif_options.find("closes_event") != std::string::npos) { //Option to indicate that ONVIF will send a close event message
|
||||||
|
@ -1869,11 +1869,18 @@ bool Monitor::Analyse() {
|
||||||
score += 9;
|
score += 9;
|
||||||
Debug(1, "Triggered on ONVIF");
|
Debug(1, "Triggered on ONVIF");
|
||||||
if (!event) {
|
if (!event) {
|
||||||
|
Event::StringSet noteSet;
|
||||||
|
noteSet.insert("ONVIF2");
|
||||||
|
noteSetMap[MOTION_CAUSE] = noteSet;
|
||||||
|
|
||||||
|
event = openEvent(snap, "ONVIF", noteSetMap);
|
||||||
cause += "ONVIF";
|
cause += "ONVIF";
|
||||||
|
} else {
|
||||||
|
event->addNote(MOTION_CAUSE, "ONVIF2");
|
||||||
|
// Add to cause
|
||||||
}
|
}
|
||||||
Event::StringSet noteSet;
|
// Regardless of previous state, we go to ALARM
|
||||||
noteSet.insert("ONVIF2");
|
shared_data->state = state = ALARM;
|
||||||
noteSetMap[MOTION_CAUSE] = noteSet;
|
|
||||||
//If the camera isn't going to send an event close, we need to close it here, but only after it has actually triggered an alarm.
|
//If the camera isn't going to send an event close, we need to close it here, but only after it has actually triggered an alarm.
|
||||||
if (!ONVIF_Closes_Event && state == ALARM)
|
if (!ONVIF_Closes_Event && state == ALARM)
|
||||||
ONVIF_Trigger_State = FALSE;
|
ONVIF_Trigger_State = FALSE;
|
||||||
|
@ -1885,13 +1892,16 @@ bool Monitor::Analyse() {
|
||||||
score += trigger_data->trigger_score;
|
score += trigger_data->trigger_score;
|
||||||
Debug(1, "Triggered on score += %d => %d", trigger_data->trigger_score, score);
|
Debug(1, "Triggered on score += %d => %d", trigger_data->trigger_score, score);
|
||||||
if (!event) {
|
if (!event) {
|
||||||
if (!cause.empty())
|
Event::StringSet noteSet;
|
||||||
cause += ", ";
|
noteSet.insert(trigger_data->trigger_text);
|
||||||
cause += trigger_data->trigger_cause;
|
noteSetMap[trigger_data->trigger_cause] = noteSet;
|
||||||
|
event = openEvent(snap, trigger_data->trigger_cause, noteSetMap);
|
||||||
|
Info("%s: %03d - Opening new event %" PRIu64 ", alarm start", name.c_str(), analysis_image_count, event->Id());
|
||||||
|
} else {
|
||||||
|
event->addNote(trigger_data->trigger_cause, trigger_data->trigger_text);
|
||||||
|
// Need to know if we should end the previous and start a new one, or just add the data
|
||||||
}
|
}
|
||||||
Event::StringSet noteSet;
|
shared_data->state = state = ALARM;
|
||||||
noteSet.insert(trigger_data->trigger_text);
|
|
||||||
noteSetMap[trigger_data->trigger_cause] = noteSet;
|
|
||||||
} // end if trigger_on
|
} // end if trigger_on
|
||||||
|
|
||||||
// FIXME this snap might not be the one that caused the signal change. Need to store that in the packet.
|
// FIXME this snap might not be the one that caused the signal change. Need to store that in the packet.
|
||||||
|
@ -1968,8 +1978,6 @@ bool Monitor::Analyse() {
|
||||||
} // end while ! decoded
|
} // end while ! decoded
|
||||||
} // end if decoding enabled
|
} // end if decoding enabled
|
||||||
|
|
||||||
SystemTimePoint timestamp = snap->timestamp;
|
|
||||||
|
|
||||||
if (Active() and (function == MODECT or function == MOCORD)) {
|
if (Active() and (function == MODECT or function == MOCORD)) {
|
||||||
Debug(3, "signal and active and modect");
|
Debug(3, "signal and active and modect");
|
||||||
Event::StringSet zoneSet;
|
Event::StringSet zoneSet;
|
||||||
|
@ -1991,7 +1999,7 @@ bool Monitor::Analyse() {
|
||||||
} else if (!(analysis_image_count % (motion_frame_skip+1))) {
|
} else if (!(analysis_image_count % (motion_frame_skip+1))) {
|
||||||
Debug(1, "Detecting motion on image %d, image %p", snap->image_index, snap->image);
|
Debug(1, "Detecting motion on image %d, image %p", snap->image_index, snap->image);
|
||||||
// Get new score.
|
// Get new score.
|
||||||
int motion_score = DetectMotion(*(snap->image), zoneSet);
|
snap->score = DetectMotion(*(snap->image), zoneSet);
|
||||||
|
|
||||||
if (!snap->analysis_image)
|
if (!snap->analysis_image)
|
||||||
snap->analysis_image = new Image(*(snap->image));
|
snap->analysis_image = new Image(*(snap->image));
|
||||||
|
@ -2010,11 +2018,11 @@ bool Monitor::Analyse() {
|
||||||
}
|
}
|
||||||
alarm_image.Assign(*(snap->analysis_image));
|
alarm_image.Assign(*(snap->analysis_image));
|
||||||
Debug(3, "After motion detection, score:%d last_motion_score(%d), new motion score(%d)",
|
Debug(3, "After motion detection, score:%d last_motion_score(%d), new motion score(%d)",
|
||||||
score, last_motion_score, motion_score);
|
score, last_motion_score, snap->score);
|
||||||
motion_frame_count += 1;
|
motion_frame_count += 1;
|
||||||
last_motion_score = motion_score;
|
last_motion_score = snap->score;
|
||||||
|
|
||||||
if (motion_score) {
|
if (snap->score) {
|
||||||
if (cause.length()) cause += ", ";
|
if (cause.length()) cause += ", ";
|
||||||
cause += MOTION_CAUSE+std::string(":")+snap->alarm_cause;
|
cause += MOTION_CAUSE+std::string(":")+snap->alarm_cause;
|
||||||
noteSetMap[MOTION_CAUSE] = zoneSet;
|
noteSetMap[MOTION_CAUSE] = zoneSet;
|
||||||
|
@ -2026,7 +2034,7 @@ bool Monitor::Analyse() {
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "no image so skipping motion detection");
|
Debug(1, "no image so skipping motion detection");
|
||||||
} // end if has image
|
} // end if has image
|
||||||
score += last_motion_score;
|
//score += last_motion_score;
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "Not Active(%d) enabled %d shared->active %d doing motion detection: %d",
|
Debug(1, "Not Active(%d) enabled %d shared->active %d doing motion detection: %d",
|
||||||
Active(), enabled, shared_data->active,
|
Active(), enabled, shared_data->active,
|
||||||
|
@ -2039,17 +2047,17 @@ bool Monitor::Analyse() {
|
||||||
if (event) {
|
if (event) {
|
||||||
Debug(2, "Have event %" PRIu64 " in record", event->Id());
|
Debug(2, "Have event %" PRIu64 " in record", event->Id());
|
||||||
|
|
||||||
if (section_length != Seconds(0) && (timestamp - event->StartTime() >= section_length)
|
if (section_length != Seconds(0) && (snap->timestamp - event->StartTime() >= section_length)
|
||||||
&& ((function == MOCORD && event_close_mode != CLOSE_TIME)
|
&& ((function == MOCORD && event_close_mode != CLOSE_TIME)
|
||||||
|| (function == RECORD && event_close_mode == CLOSE_TIME)
|
|| (function == RECORD && event_close_mode == CLOSE_TIME)
|
||||||
|| std::chrono::duration_cast<Seconds>(timestamp.time_since_epoch()) % section_length == Seconds(0))) {
|
|| std::chrono::duration_cast<Seconds>(snap->timestamp.time_since_epoch()) % section_length == Seconds(0))) {
|
||||||
Info("%s: %03d - Closing event %" PRIu64 ", section end forced %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64 ,
|
Info("%s: %03d - Closing event %" PRIu64 ", section end forced %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64 ,
|
||||||
name.c_str(),
|
name.c_str(),
|
||||||
image_count,
|
image_count,
|
||||||
event->Id(),
|
event->Id(),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(timestamp.time_since_epoch()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp.time_since_epoch()).count()),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(event->StartTime().time_since_epoch()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(event->StartTime().time_since_epoch()).count()),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(timestamp - event->StartTime()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp - event->StartTime()).count()),
|
||||||
static_cast<int64>(Seconds(section_length).count()));
|
static_cast<int64>(Seconds(section_length).count()));
|
||||||
closeEvent();
|
closeEvent();
|
||||||
} // end if section_length
|
} // end if section_length
|
||||||
|
@ -2067,13 +2075,14 @@ bool Monitor::Analyse() {
|
||||||
} // end if ! event
|
} // end if ! event
|
||||||
} // end if RECORDING
|
} // end if RECORDING
|
||||||
|
|
||||||
if (score and (function != MONITOR)) {
|
if ((snap->score > 0) and (function != MONITOR)) {
|
||||||
if ((state == IDLE) || (state == TAPE) || (state == PREALARM)) {
|
if ((state == IDLE) || (state == TAPE) || (state == PREALARM)) {
|
||||||
// If we should end then previous continuous event and start a new non-continuous event
|
// If we should end then previous continuous event and start a new non-continuous event
|
||||||
if (event && event->Frames()
|
if (event && event->Frames()
|
||||||
&& !event->AlarmFrames()
|
&& !event->AlarmFrames()
|
||||||
&& (event_close_mode == CLOSE_ALARM)
|
&& (event_close_mode == CLOSE_ALARM)
|
||||||
&& ((timestamp - event->StartTime()) >= min_section_length)
|
// FIXME since we won't be including this snap in the event if we close it, we should be looking at event->duration() instead
|
||||||
|
&& ((snap->timestamp - event->StartTime()) >= min_section_length)
|
||||||
&& ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count - 1))) {
|
&& ((!pre_event_count) || (Event::PreAlarmCount() >= alarm_frame_count - 1))) {
|
||||||
Info("%s: %03d - Closing event %" PRIu64 ", continuous end, alarm begins",
|
Info("%s: %03d - Closing event %" PRIu64 ", continuous end, alarm begins",
|
||||||
name.c_str(), image_count, event->Id());
|
name.c_str(), image_count, event->Id());
|
||||||
|
@ -2085,7 +2094,7 @@ bool Monitor::Analyse() {
|
||||||
Event::PreAlarmCount(), pre_event_count,
|
Event::PreAlarmCount(), pre_event_count,
|
||||||
event->Frames(),
|
event->Frames(),
|
||||||
event->AlarmFrames(),
|
event->AlarmFrames(),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(timestamp - event->StartTime()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp - event->StartTime()).count()),
|
||||||
static_cast<int64>(Seconds(min_section_length).count()),
|
static_cast<int64>(Seconds(min_section_length).count()),
|
||||||
(event_close_mode == CLOSE_ALARM));
|
(event_close_mode == CLOSE_ALARM));
|
||||||
}
|
}
|
||||||
|
@ -2095,12 +2104,10 @@ bool Monitor::Analyse() {
|
||||||
|
|
||||||
if (!event) {
|
if (!event) {
|
||||||
event = openEvent(snap, cause, noteSetMap);
|
event = openEvent(snap, cause, noteSetMap);
|
||||||
shared_data->state = state = ALARM;
|
|
||||||
Info("%s: %03d - Opening new event %" PRIu64 ", alarm start", name.c_str(), analysis_image_count, event->Id());
|
Info("%s: %03d - Opening new event %" PRIu64 ", alarm start", name.c_str(), analysis_image_count, event->Id());
|
||||||
} else {
|
|
||||||
shared_data->state = state = ALARM;
|
|
||||||
} // end if no event, so start it
|
} // end if no event, so start it
|
||||||
if ( alarm_frame_count ) {
|
shared_data->state = state = ALARM;
|
||||||
|
if (alarm_frame_count) {
|
||||||
Debug(1, "alarm frame count so SavePreAlarmFrames");
|
Debug(1, "alarm frame count so SavePreAlarmFrames");
|
||||||
event->SavePreAlarmFrames();
|
event->SavePreAlarmFrames();
|
||||||
}
|
}
|
||||||
|
@ -2122,13 +2129,14 @@ bool Monitor::Analyse() {
|
||||||
Debug(1, "Was in TAPE, going into ALARM");
|
Debug(1, "Was in TAPE, going into ALARM");
|
||||||
} else {
|
} else {
|
||||||
Debug(1, "Staying in %s", State_Strings[state].c_str());
|
Debug(1, "Staying in %s", State_Strings[state].c_str());
|
||||||
|
|
||||||
}
|
}
|
||||||
if (state == ALARM) {
|
if (state == ALARM) {
|
||||||
last_alarm_count = analysis_image_count;
|
last_alarm_count = analysis_image_count;
|
||||||
} // This is needed so post_event_count counts after last alarmed frames while in ALARM not single alarmed frames while ALERT
|
} // This is needed so post_event_count counts after last alarmed frames while in ALARM not single alarmed frames while ALERT
|
||||||
} else { // no score?
|
} else if (!score and snap->score == 0) { // snap->score means -1 which means didn't do motion detection so don't do state transition
|
||||||
|
Debug(1, "!score");
|
||||||
alert_to_alarm_frame_count = alarm_frame_count; // load same value configured for alarm_frame_count
|
alert_to_alarm_frame_count = alarm_frame_count; // load same value configured for alarm_frame_count
|
||||||
|
|
||||||
if (state == ALARM) {
|
if (state == ALARM) {
|
||||||
Info("%s: %03d - Gone into alert state", name.c_str(), analysis_image_count);
|
Info("%s: %03d - Gone into alert state", name.c_str(), analysis_image_count);
|
||||||
shared_data->state = state = ALERT;
|
shared_data->state = state = ALERT;
|
||||||
|
@ -2136,7 +2144,7 @@ bool Monitor::Analyse() {
|
||||||
if (
|
if (
|
||||||
((analysis_image_count - last_alarm_count) > post_event_count)
|
((analysis_image_count - last_alarm_count) > post_event_count)
|
||||||
&&
|
&&
|
||||||
((timestamp - event->StartTime()) >= min_section_length)) {
|
((snap->timestamp - event->StartTime()) >= min_section_length)) {
|
||||||
Info("%s: %03d - Left alarm state (%" PRIu64 ") - %d(%d) images",
|
Info("%s: %03d - Left alarm state (%" PRIu64 ") - %d(%d) images",
|
||||||
name.c_str(), analysis_image_count, event->Id(), event->Frames(), event->AlarmFrames());
|
name.c_str(), analysis_image_count, event->Id(), event->Frames(), event->AlarmFrames());
|
||||||
if (
|
if (
|
||||||
|
@ -2163,7 +2171,7 @@ bool Monitor::Analyse() {
|
||||||
analysis_image_count,
|
analysis_image_count,
|
||||||
last_alarm_count,
|
last_alarm_count,
|
||||||
post_event_count,
|
post_event_count,
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(timestamp.time_since_epoch()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp.time_since_epoch()).count()),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(GetVideoWriterStartTime().time_since_epoch()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(GetVideoWriterStartTime().time_since_epoch()).count()),
|
||||||
static_cast<int64>(Seconds(min_section_length).count()));
|
static_cast<int64>(Seconds(min_section_length).count()));
|
||||||
}
|
}
|
||||||
|
@ -2171,21 +2179,22 @@ bool Monitor::Analyse() {
|
||||||
Event::EmptyPreAlarmFrames();
|
Event::EmptyPreAlarmFrames();
|
||||||
} // end if score or not
|
} // end if score or not
|
||||||
|
|
||||||
snap->score = score;
|
if (score > snap->score)
|
||||||
|
snap->score = score;
|
||||||
|
|
||||||
if (state == PREALARM) {
|
if (state == PREALARM) {
|
||||||
// incremement pre alarm image count
|
// incremement pre alarm image count
|
||||||
Event::AddPreAlarmFrame(snap->image, timestamp, score, nullptr);
|
Event::AddPreAlarmFrame(snap->image, snap->timestamp, score, nullptr);
|
||||||
} else if (state == ALARM) {
|
} else if (state == ALARM) {
|
||||||
if (event) {
|
if (event) {
|
||||||
if (noteSetMap.size() > 0)
|
if (noteSetMap.size() > 0)
|
||||||
event->updateNotes(noteSetMap);
|
event->updateNotes(noteSetMap);
|
||||||
if (section_length != Seconds(0) && (timestamp - event->StartTime() >= section_length)) {
|
if (section_length != Seconds(0) && (snap->timestamp - event->StartTime() >= section_length)) {
|
||||||
Warning("%s: %03d - event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64,
|
Warning("%s: %03d - event %" PRIu64 ", has exceeded desired section length. %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64,
|
||||||
name.c_str(), analysis_image_count, event->Id(),
|
name.c_str(), analysis_image_count, event->Id(),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(timestamp.time_since_epoch()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp.time_since_epoch()).count()),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(GetVideoWriterStartTime().time_since_epoch()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(GetVideoWriterStartTime().time_since_epoch()).count()),
|
||||||
static_cast<int64>(std::chrono::duration_cast<Seconds>(timestamp - GetVideoWriterStartTime()).count()),
|
static_cast<int64>(std::chrono::duration_cast<Seconds>(snap->timestamp - GetVideoWriterStartTime()).count()),
|
||||||
static_cast<int64>(Seconds(section_length).count()));
|
static_cast<int64>(Seconds(section_length).count()));
|
||||||
closeEvent();
|
closeEvent();
|
||||||
event = openEvent(snap, cause, noteSetMap);
|
event = openEvent(snap, cause, noteSetMap);
|
||||||
|
@ -3120,7 +3129,7 @@ int Monitor::PrimeCapture() {
|
||||||
|
|
||||||
#ifdef WITH_GSOAP //For now, just don't run the thread if no ONVIF support. This may change if we add other long polling options.
|
#ifdef WITH_GSOAP //For now, just don't run the thread if no ONVIF support. This may change if we add other long polling options.
|
||||||
//ONVIF Thread
|
//ONVIF Thread
|
||||||
if (onvif_event_listener) {
|
if (onvif_event_listener && ONVIF_Healthy) {
|
||||||
if (!Poller) {
|
if (!Poller) {
|
||||||
Poller = zm::make_unique<PollThread>(this);
|
Poller = zm::make_unique<PollThread>(this);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 14292374ccf1328f2d5db20897bd06f99ba4d938
|
Subproject commit 0bd63fb464957080ead342db58ca9e01532cf1ef
|
Loading…
Reference in New Issue