add get_fps to Monitor and use it to adjust the # of frames to cache before writing to db

This commit is contained in:
Isaac Connor 2018-12-16 16:18:50 -05:00
parent ab9081e1bf
commit 19e4ef99bc
3 changed files with 15 additions and 10 deletions

View File

@ -582,7 +582,8 @@ Debug(3, "Writing video");
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() > 10 ) { // The idea is to write out 1/sec
if ( frame_data.size() > (int)monitor->get_fps() ) {
WriteDbFrames(); WriteDbFrames();
Debug(1, "Adding 10 frames to DB"); Debug(1, "Adding 10 frames to DB");
last_db_frame = frames; last_db_frame = frames;

View File

@ -1689,18 +1689,19 @@ Error("Creating new event when one exists");
event->AddFrame( snap_image, *timestamp, score ); event->AddFrame( snap_image, *timestamp, score );
} }
} else { } else {
for( int i = 0; i < n_zones; i++ ) { if ( state == ALARM ) {
if ( zones[i]->Alarmed() ) { if ( config.record_event_stats ) {
if ( config.record_event_stats && state == ALARM ) { for( int i = 0; i < n_zones; i++ ) {
zones[i]->RecordStats( event ); if ( zones[i]->Alarmed() ) {
zones[i]->RecordStats( event );
}
} }
} }
}
if ( state == PREALARM )
Event::AddPreAlarmFrame( snap_image, *timestamp, score );
else
event->AddFrame( snap_image, *timestamp, score ); event->AddFrame( snap_image, *timestamp, score );
} } else { // ( state == PREALARM )
Event::AddPreAlarmFrame( snap_image, *timestamp, score );
}
} // end if analysis_images
if ( event && noteSetMap.size() > 0 ) if ( event && noteSetMap.size() > 0 )
event->updateNotes( noteSetMap ); event->updateNotes( noteSetMap );
} else if ( state == ALERT ) { } else if ( state == ALERT ) {

View File

@ -530,6 +530,9 @@ public:
#if HAVE_LIBAVCODEC #if HAVE_LIBAVCODEC
//void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 ); //void StreamMpeg( const char *format, int scale=100, int maxfps=10, int bitrate=100000 );
#endif // HAVE_LIBAVCODEC #endif // HAVE_LIBAVCODEC
double get_fps( ) const {
return fps;
}
}; };
#define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit)) #define MOD_ADD( var, delta, limit ) (((var)+(limit)+(delta))%(limit))