Add objdetect.gif support in filter email replacements

This commit is contained in:
Isaac Connor 2021-04-28 19:12:37 -04:00
parent 5622429cc2
commit a8bd1662e3
2 changed files with 22 additions and 6 deletions

View File

@ -70,13 +70,17 @@ Here is what the filter window looks like
* %EPS% Path to the event stream
* %EPF1% Path to the frame view for the first alarmed event image
* %EPFM% Path to the frame view for the (first) event image with the highest score
* %EFMOD% Path to image containing object detection, in frame view
* %EPFMOD% Path to image containing object detection, in frame view
* %EPFMODG% Path to image containing object detection animated gif version, in frame view
* %EPI% Path to the event images
* %EPI1% Path to the first alarmed event image, suitable for use in img tags
* %EPIM% Path to the (first) event image with the highest score, suitable for use in img tags
* %EIMOD% Path to image containing object detection, suitable for use in img tags
* %EPIMOD% Path to image containing object detection, suitable for use in img tags
* %EPIMODG% Path to image containing object detection animated gif version, suitable for use in img tags
* %EI1% Attach first alarmed event image
* %EIM% Attach (first) event image with the highest score
* %EIMOD% Attach image containing object detection
* %EIMODG% Attach image containing object detection animated gif version
* %EV% Attach event mpeg video
* %MN% Name of the monitor
* %MET% Total number of events for the monitor

View File

@ -668,7 +668,7 @@ sub substituteTags {
my $Status = $Monitor->Status() if $need_status;
# Do we need the image information too?
my $need_images = $text =~ /%(?:EPI1|EPIM|EI1|EIM|EI1A|EIMA|EIMOD)%/;
my $need_images = $text =~ /%(?:EPI1|EPIM|EI1|EIM|EI1A|EIMA|EIMOD|EIMODG)%/;
my $first_alarm_frame;
my $max_alarm_frame;
my $max_alarm_score = 0;
@ -726,6 +726,11 @@ sub substituteTags {
$text =~ s/%EPFM%/$url?view=frame&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=$max_alarm_frame->{FrameId}/g;
$text =~ s/%EPI1%/$url?view=image&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=$first_alarm_frame->{FrameId}/g;
$text =~ s/%EPIM%/$url?view=image&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=$max_alarm_frame->{FrameId}/g;
$text =~ s/%EPFMOD%/$url?view=frame&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=objdetect/g;
$text =~ s/%EPIMOD%/$url?view=image&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=objdetect/g;
$text =~ s/%EPFMODG%/$url?view=frame&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=objdetect_gif/g;
$text =~ s/%EPIMODG%/$url?view=image&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=objdetect_gif/g;
if ( $attachments_ref ) {
if ( $text =~ s/%EI1%//g ) {
my $path = generateImage($Event, $first_alarm_frame);
@ -773,9 +778,7 @@ sub substituteTags {
}
}
if ( $text =~ s/%EIMOD%//g or $text =~ s/%EFMOD%//g ) {
$text =~ s/%EFMOD%/$url?view=frame&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=objdetect/g;
$text =~ s/%EIMOD%/$url?view=image&mid=$Event->{MonitorId}&eid=$Event->{Id}&fid=objdetect/g;
if ( $text =~ s/%EIMOD%//g ) {
my $path = $Event->Path().'/objdetect.jpg';
if ( -e $path ) {
push @$attachments_ref, { type=>'image/jpeg', path=>$path };
@ -784,6 +787,15 @@ sub substituteTags {
}
}
if ( $text =~ s/%EIMODG%//g ) {
my $path = $Event->Path().'/objdetect.gif';
if ( -e $path ) {
push @$attachments_ref, { type=>'image/gif', path=>$path };
} else {
Warning('No image for MODG at '.$path);
}
}
} # end if attachments_ref
} # end if $first_alarm_frame