Fix plugin output to event note

This commit is contained in:
Emmanuel Papin 2015-03-07 21:46:01 +01:00
parent 0988eaeb06
commit 7fd2f367c6
8 changed files with 27 additions and 29 deletions

View File

@ -88,13 +88,13 @@ void Detector::log(int nLogLevel, string sLevel, string sMessage)
/*! \fn int Detector::Detect(const Image &image, Event::StringSet &zoneSet) /*! \fn int Detector::Detect(const Image &zmImage, Zone** zones, unsigned int &score)
* \param zmImage is an image to detect faces on * \param zmImage is an image to detect faces on
* \param zoneSet is set of zone names (see zm_zone.h) * \param zones is the array of detection zones
* \param score is the detection score * \param score is the detection score
* \return true if detection is effective * \return true if detection is effective
*/ */
bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zoneSet, unsigned int &score) bool Detector::Detect(const Image &zmImage, Zone** zones, unsigned int &score)
{ {
bool alarm = false; bool alarm = false;
char szMessage[100]; char szMessage[100];
@ -116,7 +116,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone
{ {
alarm = true; alarm = true;
score += zone->Score(); score += zone->Score();
zoneSet.insert(zone->Text());
if (zone->IsPostProcEnabled()) if (zone->IsPostProcEnabled())
{ {
zone->StopPostProcessing(); zone->StopPostProcessing();
@ -149,7 +148,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone
{ {
alarm = true; alarm = true;
score += zone->Score(); score += zone->Score();
zoneSet.insert(zone->Text());
if (zone->IsPostProcEnabled()) if (zone->IsPostProcEnabled())
{ {
zone->StopPostProcessing(); zone->StopPostProcessing();
@ -180,7 +178,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone
{ {
alarm = true; alarm = true;
score += zone->Score(); score += zone->Score();
zoneSet.insert(zone->Text());
if (zone->IsPostProcEnabled()) if (zone->IsPostProcEnabled())
{ {
zone->StopPostProcessing(); zone->StopPostProcessing();
@ -211,7 +208,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone
{ {
alarm = true; alarm = true;
score += zone->Score(); score += zone->Score();
zoneSet.insert(zone->Text());
if (zone->IsPostProcEnabled()) if (zone->IsPostProcEnabled())
{ {
zone->StopPostProcessing(); zone->StopPostProcessing();
@ -235,12 +231,26 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone
void Detector::_onCreateEvent(Zone** zones, Event* event) void Detector::_onCreateEvent(Zone** zones, Event* event)
{ {
for(std::vector<unsigned int>::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it) for(std::vector<unsigned int>::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it)
{
onCreateEvent(zones[*it], *it, event); onCreateEvent(zones[*it], *it, event);
} }
}
void Detector::_onCloseEvent(Zone** zones, Event* event) void Detector::_onCloseEvent(Zone** zones, Event* event)
{ {
for(std::vector<unsigned int>::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it) for(std::vector<unsigned int>::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it)
onCloseEvent(zones[*it], *it, event); {
string noteText = "[Zone ";
noteText += zones[*it]->Label();
noteText += "]\n";
onCloseEvent(zones[*it], *it, event, noteText);
Event::StringSet noteSet;
noteSet.insert(noteText);
Event::StringSetMap noteSetMap;
noteSetMap[m_sDetectionCause] = noteSet;
event->updateNotes(noteSetMap);
}
} }

View File

@ -76,7 +76,7 @@ public:
Detector& operator=(const Detector& source); Detector& operator=(const Detector& source);
//! Detect (in an image later) //! Detect (in an image later)
bool Detect(const Image &image, Zone** zones, Event::StringSet &zoneSet, unsigned int &score); bool Detect(const Image &image, Zone** zones, unsigned int &score);
void _onCreateEvent(Zone** zones, Event *event); void _onCreateEvent(Zone** zones, Event *event);
void _onCloseEvent(Zone** zones, Event *event); void _onCloseEvent(Zone** zones, Event *event);
@ -102,7 +102,7 @@ protected:
virtual bool checkZone(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0; virtual bool checkZone(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0;
virtual void onCreateEvent(Zone *zone, unsigned int n_zone, Event *event) = 0; virtual void onCreateEvent(Zone *zone, unsigned int n_zone, Event *event) = 0;
virtual void onCloseEvent(Zone *zone, unsigned int n_zone, Event *event) = 0; virtual void onCloseEvent(Zone *zone, unsigned int n_zone, Event *event, string &noteText) = 0;
//! Log messages to the SYSLOG. //! Log messages to the SYSLOG.
void log(int, string sLevel, string sMessage); void log(int, string sLevel, string sMessage);

View File

@ -231,7 +231,7 @@ void Event::Close()
{ {
if ( ( tot_score == 0 ) && ( alarm_frames == 0 ) ) if ( ( tot_score == 0 ) && ( alarm_frames == 0 ) )
{ {
Info( "Event is empty: Delete data" ); Info( "Delete event's data (empty event)" );
DeleteData(); DeleteData();
} }
} }

View File

@ -79,7 +79,7 @@ bool ImageAnalyser::DoDetection(const Image &comp_image, Zone** zones, Event::St
++It ) ++It )
{ {
unsigned int detect_score = 0; unsigned int detect_score = 0;
if ( (*It)->Detect( comp_image, zones, zoneSet, detect_score ) ) if ( (*It)->Detect( comp_image, zones, detect_score ) )
{ {
alarm = true; alarm = true;
score += detect_score; score += detect_score;

View File

@ -3376,11 +3376,11 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z
{ {
alarm = true; alarm = true;
score += zone->Score(); score += zone->Score();
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
if ( !zone->IsPostProcEnabled() ) if ( !zone->IsPostProcEnabled() )
{ {
zone->SetAlarm(); zone->SetAlarm();
Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() );
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
} }
//zone->ResetStats(); //zone->ResetStats();
} else { } else {
@ -3424,10 +3424,10 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z
alarm = true; alarm = true;
zone->SetAlarm(); zone->SetAlarm();
score += zone->Score(); score += zone->Score();
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
if ( !zone->IsPostProcEnabled() ) if ( !zone->IsPostProcEnabled() )
{ {
Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() );
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
if ( config.opt_control && track_motion ) if ( config.opt_control && track_motion )
{ {
if ( (int)zone->Score() > top_score ) if ( (int)zone->Score() > top_score )
@ -3454,10 +3454,10 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z
alarm = true; alarm = true;
zone->SetAlarm(); zone->SetAlarm();
score += zone->Score(); score += zone->Score();
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
if ( !zone->IsPostProcEnabled() ) if ( !zone->IsPostProcEnabled() )
{ {
Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() );
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
if ( config.opt_control && track_motion ) if ( config.opt_control && track_motion )
{ {
if ( zone->Score() > (unsigned int)top_score ) if ( zone->Score() > (unsigned int)top_score )
@ -3486,10 +3486,10 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z
alarm = true; alarm = true;
zone->SetAlarm(); zone->SetAlarm();
score += zone->Score(); score += zone->Score();
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
if ( !zone->IsPostProcEnabled() ) if ( !zone->IsPostProcEnabled() )
{ {
Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() );
zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() );
} }
} }
} }

View File

@ -60,7 +60,6 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_
max_blob_size = 0; max_blob_size = 0;
image = 0; image = 0;
score = 0; score = 0;
text = "";
post_proc_enabled = false; post_proc_enabled = false;
post_proc_in_progress = false; post_proc_in_progress = false;
include_nat_det = true; include_nat_det = true;
@ -148,13 +147,6 @@ void Zone::SetScore(unsigned int nScore)
score = nScore; score = nScore;
} }
void Zone::SetText(std::string sText)
{
text = "[Zone ";
text += label;
text += "]\n" + sText;
}
void Zone::AssignRefImage( unsigned int p_width, unsigned int p_height, unsigned int p_colours, unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size ) void Zone::AssignRefImage( unsigned int p_width, unsigned int p_height, unsigned int p_colours, unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size )
{ {
ref_image.Assign( p_width, p_height, p_colours, p_subpixelorder, new_buffer, buffer_size); ref_image.Assign( p_width, p_height, p_colours, p_subpixelorder, new_buffer, buffer_size);

View File

@ -100,7 +100,6 @@ protected:
Box alarm_box; Box alarm_box;
Coord alarm_centre; Coord alarm_centre;
unsigned int score; unsigned int score;
std::string text;
Image *pg_image; Image *pg_image;
Range *ranges; Range *ranges;
Image *image; Image *image;
@ -151,7 +150,6 @@ public:
inline void ClearAlarm() { alarmed = false; } inline void ClearAlarm() { alarmed = false; }
inline Coord GetAlarmCentre() const { return( alarm_centre ); } inline Coord GetAlarmCentre() const { return( alarm_centre ); }
inline unsigned int Score() const { return( score ); } inline unsigned int Score() const { return( score ); }
inline std::string Text() const { return( text ); }
void SetConfig( zConf zone_conf ); void SetConfig( zConf zone_conf );
inline bool IsPostProcEnabled() const { return post_proc_enabled; } inline bool IsPostProcEnabled() const { return post_proc_enabled; }
inline bool IsNatDetIncluded() const { return include_nat_det; } inline bool IsNatDetIncluded() const { return include_nat_det; }
@ -170,7 +168,6 @@ public:
min_blob_size = 0; min_blob_size = 0;
max_blob_size = 0; max_blob_size = 0;
score = 0; score = 0;
text = "";
} }
void RecordStats( const Event *event ); void RecordStats( const Event *event );
bool CheckAlarms( const Image *comp_image ); bool CheckAlarms( const Image *comp_image );
@ -190,7 +187,6 @@ public:
void SetExtendAlarmCount(int nOverCount); void SetExtendAlarmCount(int nOverCount);
int GetExtendAlarmFrames(); int GetExtendAlarmFrames();
void SetScore(unsigned int nScore); void SetScore(unsigned int nScore);
void SetText(std::string sText);
void SetAlarmImage(const Image* srcImage); void SetAlarmImage(const Image* srcImage);
void AssignRefImage( unsigned int p_width, unsigned int p_height, unsigned int p_colours, unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size ); void AssignRefImage( unsigned int p_width, unsigned int p_height, unsigned int p_colours, unsigned int p_subpixelorder, const uint8_t* new_buffer, const size_t buffer_size );
void SetRefImage( const Image &srcImage); void SetRefImage( const Image &srcImage);