always commit buffered db_frames when we have a new max score image or alarm cause image
This commit is contained in:
parent
9faaba9300
commit
f719dd9acc
|
@ -538,6 +538,7 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
}
|
}
|
||||||
|
|
||||||
frames++;
|
frames++;
|
||||||
|
bool write_to_db = false;
|
||||||
|
|
||||||
if ( monitor->GetOptSaveJPEGs() & 1 ) {
|
if ( monitor->GetOptSaveJPEGs() & 1 ) {
|
||||||
static char event_file[PATH_MAX];
|
static char event_file[PATH_MAX];
|
||||||
|
@ -549,10 +550,12 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
} else {
|
} else {
|
||||||
//If this is the first frame, we should add a thumbnail to the event directory
|
//If this is the first frame, we should add a thumbnail to the event directory
|
||||||
if ( (frames == 1) || (score > (int)max_score) ) {
|
if ( (frames == 1) || (score > (int)max_score) ) {
|
||||||
|
write_to_db = true; // web ui might show this as thumbnail, so db needs to know about it.
|
||||||
WriteFrameImage(image, timestamp, snapshot_file);
|
WriteFrameImage(image, timestamp, snapshot_file);
|
||||||
}
|
}
|
||||||
// The first frame with a score will be the frame that alarmed the event
|
// The first frame with a score will be the frame that alarmed the event
|
||||||
if ( (!alarm_frame_written) && (score > 0) ) {
|
if ( (!alarm_frame_written) && (score > 0) ) {
|
||||||
|
write_to_db = true; // OD processing will need it, so the db needs to know about it
|
||||||
alarm_frame_written = true;
|
alarm_frame_written = true;
|
||||||
WriteFrameImage(image, timestamp, alarm_file);
|
WriteFrameImage(image, timestamp, alarm_file);
|
||||||
}
|
}
|
||||||
|
@ -574,7 +577,7 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||||
|
|
||||||
frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score));
|
frame_data.push(new Frame(id, frames, frame_type, timestamp, delta_time, score));
|
||||||
if ( frame_data.size() > 20 ) {
|
if ( write_to_db || ( frame_data.size() > 20 ) ) {
|
||||||
WriteDbFrames();
|
WriteDbFrames();
|
||||||
Debug(1, "Adding 20 frames to DB");
|
Debug(1, "Adding 20 frames to DB");
|
||||||
last_db_frame = frames;
|
last_db_frame = frames;
|
||||||
|
|
Loading…
Reference in New Issue