Load plugins in Monitor class
This commit is contained in:
parent
12f0177f14
commit
731fa96fdf
|
@ -65,6 +65,23 @@ std::vector<std::string> split(const std::string &s, char delim) {
|
|||
}
|
||||
return elems;
|
||||
}
|
||||
|
||||
#if ZM_PLUGINS_ON
|
||||
int conf_select(const struct direct *entry)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
if ((strcmp(entry->d_name, ".")== 0) || (strcmp(entry->d_name, "..") == 0))
|
||||
return 0;
|
||||
|
||||
// Check for filename extensions.
|
||||
ptr = rindex((char*)entry->d_name, '.');
|
||||
if ((ptr != NULL) && (strcmp(ptr, ".conf") == 0))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#endif // ZM_PLUGINS_ON
|
||||
//=============================================================================
|
||||
|
||||
|
||||
|
@ -286,7 +303,8 @@ Monitor::Monitor(
|
|||
Rgb p_signal_check_colour,
|
||||
Purpose p_purpose,
|
||||
int p_n_zones,
|
||||
Zone *p_zones[]
|
||||
Zone *p_zones[],
|
||||
int p_DoNativeMotDet
|
||||
) : id( p_id ),
|
||||
function( (Function)p_function ),
|
||||
enabled( p_enabled ),
|
||||
|
@ -315,7 +333,9 @@ Monitor::Monitor(
|
|||
last_motion_score(0),
|
||||
camera( p_camera ),
|
||||
n_zones( p_n_zones ),
|
||||
zones( p_zones )
|
||||
zones( p_zones ),
|
||||
iDoNativeMotDet( p_DoNativeMotDet ),
|
||||
ThePluginManager( p_id )
|
||||
{
|
||||
strncpy( name, p_name, sizeof(name) );
|
||||
|
||||
|
@ -410,6 +430,35 @@ Monitor::Monitor(
|
|||
shared_data->alarm_y = -1;
|
||||
}
|
||||
|
||||
#if ZM_PLUGINS_ON
|
||||
if ( purpose == ANALYSIS || purpose == QUERY )
|
||||
{
|
||||
if ( config.load_plugins || purpose == QUERY )
|
||||
{
|
||||
Info("Load plugins from the directory %s ... ", config.path_plugins);
|
||||
ThePluginManager.setPluginExt(std::string(config.plugin_extension));
|
||||
unsigned int nNumPlugLoaded = 0;
|
||||
unsigned int nNumPlugFound = ThePluginManager.findPlugins(
|
||||
std::string(config.path_plugins), (purpose == ANALYSIS), nNumPlugLoaded );
|
||||
Info("Found %u plugin(s) - %u loaded", nNumPlugFound, nNumPlugLoaded);
|
||||
if (nNumPlugFound > 0)
|
||||
{
|
||||
ThePluginManager.configurePlugins(
|
||||
std::string(config.plugins_config_path),
|
||||
(!config.turnoff_native_analysis && iDoNativeMotDet));
|
||||
struct direct **files;
|
||||
int count = scandir(config.plugins_config_dir, &files, conf_select, alphasort);
|
||||
if (count > 0)
|
||||
Info("Load plugin configuration files from directory %s ... ", config.plugins_config_dir);
|
||||
for (int i = 0; i < count; ++i)
|
||||
ThePluginManager.configurePlugins(
|
||||
join_paths(config.plugins_config_dir, files[i]->d_name),
|
||||
(!config.turnoff_native_analysis && iDoNativeMotDet));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ZM_PLUGINS_ON
|
||||
|
||||
if ( ( ! mem_ptr ) || ! shared_data->valid )
|
||||
{
|
||||
if ( purpose != QUERY )
|
||||
|
@ -632,6 +681,20 @@ void Monitor::AddZones( int p_n_zones, Zone *p_zones[] )
|
|||
delete[] zones;
|
||||
n_zones = p_n_zones;
|
||||
zones = p_zones;
|
||||
for ( int i = 0; i < n_zones; i++ )
|
||||
{
|
||||
if ( purpose == ANALYSIS )
|
||||
{
|
||||
Zone *zone = zones[i];
|
||||
zone->AssignRefImage( width, height, camera->Colours(), camera->SubpixelOrder(),
|
||||
image_buffer[shared_data->last_write_index].image->Buffer(), camera->ImageSize() );
|
||||
#if ZM_PLUGINS_ON
|
||||
zConf zone_conf;
|
||||
if ( ThePluginManager.getImageAnalyser().getZoneConfig( i, zone_conf ) )
|
||||
zone->SetConfig( zone_conf );
|
||||
#endif // ZM_PLUGINS_ON
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Monitor::State Monitor::GetState() const
|
||||
|
@ -1271,6 +1334,8 @@ bool Monitor::Analyse()
|
|||
cause += ", ";
|
||||
cause += trigger_data->trigger_cause;
|
||||
}
|
||||
else
|
||||
event->AddCause( trigger_data->trigger_cause );
|
||||
Event::StringSet noteSet;
|
||||
noteSet.insert( trigger_data->trigger_text );
|
||||
noteSetMap[trigger_data->trigger_cause] = noteSet;
|
||||
|
@ -1298,6 +1363,8 @@ bool Monitor::Analyse()
|
|||
cause += ", ";
|
||||
cause += SIGNAL_CAUSE;
|
||||
}
|
||||
else
|
||||
event->AddCause( SIGNAL_CAUSE );
|
||||
Event::StringSet noteSet;
|
||||
noteSet.insert( signalText );
|
||||
noteSetMap[SIGNAL_CAUSE] = noteSet;
|
||||
|
@ -1310,31 +1377,70 @@ bool Monitor::Analyse()
|
|||
}
|
||||
else if ( signal && Active() && (function == MODECT || function == MOCORD) )
|
||||
{
|
||||
Event::StringSet zoneSet;
|
||||
unsigned int motion_score = last_motion_score;
|
||||
bool alarm = false;
|
||||
if ( !(image_count % (motion_frame_skip+1) ) )
|
||||
#if ZM_PLUGINS_ON
|
||||
if ((config.turnoff_native_analysis && !config.load_plugins) || (!config.turnoff_native_analysis && (iDoNativeMotDet || (!iDoNativeMotDet && !config.load_plugins))) )
|
||||
#else // ZM_PLUGINS_ON
|
||||
if (!config.turnoff_native_analysis && iDoNativeMotDet)
|
||||
#endif // ZM_PLUGINS_ON
|
||||
{
|
||||
// Get new score.
|
||||
alarm = DetectMotion( *snap_image, zoneSet, motion_score );
|
||||
last_motion_score = motion_score;
|
||||
}
|
||||
//int motion_score = DetectBlack( *snap_image, zoneSet );
|
||||
if ( alarm )
|
||||
{
|
||||
if ( motion_score )
|
||||
Event::StringSet zoneSet;
|
||||
unsigned int motion_score = last_motion_score;
|
||||
bool alarm = false;
|
||||
if ( !(image_count % (motion_frame_skip+1) ) )
|
||||
{
|
||||
score += motion_score;
|
||||
// Get new score.
|
||||
alarm = DetectMotion( *snap_image, zoneSet, motion_score );
|
||||
last_motion_score = motion_score;
|
||||
}
|
||||
//int motion_score = DetectBlack( *snap_image, zoneSet );
|
||||
if ( alarm )
|
||||
{
|
||||
if ( motion_score )
|
||||
{
|
||||
score += motion_score;
|
||||
if ( !event )
|
||||
{
|
||||
if ( cause.length() )
|
||||
cause += ", ";
|
||||
cause += MOTION_CAUSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
event->AddCause( MOTION_CAUSE );
|
||||
}
|
||||
noteSetMap[MOTION_CAUSE] = zoneSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int n_zone = 0; n_zone < n_zones; n_zone++ )
|
||||
{
|
||||
zones[n_zone]->ResetStats();
|
||||
}
|
||||
}
|
||||
#if ZM_PLUGINS_ON
|
||||
if (config.load_plugins)
|
||||
{
|
||||
std::string det_cause; // detection cause to fill in plugin's detectors
|
||||
unsigned int plugin_score = 0;
|
||||
if ( ThePluginManager.getImageAnalyser().DoDetection( *snap_image, zones, noteSetMap, det_cause, plugin_score ) )
|
||||
{
|
||||
score += plugin_score;
|
||||
if ( !event )
|
||||
{
|
||||
if ( cause.length() )
|
||||
cause += ", ";
|
||||
cause += MOTION_CAUSE;
|
||||
if ( det_cause.length() )
|
||||
{
|
||||
if ( cause.length() )
|
||||
cause += ", ";
|
||||
cause += det_cause;
|
||||
}
|
||||
}
|
||||
noteSetMap[MOTION_CAUSE] = zoneSet;
|
||||
else
|
||||
event->AddCause( det_cause );
|
||||
}
|
||||
|
||||
}
|
||||
#endif // ZM_PLUGINS_ON
|
||||
shared_data->active = signal;
|
||||
}
|
||||
if ( (!signal_change && signal) && n_linked_monitors > 0 )
|
||||
|
@ -1357,6 +1463,8 @@ bool Monitor::Analyse()
|
|||
first_link = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
event->AddCause( LINKED_CAUSE );
|
||||
noteSet.insert( linked_monitors[i]->Name() );
|
||||
score += 50;
|
||||
}
|
||||
|
@ -1456,7 +1564,6 @@ bool Monitor::Analyse()
|
|||
pre_index = (pre_index+1)%image_buffer_count;
|
||||
pre_event_images--;
|
||||
}
|
||||
|
||||
event = new Event( this, *(image_buffer[pre_index].timestamp), cause, noteSetMap );
|
||||
shared_data->last_event = event->Id();
|
||||
|
||||
|
@ -1651,7 +1758,7 @@ void Monitor::Reload()
|
|||
closeEvent();
|
||||
|
||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = '%d'", id );
|
||||
snprintf( sql, sizeof(sql), "select Function+0, Enabled, LinkedMonitors, EventPrefix, LabelFormat, LabelX, LabelY, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet, SignalCheckColour from Monitors where Id = '%d'", id );
|
||||
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -1694,7 +1801,8 @@ void Monitor::Reload()
|
|||
ref_blend_perc = atoi(dbrow[index++]);
|
||||
alarm_ref_blend_perc = atoi(dbrow[index++]);
|
||||
track_motion = atoi(dbrow[index++]);
|
||||
|
||||
|
||||
iDoNativeMotDet = atoi(dbrow[index++]);
|
||||
|
||||
if ( dbrow[index][0] == '#' )
|
||||
signal_check_colour = strtol(dbrow[index]+1,0,16);
|
||||
|
@ -1843,11 +1951,11 @@ int Monitor::LoadLocalMonitors( const char *device, Monitor **&monitors, Purpose
|
|||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
if ( !device[0] )
|
||||
{
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) );
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' order by Device, Channel", sizeof(sql) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Method, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet, SignalCheckColour from Monitors where Function != 'None' and Type = 'Local' and Device = '%s' order by Channel", device );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -1933,6 +2041,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|||
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
|
||||
int track_motion = atoi(dbrow[col]); col++;
|
||||
|
||||
int doNativeMotDet = atoi(dbrow[col]); col++;
|
||||
|
||||
int signal_check_colour;
|
||||
if ( dbrow[col][0] == '#' )
|
||||
signal_check_colour = strtol(dbrow[col]+1,0,16);
|
||||
|
@ -1995,7 +2105,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|||
signal_check_colour,
|
||||
purpose,
|
||||
0,
|
||||
0
|
||||
0,
|
||||
doNativeMotDet
|
||||
);
|
||||
Zone **zones = 0;
|
||||
int n_zones = Zone::Load( monitors[i], zones );
|
||||
|
@ -2019,11 +2130,11 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
if ( !protocol )
|
||||
{
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) );
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Protocol, Method, Host, Port, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet from Monitors where Function != 'None' and Type = 'Remote' and Protocol = '%s' and Host = '%s' and Port = '%s' and Path = '%s'", protocol, host, port, path );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -2090,6 +2201,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|||
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
|
||||
int track_motion = atoi(dbrow[col]); col++;
|
||||
|
||||
int doNativeMotDet = atoi(dbrow[col]); col++;
|
||||
|
||||
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
|
||||
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
|
||||
|
@ -2168,8 +2280,8 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c
|
|||
RGB_WHITE,
|
||||
purpose,
|
||||
0,
|
||||
0
|
||||
|
||||
0,
|
||||
doNativeMotDet
|
||||
);
|
||||
Zone **zones = 0;
|
||||
int n_zones = Zone::Load( monitors[i], zones );
|
||||
|
@ -2192,11 +2304,11 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
if ( !file[0] )
|
||||
{
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) );
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet from Monitors where Function != 'None' and Type = 'File'", sizeof(sql) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet from Monitors where Function != 'None' and Type = 'File' and Path = '%s'", file );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -2259,6 +2371,8 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|||
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
|
||||
int track_motion = atoi(dbrow[col]); col++;
|
||||
|
||||
int doNativeMotDet = atoi(dbrow[col]); col++;
|
||||
|
||||
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
|
||||
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
|
||||
|
||||
|
@ -2305,7 +2419,8 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu
|
|||
RGB_WHITE,
|
||||
purpose,
|
||||
0,
|
||||
0
|
||||
0,
|
||||
doNativeMotDet
|
||||
);
|
||||
Zone **zones = 0;
|
||||
int n_zones = Zone::Load( monitors[i], zones );
|
||||
|
@ -2329,11 +2444,11 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
if ( !file[0] )
|
||||
{
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) );
|
||||
strncpy( sql, "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet from Monitors where Function != 'None' and Type = 'Ffmpeg'", sizeof(sql) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Enabled, LinkedMonitors, Path, Method, Options, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet from Monitors where Function != 'None' and Type = 'Ffmpeg' and Path = '%s'", file );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -2398,6 +2513,8 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|||
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
|
||||
int track_motion = atoi(dbrow[col]); col++;
|
||||
|
||||
int doNativeMotDet = atoi(dbrow[col]); col++;
|
||||
|
||||
int cam_width = ((orientation==ROTATE_90||orientation==ROTATE_270)?height:width);
|
||||
int cam_height = ((orientation==ROTATE_90||orientation==ROTATE_270)?width:height);
|
||||
|
||||
|
@ -2446,7 +2563,8 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|||
RGB_WHITE,
|
||||
purpose,
|
||||
0,
|
||||
0
|
||||
0,
|
||||
doNativeMotDet
|
||||
);
|
||||
Zone **zones = 0;
|
||||
int n_zones = Zone::Load( monitors[i], zones );
|
||||
|
@ -2468,7 +2586,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose
|
|||
Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
|
||||
{
|
||||
static char sql[ZM_SQL_MED_BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour from Monitors where Id = %d", id );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, DoNativeMotDet, SignalCheckColour from Monitors where Id = %d", id );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error( "Can't run query: %s", mysql_error( &dbconn ) );
|
||||
|
@ -2562,6 +2680,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|||
int alarm_ref_blend_perc = atoi(dbrow[col]); col++;
|
||||
int track_motion = atoi(dbrow[col]); col++;
|
||||
|
||||
int doNativeMotDet = atoi(dbrow[col]); col++;
|
||||
|
||||
int signal_check_colour;
|
||||
if ( dbrow[col][0] == '#' )
|
||||
signal_check_colour = strtol(dbrow[col]+1,0,16);
|
||||
|
@ -2759,8 +2879,8 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame );
|
|||
signal_check_colour,
|
||||
purpose,
|
||||
0,
|
||||
0
|
||||
|
||||
0,
|
||||
doNativeMotDet
|
||||
);
|
||||
|
||||
int n_zones = 0;
|
||||
|
|
|
@ -32,7 +32,10 @@
|
|||
#include "zm_camera.h"
|
||||
#include "zm_utils.h"
|
||||
|
||||
#if ZM_PLUGINS_ON
|
||||
#include "zm_plugin_manager.h"
|
||||
#include "zm_image_analyser.h"
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
|
@ -41,6 +44,9 @@
|
|||
#define MOTION_CAUSE "Motion"
|
||||
#define LINKED_CAUSE "Linked"
|
||||
|
||||
|
||||
int conf_select(const struct direct *entry);
|
||||
|
||||
//
|
||||
// This is the main class for monitors. Each monitor is associated
|
||||
// with a camera and is effectively a collector for events.
|
||||
|
@ -283,7 +289,12 @@ protected:
|
|||
int n_zones;
|
||||
Zone **zones;
|
||||
|
||||
int iDoNativeMotDet;
|
||||
int iDoNativeMotDet;
|
||||
#if ZM_PLUGINS_ON
|
||||
PluginManager ThePluginManager;
|
||||
#else
|
||||
int ThePluginManager;
|
||||
#endif
|
||||
|
||||
int n_linked_monitors;
|
||||
MonitorLink **linked_monitors;
|
||||
|
@ -291,7 +302,7 @@ protected:
|
|||
public:
|
||||
// OurCheckAlarms seems to be unused. Check it on zm_monitor.cpp for more info.
|
||||
//bool OurCheckAlarms( Zone *zone, const Image *pImage );
|
||||
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, const char *p_name, int p_function, bool p_enabled, const char *p_linked_monitors, Camera *p_camera, int p_orientation, unsigned int p_deinterlacing, const char *p_event_prefix, const char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_stream_replay_buffer, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_motion_frame_skip, int p_capture_delay, int p_alarm_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, int p_alarm_ref_blend_perc, bool p_track_motion, Rgb p_signal_check_colour, Purpose p_purpose, int p_n_zones=0, Zone *p_zones[]=0, int p_DoNativeMotDet=1 );
|
||||
~Monitor();
|
||||
|
||||
void AddZones( int p_n_zones, Zone *p_zones[] );
|
||||
|
|
Loading…
Reference in New Issue