X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=src%2FEngine.cpp;h=49a17daee4f7ec4963e4029f0552ee472203dbb4;hb=3811d034ba9e1f44a2e9915289438db3807217fe;hp=c044ab7ad5d9f615f8e1d1f265588a55426e833e;hpb=b3feccd1ee1186c37b39844dc566d39aedaa54ed;p=trackerpp.git diff --git a/src/Engine.cpp b/src/Engine.cpp index c044ab7..49a17da 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -8,40 +8,41 @@ using namespace suanzi; const static std::string TAG = "Engine"; static std::mutex g_mutex; -static Engine* g_instance = nullptr; +static EngineWPtr g_instance; -Engine::Engine() -{ - detector = new Detector(); - tracker = new Tracker(); -} -Engine* Engine::create() +EnginePtr Engine::create() { LOG_DEBUG(TAG, "create"); std::lock_guard lock(g_mutex); - if (g_instance) - return g_instance; - - Engine* instance (new Engine()); + if (g_instance.lock()){ + LOG_ERROR(TAG, "already exists"); + return EnginePtr(); // nullptr + } + EnginePtr instance (new Engine()); g_instance = instance; - return g_instance; + return instance; } -void Engine::destroy() +Engine::Engine() { - delete g_instance; + detector = std::make_shared(); + MetricsPtr m (new Metrics("model.pkl")); + multiTracker = std::make_shared(m); } Engine::~Engine() { - delete detector; - delete tracker; } +void Engine::destroy() +{ +} + + void Engine::setVideoSrc(VideoSrcType type, const std::string& url) { - videoSrc = url; +// videoSrc = url; reader = VideoReaderFactory::createVideoReader(type, url); } @@ -49,8 +50,12 @@ void Engine::run() { LOG_DEBUG(TAG, "run"); cv::Mat frame; + Detection detections[128]; while (reader->read(frame)){ - detector->detect(frame); + LOG_DEBUG(TAG, "Size: " << frame.cols << "x" << frame.rows); + // TODO + int total = detector->detect(frame, detections); + multiTracker->update(total, detections, frame); } }