Move the bulk frame logic from monitor to event. Fix up the logic of when to store a db frame. Fix altering max_score too early
This commit is contained in:
parent
d4e83620b2
commit
35470951ad
|
@ -637,13 +637,20 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
frames++;
|
frames++;
|
||||||
|
|
||||||
bool write_to_db = false;
|
bool write_to_db = false;
|
||||||
FrameType frame_type = score>0?ALARM:(score<0?BULK:NORMAL);
|
FrameType frame_type = ( ( score > 0 ) ? ALARM : (
|
||||||
// < 0 means no motion detection is being done.
|
(
|
||||||
|
( monitor->GetState() == Monitor::TAPE )
|
||||||
|
and
|
||||||
|
( config.bulk_frame_interval > 1 )
|
||||||
|
and
|
||||||
|
( ! (frames % config.bulk_frame_interval) )
|
||||||
|
) ? BULK : NORMAL
|
||||||
|
) );
|
||||||
|
|
||||||
if ( score < 0 )
|
if ( score < 0 )
|
||||||
score = 0;
|
score = 0;
|
||||||
|
|
||||||
tot_score += score;
|
tot_score += score;
|
||||||
if ( score > (int)max_score )
|
|
||||||
max_score = score;
|
|
||||||
|
|
||||||
if ( image ) {
|
if ( image ) {
|
||||||
if ( save_jpegs & 1 ) {
|
if ( save_jpegs & 1 ) {
|
||||||
|
@ -680,22 +687,24 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
} // end if is an alarm frame
|
} // end if is an alarm frame
|
||||||
} // end if has image
|
} // end if has image
|
||||||
|
|
||||||
bool db_frame = ( frame_type != BULK ) || (frames==1) || ((frames%config.bulk_frame_interval)==0) ;
|
bool db_frame = ( frame_type == BULK ) || ( frame_type == ALARM ) || ( frames == 1 ) || ( score > (int)max_score );
|
||||||
if ( db_frame ) {
|
if ( db_frame ) {
|
||||||
|
|
||||||
struct DeltaTimeval delta_time;
|
struct DeltaTimeval delta_time;
|
||||||
DELTA_TIMEVAL(delta_time, timestamp, start_time, DT_PREC_2);
|
DELTA_TIMEVAL(delta_time, timestamp, start_time, DT_PREC_2);
|
||||||
Debug(1, "Frame delta is %d.%d - %d.%d = %d.%d",
|
Debug(1, "Frame delta is %d.%d - %d.%d = %d.%d",
|
||||||
start_time.tv_sec, start_time.tv_usec, timestamp.tv_sec, timestamp.tv_usec, delta_time.sec, delta_time.fsec);
|
start_time.tv_sec, start_time.tv_usec,
|
||||||
|
timestamp.tv_sec, timestamp.tv_usec,
|
||||||
|
delta_time.sec, delta_time.fsec);
|
||||||
|
|
||||||
// The idea is to write out 1/sec
|
// The idea is to write out 1/sec
|
||||||
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));
|
||||||
double fps = monitor->get_capture_fps();
|
double fps = monitor->get_capture_fps();
|
||||||
if ( write_to_db
|
if ( write_to_db
|
||||||
or
|
or
|
||||||
(frame_data.size() >= MAX_DB_FRAMES)
|
( frame_data.size() >= MAX_DB_FRAMES )
|
||||||
or
|
or
|
||||||
(frame_type == BULK)
|
( frame_type == BULK )
|
||||||
or
|
or
|
||||||
( fps and (frame_data.size() > fps) )
|
( fps and (frame_data.size() > fps) )
|
||||||
) {
|
) {
|
||||||
|
@ -730,6 +739,8 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
||||||
} // end if frame_type == BULK
|
} // end if frame_type == BULK
|
||||||
} // end if db_frame
|
} // end if db_frame
|
||||||
|
|
||||||
|
if ( score > (int)max_score )
|
||||||
|
max_score = score;
|
||||||
end_time = timestamp;
|
end_time = timestamp;
|
||||||
} // end void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *alarm_image)
|
} // end void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *alarm_image)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue