53 lines
2.3 KiB
C++
53 lines
2.3 KiB
C++
#ifndef MOVENET_H
|
|
#define MOVENET_H
|
|
#pragma once
|
|
#include <string.h>
|
|
#include <vector>
|
|
#include <iostream>
|
|
#include <typeinfo>
|
|
#include "ANSEngineCommon.h"
|
|
#include "engine.h"
|
|
#include "ONNXEngine.h"
|
|
//#define FACEDEBUG
|
|
|
|
namespace ANSCENTER {
|
|
class ANSENGINE_API ANSMOVIENET :public ANSODBase {
|
|
public:
|
|
virtual bool Initialize(std::string licenseKey, ModelConfig modelConfig, const std::string& modelZipFilePath, const std::string& modelZipPassword, std::string& labelMap) override;
|
|
virtual bool LoadModel(const std::string& modelZipFilePath, const std::string& modelZipPassword)override;
|
|
virtual bool LoadModelFromFolder(std::string licenseKey, ModelConfig modelConfig, std::string modelName, std::string className, const std::string& modelFolder, std::string& labelMap)override;
|
|
bool OptimizeModel(bool fp16, std::string& optimizedModelFolder);
|
|
std::vector<Object> RunInference(const cv::Mat& input);
|
|
std::vector<Object> RunInference(const cv::Mat& input, const std::string& camera_id);
|
|
bool Destroy();
|
|
~ANSMOVIENET();
|
|
private:
|
|
std::string _modelFilePath;
|
|
std::unique_ptr<MOVINET> _movienet_detector = nullptr;
|
|
static constexpr int TEMPORAL_LENGTH = 16;
|
|
|
|
// ----- Per-camera queue state -----
|
|
struct CameraQueueState {
|
|
std::deque<cv::Mat> frames;
|
|
int frameCount = 0; // total frames received (for stride calc)
|
|
int lastAccessFrame = 0; // global frame when last accessed (for staleness)
|
|
};
|
|
std::unordered_map<std::string, CameraQueueState> _cameraQueues;
|
|
|
|
// ----- Inference stride -----
|
|
int _inferenceStride = TEMPORAL_LENGTH; // non-overlapping by default
|
|
|
|
// ----- Global frame counter for staleness tracking -----
|
|
int _globalFrameCounter = 0;
|
|
|
|
// ----- Cleanup config -----
|
|
static constexpr int STALE_THRESHOLD = 100; // frames without access → stale
|
|
static constexpr int CLEANUP_INTERVAL = 50; // run cleanup every N frames
|
|
static constexpr int MAX_QUEUES = 200; // hard cap on total queues
|
|
|
|
// ----- Internal methods -----
|
|
std::vector<Object> Inference(const cv::Mat& input, const std::string& camera_id);
|
|
void CleanupStaleQueues();
|
|
};
|
|
}
|
|
#endif |