From 3c59a9a34db363fc1ae4dace2623afbff0508e6c Mon Sep 17 00:00:00 2001 From: stan Date: Thu, 19 Sep 2002 09:38:17 +0000 Subject: [PATCH] Changed event scoring to be calculated as events are created. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@14 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm.cpp | 7 ++++++- src/zm.h | 2 ++ web/zm.php | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/zm.cpp b/src/zm.cpp index 023122f79..091487cda 100644 --- a/src/zm.cpp +++ b/src/zm.cpp @@ -1289,6 +1289,8 @@ Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ), end_time = 0; frames = 0; alarm_frames = 0; + tot_score = 0; + max_score = 0; sprintf( path, "%s/%04d", monitor->GetTimestampPath( 0 ), id ); struct stat statbuf; @@ -1306,7 +1308,7 @@ Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ), Event::~Event() { static char sql[256]; - sprintf( sql, "update Events set Name='Event-%d', EndTime = now(), Length = %d, Frames = %d, AlarmFrames = %d where Id=%d", id, (end_time-start_time), frames, alarm_frames, id ); + sprintf( sql, "update Events set Name='Event-%d', EndTime = now(), Length = %d, Frames = %d, AlarmFrames = %d, AvgScore = %d, MaxScore = %d where Id=%d", id, (end_time-start_time), frames, alarm_frames, (int)(tot_score/alarm_frames), max_score, id ); if ( mysql_query( &dbconn, sql ) ) { Error(( "Can't update event: %s\n", mysql_error( &dbconn ) )); @@ -1339,6 +1341,9 @@ void Event::AddFrame( time_t timestamp, const Image *image, const Image *alarm_i alarm_frames++; sprintf( event_file, "%s/analyse-%03d.jpg", path, frames ); alarm_image->WriteJpeg( event_file ); + tot_score += score; + if ( score > max_score ) + max_score = score; } } diff --git a/src/zm.h b/src/zm.h index 416fc23ac..0876c7e70 100644 --- a/src/zm.h +++ b/src/zm.h @@ -490,6 +490,8 @@ protected: int end_frame_id; int frames; int alarm_frames; + unsigned int tot_score; + unsigned int max_score; char path[256]; public: diff --git a/web/zm.php b/web/zm.php index 6d75a21fd..ec2012d63 100644 --- a/web/zm.php +++ b/web/zm.php @@ -457,7 +457,8 @@ function checkAll(form,name){ - +
() () ()