Add unit testes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "ANSLIB.h"
|
||||
#include <deque>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
#define RETAINFRAMES 80
|
||||
#define FILTERFRAMES 10
|
||||
@@ -13,6 +14,22 @@ class CUSTOM_API ANSCustomFS : public IANSCustomClass
|
||||
int priority;
|
||||
ImageSection(const cv::Rect& r) : region(r), priority(0) {}
|
||||
};
|
||||
|
||||
// Track record for voting-based detection confirmation
|
||||
struct TrackRecord {
|
||||
int trackId{ 0 };
|
||||
int classId{ 0 }; // fire=0, smoke=2
|
||||
std::deque<cv::Rect> bboxHistory; // bounding box history within window
|
||||
int detectedCount{ 0 }; // frames detected in sliding window
|
||||
int totalFrames{ 0 }; // total frames since track appeared
|
||||
bool confirmed{ false }; // passed voting threshold
|
||||
};
|
||||
|
||||
// Voting mechanism constants
|
||||
static constexpr int VOTE_WINDOW = 15;
|
||||
static constexpr int VOTE_THRESHOLD = 8;
|
||||
static constexpr float BBOX_CHANGE_THRESHOLD = 0.05f;
|
||||
|
||||
private:
|
||||
using ANSLIBPtr = std::unique_ptr<ANSCENTER::ANSLIB, decltype(&ANSCENTER::ANSLIB::Destroy)>;
|
||||
|
||||
@@ -74,6 +91,9 @@ private:
|
||||
float _smokeDetetectionThreshold{ 0 };
|
||||
float _motionSpecificity{ 0 };
|
||||
|
||||
// Tracker-based voting state
|
||||
std::unordered_map<int, TrackRecord> _trackHistory;
|
||||
|
||||
cv::Rect GenerateMinimumSquareBoundingBox(const std::vector<ANSCENTER::Object>& detectedObjects, int minSize = 640);
|
||||
void UpdateNoDetectionCondition();
|
||||
bool detectStaticFire(std::deque<cv::Mat>& frameQueue);
|
||||
@@ -101,7 +121,6 @@ private:
|
||||
void ResetDetectionState();
|
||||
void GetModelParameters();
|
||||
std::vector<ANSCENTER::Object> ProcessExistingDetectedArea(const cv::Mat& frame, const std::string& camera_id, cv::Mat& draw);
|
||||
bool ProcessValidDetection(const cv::Mat& frame, const std::string& camera_id, cv::Mat& draw, ANSCENTER::Object& detectedObj, std::vector<ANSCENTER::Object>& output);
|
||||
void AddConfirmedDetection(ANSCENTER::Object& detectedObj, std::vector<ANSCENTER::Object>& output);
|
||||
#ifdef FNS_DEBUG
|
||||
void DisplayDebugFrame(cv::Mat& draw) {
|
||||
@@ -117,21 +136,11 @@ private:
|
||||
int getLowestPriorityRegion();
|
||||
cv::Rect getRegionByPriority(int priority);
|
||||
|
||||
std::vector<ANSCENTER::Object> ProcessExistingDetectedArea(
|
||||
const cv::Mat& frame,
|
||||
const std::string& camera_id,
|
||||
const std::vector<cv::Rect>& fireNSmokeRects, cv::Mat& draw);
|
||||
bool ProcessDetectedObject(
|
||||
const cv::Mat& frame,
|
||||
ANSCENTER::Object& detectedObj,
|
||||
const std::string& camera_id,
|
||||
const std::vector<cv::Rect>& fireNSmokeRects,
|
||||
std::vector<ANSCENTER::Object>& output, cv::Mat& draw);
|
||||
bool ValidateWithFilter(
|
||||
const cv::Mat& frame,
|
||||
const ANSCENTER::Object& detectedObj,
|
||||
const std::string& camera_id,
|
||||
std::vector<ANSCENTER::Object>& output, cv::Mat& draw);
|
||||
// Tracker-based voting methods
|
||||
void UpdateTrackHistory(int trackId, int classId, const cv::Rect& bbox);
|
||||
bool IsTrackConfirmed(int trackId) const;
|
||||
bool HasBboxMovement(int trackId) const;
|
||||
void AgeTracks(const std::unordered_set<int>& detectedTrackIds);
|
||||
std::vector<ANSCENTER::Object> FindNewDetectedArea(
|
||||
const cv::Mat& frame,
|
||||
const std::string& camera_id, cv::Mat& draw);
|
||||
|
||||
Reference in New Issue
Block a user