Use a flag to tell whether we have written the snapshot jpeg yet. If image data has been freed from packets, we may not write the snapshot because we already had a packet with a higher score.
parent
fc2e5aa135
commit
83a2e543f9
|
@ -60,6 +60,7 @@ Event::Event(
|
|||
max_score(-1),
|
||||
//path(""),
|
||||
//snapshit_file(),
|
||||
snapshot_file_written(false),
|
||||
//alarm_file(""),
|
||||
videoStore(nullptr),
|
||||
//video_name(""),
|
||||
|
@ -450,10 +451,11 @@ void Event::AddFrame(const std::shared_ptr<ZMPacket>&packet) {
|
|||
} // end if save_jpegs
|
||||
|
||||
// If this is the first frame, we should add a thumbnail to the event directory
|
||||
if ((frames == 1) || (score > max_score)) {
|
||||
if ((frames == 1) || (score > max_score) || (!snapshot_file_written)) {
|
||||
write_to_db = true; // web ui might show this as thumbnail, so db needs to know about it.
|
||||
Debug(1, "Writing snapshot to %s", snapshot_file.c_str());
|
||||
WriteFrameImage(packet->image, packet->timestamp, snapshot_file.c_str());
|
||||
snapshot_file_written = true;
|
||||
} else {
|
||||
Debug(1, "Not Writing snapshot because frames %d score %d > max %d", frames, score, max_score);
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ class Event {
|
|||
int max_score;
|
||||
std::string path;
|
||||
std::string snapshot_file;
|
||||
bool snapshot_file_written;
|
||||
std::string alarm_file;
|
||||
VideoStore *videoStore;
|
||||
|
||||
|
|
Loading…
Reference in New Issue