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
This commit is contained in:
parent
2da6553533
commit
3c59a9a34d
|
@ -1289,6 +1289,8 @@ Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ),
|
||||||
end_time = 0;
|
end_time = 0;
|
||||||
frames = 0;
|
frames = 0;
|
||||||
alarm_frames = 0;
|
alarm_frames = 0;
|
||||||
|
tot_score = 0;
|
||||||
|
max_score = 0;
|
||||||
sprintf( path, "%s/%04d", monitor->GetTimestampPath( 0 ), id );
|
sprintf( path, "%s/%04d", monitor->GetTimestampPath( 0 ), id );
|
||||||
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
@ -1306,7 +1308,7 @@ Event::Event( Monitor *p_monitor, time_t p_start_time ) : monitor( p_monitor ),
|
||||||
Event::~Event()
|
Event::~Event()
|
||||||
{
|
{
|
||||||
static char sql[256];
|
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 ) )
|
if ( mysql_query( &dbconn, sql ) )
|
||||||
{
|
{
|
||||||
Error(( "Can't update event: %s\n", mysql_error( &dbconn ) ));
|
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++;
|
alarm_frames++;
|
||||||
sprintf( event_file, "%s/analyse-%03d.jpg", path, frames );
|
sprintf( event_file, "%s/analyse-%03d.jpg", path, frames );
|
||||||
alarm_image->WriteJpeg( event_file );
|
alarm_image->WriteJpeg( event_file );
|
||||||
|
tot_score += score;
|
||||||
|
if ( score > max_score )
|
||||||
|
max_score = score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
src/zm.h
2
src/zm.h
|
@ -490,6 +490,8 @@ protected:
|
||||||
int end_frame_id;
|
int end_frame_id;
|
||||||
int frames;
|
int frames;
|
||||||
int alarm_frames;
|
int alarm_frames;
|
||||||
|
unsigned int tot_score;
|
||||||
|
unsigned int max_score;
|
||||||
char path[256];
|
char path[256];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -457,7 +457,8 @@ function checkAll(form,name){
|
||||||
<td valign="top"><table border="0" cellspacing="0" cellpadding="0" width="100%">
|
<td valign="top"><table border="0" cellspacing="0" cellpadding="0" width="100%">
|
||||||
<?php
|
<?php
|
||||||
//$sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames from Monitors as M, Events as E where M.Id = '$mid' and M.Id = E.MonitorId and E.Archived = ".($archived?"1":"0")." order by E.Id desc";
|
//$sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames from Monitors as M, Events as E where M.Id = '$mid' and M.Id = E.MonitorId and E.Archived = ".($archived?"1":"0")." order by E.Id desc";
|
||||||
$sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,sum(F.Score)/count(if(F.AlarmFrame,1,NULL)) as Score, max(F.Score) as MaxScore from Monitors as M, Events as E left join Frames as F on E.Id = F.EventId where M.Id = '$mid' and M.Id = E.MonitorId and E.Archived = ".($archived?"1":"0")." group by E.Id order by E.Id desc";
|
//$sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,sum(F.Score)/count(if(F.AlarmFrame,1,NULL)) as Score, max(F.Score) as MaxScore from Monitors as M, Events as E left join Frames as F on E.Id = F.EventId where M.Id = '$mid' and M.Id = E.MonitorId and E.Archived = ".($archived?"1":"0")." group by E.Id order by E.Id desc";
|
||||||
|
$sql = "select E.Id, E.Name,unix_timestamp(E.StartTime) as Time,E.Length,E.Frames,E.AlarmFrames,E.AvgScore,E.MaxScore from Monitors as M, Events as E where M.Id = '$mid' and M.Id = E.MonitorId and E.Archived = ".($archived?"1":"0")." order by E.Id desc";
|
||||||
if ( $max_events )
|
if ( $max_events )
|
||||||
$sql .= " limit 0,$max_events";
|
$sql .= " limit 0,$max_events";
|
||||||
$result = mysql_query( $sql );
|
$result = mysql_query( $sql );
|
||||||
|
@ -501,7 +502,7 @@ function checkAll(form,name){
|
||||||
<td align="center" class="text"><?php echo strftime( "%m/%d %H:%M:%S", $row[Time] ) ?></td>
|
<td align="center" class="text"><?php echo strftime( "%m/%d %H:%M:%S", $row[Time] ) ?></td>
|
||||||
<td align="center" class="text"><?php echo $row[Length] ?></td>
|
<td align="center" class="text"><?php echo $row[Length] ?></td>
|
||||||
<td align="center" class="text"><?php echo $row[Frames] ?> (<?php echo $row[AlarmFrames] ?>)</td>
|
<td align="center" class="text"><?php echo $row[Frames] ?> (<?php echo $row[AlarmFrames] ?>)</td>
|
||||||
<td align="center" class="text"><?php echo (int)$row[Score] ?> (<?php echo sprintf( "%d", $row[MaxScore] ) ?>)</td>
|
<td align="center" class="text"><?php echo $row[AvgScore] ?> (<?php echo $row[MaxScore] ?>)</td>
|
||||||
<td align="center" class="text"><input type="checkbox" name="delete_eids[]" value="<?php echo $row[Id] ?>"></td>
|
<td align="center" class="text"><input type="checkbox" name="delete_eids[]" value="<?php echo $row[Id] ?>"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
|
|
Loading…
Reference in New Issue