Assign image to analysis_image before doing motion detection so there is always an image to see. Fix crash.

This commit is contained in:
Isaac Connor 2022-01-07 15:57:01 -05:00
parent 7219809364
commit f4c813a26f
1 changed files with 15 additions and 11 deletions

View File

@ -666,8 +666,8 @@ void Monitor::Load(MYSQL_ROW dbrow, bool load_zones=true, Purpose p = QUERY) {
+ sizeof(TriggerData) + sizeof(TriggerData)
+ sizeof(VideoStoreData) //Information to pass back to the capture process + sizeof(VideoStoreData) //Information to pass back to the capture process
+ (image_buffer_count*sizeof(struct timeval)) + (image_buffer_count*sizeof(struct timeval))
+ (image_buffer_count*camera->ImageSize()) + (image_buffer_count*image_size)
+ camera->ImageSize() // alarm_image + image_size // alarm_image
+ 64; /* Padding used to permit aligning the images buffer to 64 byte boundary */ + 64; /* Padding used to permit aligning the images buffer to 64 byte boundary */
Debug(1, Debug(1,
@ -1970,6 +1970,8 @@ bool Monitor::Analyse() {
} }
if (snap->image) { if (snap->image) {
alarm_image.Assign(*(snap->image));
// decoder may not have been able to provide an image // decoder may not have been able to provide an image
if (!ref_image.Buffer()) { if (!ref_image.Buffer()) {
Debug(1, "Assigning instead of Detecting"); Debug(1, "Assigning instead of Detecting");
@ -2152,7 +2154,7 @@ bool Monitor::Analyse() {
if (state == PREALARM) { if (state == PREALARM) {
// Generate analysis images if necessary // Generate analysis images if necessary
if ((savejpegs > 1) and snap->image) { if (snap->image) {
for (const Zone &zone : zones) { for (const Zone &zone : zones) {
if (zone.Alarmed() and zone.AlarmImage()) { if (zone.Alarmed() and zone.AlarmImage()) {
if (!snap->analysis_image) if (!snap->analysis_image)
@ -2160,21 +2162,23 @@ bool Monitor::Analyse() {
snap->analysis_image->Overlay(*(zone.AlarmImage())); snap->analysis_image->Overlay(*(zone.AlarmImage()));
} // end if zone is alarmed } // end if zone is alarmed
} // end foreach zone } // end foreach zone
alarm_image.Assign(*snap->analysis_image); alarm_image.Assign(*(snap->analysis_image));
} // end if savejpegs } // end if image.
// incremement pre alarm image count // incremement pre alarm image count
Event::AddPreAlarmFrame(snap->image, timestamp, score, nullptr); Event::AddPreAlarmFrame(snap->image, timestamp, score, nullptr);
} else if (state == ALARM) { } else if (state == ALARM) {
if (snap->image) {
for (const Zone &zone : zones) { for (const Zone &zone : zones) {
if (zone.Alarmed()) { if (zone.Alarmed() and zone.AlarmImage()) {
if (zone.AlarmImage() and (savejpegs > 1) and snap->image) {
if (!snap->analysis_image) if (!snap->analysis_image)
snap->analysis_image = new Image(*(snap->image)); snap->analysis_image = new Image(*(snap->image));
snap->analysis_image->Overlay(*(zone.AlarmImage())); snap->analysis_image->Overlay(*(zone.AlarmImage()));
}
} // end if zone is alarmed } // end if zone is alarmed
} // end foreach zone } // end foreach zone
alarm_image.Assign(*(snap->analysis_image));
}
if (event) { if (event) {
if (noteSetMap.size() > 0) if (noteSetMap.size() > 0)
event->updateNotes(noteSetMap); event->updateNotes(noteSetMap);