From 70a062a6099096e263c95d7ac9bd3735fae5d48d Mon Sep 17 00:00:00 2001 From: Emmanuel Papin Date: Sat, 17 Jan 2015 18:30:24 +0100 Subject: [PATCH] Remove image argument in new functions --- src/zm_detector.cpp | 8 ++++---- src/zm_detector.h | 10 ++++------ src/zm_image_analyser.cpp | 10 +++++----- src/zm_image_analyser.h | 4 ++-- src/zm_monitor.cpp | 11 +++++++++-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/zm_detector.cpp b/src/zm_detector.cpp index 3cc343bf3..dc2ee81bc 100644 --- a/src/zm_detector.cpp +++ b/src/zm_detector.cpp @@ -232,15 +232,15 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone } -void Detector::_onCreateEvent(const Image &zmImage, Zone** zones) +void Detector::_onCreateEvent(Zone** zones, Event* event) { for(std::vector::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it) - onCreateEvent(zones[*it], *it, const Image *zmImage); + onCreateEvent(zones[*it], *it, Event* event); } -void Detector::_onCloseEvent(const Image &zmImage, Zone** zones) +void Detector::_onCloseEvent(Zone** zones, Event* event) { for(std::vector::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it) - onCloseEvent(zones[*it], *it, const Image *zmImage); + onCloseEvent(zones[*it], *it, Event* event); } diff --git a/src/zm_detector.h b/src/zm_detector.h index 727bcb84f..9867470fc 100644 --- a/src/zm_detector.h +++ b/src/zm_detector.h @@ -78,9 +78,8 @@ public: //! Detect (in an image later) bool Detect(const Image &image, Zone** zones, Event::StringSet &zoneSet, unsigned int &score); - - void _onCreateEvent(const Image &zmImage, Zone** zones); - void _onCloseEvent(const Image &zmImage, Zone** zones); + void _onCreateEvent(Zone** zones, Event *event); + void _onCloseEvent(Zone** zones, Event *event); //! Load detector's parameters. virtual int loadConfig(string sConfigFileName, map > mapPluginConf) = 0; @@ -102,9 +101,8 @@ protected: //! Do detection inside one given zone. virtual bool checkZone(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0; - - virtual void onCreateEvent(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0; - virtual void onCloseEvent(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; //! Log messages to the SYSLOG. void log(int, string sLevel, string sMessage); diff --git a/src/zm_image_analyser.cpp b/src/zm_image_analyser.cpp index 0fa4f95de..52414f6fd 100644 --- a/src/zm_image_analyser.cpp +++ b/src/zm_image_analyser.cpp @@ -41,24 +41,24 @@ ImageAnalyser::~ImageAnalyser() delete *It; } -void ImageAnalyser::onCreateEvent(const Image &comp_image, Zone** zones, Event* event) +void ImageAnalyser::onCreateEvent(Zone** zones, Event* event) { for ( DetectorsList::iterator It = m_Detectors.begin(); It != m_Detectors.end(); ++It ) { - (*It)->_onCreateEvent(const comp_image, zones, event); + (*It)->_onCreateEvent(zones, event); } } -void ImageAnalyser::onCloseEvent(const Image &comp_image, Zone** zones, Event* event) +void ImageAnalyser::onCloseEvent(Zone** zones, Event* event) { for ( DetectorsList::iterator It = m_Detectors.begin(); It != m_Detectors.end(); ++It ) { - (*It)->_onCloseEvent(const comp_image, zones, event); - } } + (*It)->_onCloseEvent(zones, event); + } } /*!\fn ImageAnalyser::DoDetection(const Image &comp_image, Zone** zones, Event::StringSetMap noteSetMap, string& det_cause) diff --git a/src/zm_image_analyser.h b/src/zm_image_analyser.h index 9b5060d48..c25c1f6c5 100644 --- a/src/zm_image_analyser.h +++ b/src/zm_image_analyser.h @@ -75,8 +75,8 @@ class ImageAnalyser { m_Detectors.push_back(Det.release()); } - void onCreateEvent(const Image &comp_image, Zone** zones); - void onCloseEvent(const Image &comp_image, Zone** zones); + void onCreateEvent(Zone** zones, Event* event); + void onCloseEvent(Zone** zones, Event* event); //! Do detection in an image by calling all available detectors. bool DoDetection(const Image &comp_image, Zone** zones, Event::StringSetMap& noteSetMap, std::string& det_cause, unsigned int& score); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index fc6bb3e15..95a6b6acd 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1522,7 +1522,7 @@ bool Monitor::Analyse() shared_data->last_event = event->Id(); #if ZM_PLUGINS_ON if (config.load_plugins) - ThePluginManager.getImageAnalyser().onCreateEvent( *snap_image, zones, event ); + ThePluginManager.getImageAnalyser().onCreateEvent( zones, event ); #endif // ZM_PLUGINS_ON Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() ); @@ -1581,7 +1581,10 @@ bool Monitor::Analyse() } event = new Event( this, *(image_buffer[pre_index].timestamp), cause, noteSetMap ); shared_data->last_event = event->Id(); - +#if ZM_PLUGINS_ON + if (config.load_plugins) + ThePluginManager.getImageAnalyser().onCreateEvent( zones, event ); +#endif // ZM_PLUGINS_ON Info( "%s: %03d - Opening new event %d, alarm start", name, image_count, event->Id() ); if ( pre_event_images ) @@ -3117,6 +3120,10 @@ bool Monitor::closeEvent() { gettimeofday( &(event->EndTime()), NULL ); } + else ( function == ANALYSIS && config.load_plugins ) + { + ThePluginManager.getImageAnalyser().onCloseEvent( zones, event ); + } delete event; event = 0; return( true );