Fix nan issue in features
[trackerpp.git] / include / Engine.h
index 5405539..8443e19 100644 (file)
@@ -9,12 +9,16 @@
 #include "MultiTracker.h"
 #include "VideoReader.h"
 #include "SharedPtr.h"
+#include "WorkerThread.h"
 
 namespace suanzi{
 
 class EngineObserver;
 
 TK_DECLARE_PTR(Engine);
+TK_DECLARE_PTR(MultiTracker);
+
+struct Person;
 
 class Engine
 {
@@ -24,16 +28,26 @@ public:
     virtual ~Engine();
 
     virtual void start();
+    //virtual void getCurrentCount();
+    // virtual void capture(bool bb = false);
     void addObserver(EngineObserver* o);
     void setVideoSrc(VideoSrcType type, const std::string& url);
+    // stream the video source as http, return the url
+    std::string setPreview(bool isPreview, bool showBB = false){return "";} 
+
+protected:
+    friend class MultiTracker;
+    void onPersonsIn(const std::vector<Person>& p);
+    void onPersonsOut(const std::vector<Person>& p);
 
 private:
     Engine();
     void run();
+    WorkerThread eventThread {"EventThread"};
+    WorkerThread writeImgThread {"WriteImgThread"};
     DetectorPtr detector;
     MultiTrackerPtr multiTracker;
     std::set<EngineObserver *> observer_list;
-    //std::string videoSrc;
     VideoReaderPtr reader;
 };
 
@@ -58,7 +72,7 @@ struct Person
     Gender gender = Female;
     Ages age = Kid;
 
-    std::string ageToString (Ages age){
+    std::string ageToString (Ages age) const {
         switch (age){
         case Kid: return "Kid";
         case Teenager: return "Teenager";
@@ -66,7 +80,7 @@ struct Person
         }
     }
 
-    std::string toString(){
+    std::string toString() const {
         std::stringstream ss;
         ss << "Person: id=" << id << ". Gender:" << (gender == Gender::Male ? "Male" : "Female" ) <<
             ". Age: " << ageToString(age);
@@ -77,9 +91,8 @@ struct Person
 class EngineObserver
 {
 public:
-    //virtual void onPersonIn(std::set<Person> persons) = 0;
-    virtual void onPersonIn(Person& p) = 0;
-    virtual void onPersonOut(Person& p) = 0;
+    virtual void onPersonsIn(const std::vector<Person>& p) = 0;
+    virtual void onPersonsOut(const std::vector<Person>& p) = 0;
 };
 
 } // namespace suanzi