diff --git a/src/zm_detector.cpp b/src/zm_detector.cpp index 05450a767..ca460131d 100644 --- a/src/zm_detector.cpp +++ b/src/zm_detector.cpp @@ -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 zoneSet is set of zone names (see zm_zone.h) + * \param zones is the array of detection zones * \param score is the detection score * \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; char szMessage[100]; @@ -116,7 +116,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone { alarm = true; score += zone->Score(); - zoneSet.insert(zone->Text()); if (zone->IsPostProcEnabled()) { zone->StopPostProcessing(); @@ -149,7 +148,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone { alarm = true; score += zone->Score(); - zoneSet.insert(zone->Text()); if (zone->IsPostProcEnabled()) { zone->StopPostProcessing(); @@ -180,7 +178,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone { alarm = true; score += zone->Score(); - zoneSet.insert(zone->Text()); if (zone->IsPostProcEnabled()) { zone->StopPostProcessing(); @@ -211,7 +208,6 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone { alarm = true; score += zone->Score(); - zoneSet.insert(zone->Text()); if (zone->IsPostProcEnabled()) { zone->StopPostProcessing(); @@ -235,12 +231,26 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone void Detector::_onCreateEvent(Zone** zones, Event* event) { for(std::vector::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it) + { onCreateEvent(zones[*it], *it, event); + } } void Detector::_onCloseEvent(Zone** zones, Event* event) { for(std::vector::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); + } } diff --git a/src/zm_detector.h b/src/zm_detector.h index 9867470fc..a1b1683be 100644 --- a/src/zm_detector.h +++ b/src/zm_detector.h @@ -76,7 +76,7 @@ public: Detector& operator=(const Detector& source); //! 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 _onCloseEvent(Zone** zones, Event *event); @@ -102,7 +102,7 @@ protected: 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 onCloseEvent(Zone *zone, unsigned int n_zone, Event *event) = 0; + virtual void onCloseEvent(Zone *zone, unsigned int n_zone, Event *event, string ¬eText) = 0; //! Log messages to the SYSLOG. void log(int, string sLevel, string sMessage); diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 459fb7f1c..72d685cac 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -231,7 +231,7 @@ void Event::Close() { if ( ( tot_score == 0 ) && ( alarm_frames == 0 ) ) { - Info( "Event is empty: Delete data" ); + Info( "Delete event's data (empty event)" ); DeleteData(); } } diff --git a/src/zm_event.h b/src/zm_event.h index ec31cae72..b06da823b 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -128,7 +128,7 @@ public: bool SendFrameImage( const Image *image, bool alarm_frame=false ); bool WriteFrameImage( Image *image, struct timeval timestamp, const char *event_file, bool alarm_frame=false ); - void updateNotes( const StringSetMap &stringSetMap ); + void updateNotes( const StringSetMap &stringSetMap ); void AddFrames( int n_frames, Image **images, struct timeval **timestamps ); void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL ); diff --git a/src/zm_image_analyser.cpp b/src/zm_image_analyser.cpp index 8feaecf1c..0e25e7e82 100644 --- a/src/zm_image_analyser.cpp +++ b/src/zm_image_analyser.cpp @@ -79,7 +79,7 @@ bool ImageAnalyser::DoDetection(const Image &comp_image, Zone** zones, Event::St ++It ) { unsigned int detect_score = 0; - if ( (*It)->Detect( comp_image, zones, zoneSet, detect_score ) ) + if ( (*It)->Detect( comp_image, zones, detect_score ) ) { alarm = true; score += detect_score; diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 2646c917a..b6184a167 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3376,11 +3376,11 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z { alarm = true; score += zone->Score(); + zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() ); if ( !zone->IsPostProcEnabled() ) { zone->SetAlarm(); Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); - zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() ); } //zone->ResetStats(); } else { @@ -3424,10 +3424,10 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z alarm = true; zone->SetAlarm(); score += zone->Score(); + zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() ); if ( !zone->IsPostProcEnabled() ) { 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 ( (int)zone->Score() > top_score ) @@ -3454,10 +3454,10 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z alarm = true; zone->SetAlarm(); score += zone->Score(); + zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() ); if ( !zone->IsPostProcEnabled() ) { 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 ( zone->Score() > (unsigned int)top_score ) @@ -3486,10 +3486,10 @@ unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &z alarm = true; zone->SetAlarm(); score += zone->Score(); + zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() ); if ( !zone->IsPostProcEnabled() ) { Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); - zoneSet.insert( ("[Zone " + std::string(zone->Label()) + "]\n").c_str() ); } } } diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 4e37147b7..5303eda18 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -60,7 +60,6 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_ max_blob_size = 0; image = 0; score = 0; - text = ""; post_proc_enabled = false; post_proc_in_progress = false; include_nat_det = true; @@ -148,13 +147,6 @@ void Zone::SetScore(unsigned int 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 ) { ref_image.Assign( p_width, p_height, p_colours, p_subpixelorder, new_buffer, buffer_size); diff --git a/src/zm_zone.h b/src/zm_zone.h index 6e9267b1c..fc6ddcd2c 100644 --- a/src/zm_zone.h +++ b/src/zm_zone.h @@ -100,7 +100,6 @@ protected: Box alarm_box; Coord alarm_centre; unsigned int score; - std::string text; Image *pg_image; Range *ranges; Image *image; @@ -151,7 +150,6 @@ public: inline void ClearAlarm() { alarmed = false; } inline Coord GetAlarmCentre() const { return( alarm_centre ); } inline unsigned int Score() const { return( score ); } - inline std::string Text() const { return( text ); } void SetConfig( zConf zone_conf ); inline bool IsPostProcEnabled() const { return post_proc_enabled; } inline bool IsNatDetIncluded() const { return include_nat_det; } @@ -170,7 +168,6 @@ public: min_blob_size = 0; max_blob_size = 0; score = 0; - text = ""; } void RecordStats( const Event *event ); bool CheckAlarms( const Image *comp_image ); @@ -190,7 +187,6 @@ public: void SetExtendAlarmCount(int nOverCount); int GetExtendAlarmFrames(); void SetScore(unsigned int nScore); - void SetText(std::string sText); 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 SetRefImage( const Image &srcImage);