提交 f8eaed34 authored 作者: blu's avatar blu

evmlmotion: area configure

上级 0d4722f2
...@@ -31,6 +31,7 @@ using namespace zmqhelper; ...@@ -31,6 +31,7 @@ using namespace zmqhelper;
#define URLOUT_DEFAULT "frames" #define URLOUT_DEFAULT "frames"
#define NUM_PKT_IGNORE 18*5 #define NUM_PKT_IGNORE 18*5
#define FRAME_SIZE 500 #define FRAME_SIZE 500
#define AREA_1080P 200
#define DEBUG #define DEBUG
...@@ -70,7 +71,7 @@ private: ...@@ -70,7 +71,7 @@ private:
int iid; int iid;
AVFormatContext *pAVFormatInput = nullptr; AVFormatContext *pAVFormatInput = nullptr;
AVCodecContext *pCodecCtx = nullptr; AVCodecContext *pCodecCtx = nullptr;
DetectParam detPara = {25, 500, -1, 3, 3, 30, 0.3, 25, 0, 540, {{0,0},{0,0}}}; DetectParam detPara = {25, 0, -1, 3, 3, 30, 0.3, 25, 0, 540, {{0,0},{0,0}}};
EventState evtState = EventState::NONE; EventState evtState = EventState::NONE;
// chrono::system_clock::time_point packetTm, evtStartTmLast, evtStartTmOrig; // chrono::system_clock::time_point packetTm, evtStartTmLast, evtStartTmOrig;
long long packetTm = 0, evtStartTmLast = 0, evtStartTmOrig = 0, evtStartTmPre = 0; long long packetTm = 0, evtStartTmLast = 0, evtStartTmOrig = 0, evtStartTmPre = 0;
...@@ -275,8 +276,8 @@ private: ...@@ -275,8 +276,8 @@ private:
detPara.thre = evmlmotion["thresh"]; detPara.thre = evmlmotion["thresh"];
} }
if(evmlmotion.count("area") == 0||evmlmotion["area"] < 10 ||evmlmotion["area"] >= int(FRAME_SIZE*FRAME_SIZE)*9/10) { if(evmlmotion.count("area") == 0||evmlmotion["area"] < 5 ||evmlmotion["area"] >= int(FRAME_SIZE*FRAME_SIZE)*9/10) {
spdlog::info("{} invalid area value. should be in (10, 500*500*9/10), default to {}", selfId, detPara.area); spdlog::info("{} invalid area value. should be in (10, 500*500*9/10), default to {}, {}", selfId, detPara.area, AREA_1080P);
} }
else { else {
detPara.area = evmlmotion["area"]; detPara.area = evmlmotion["area"];
...@@ -607,6 +608,7 @@ private: ...@@ -607,6 +608,7 @@ private:
static bool first = true; static bool first = true;
static cv::Mat avg; static cv::Mat avg;
static double _area = 0; static double _area = 0;
static double area = 0;
static int frameProcessed = 0; static int frameProcessed = 0;
vector<vector<cv::Point> > cnts; vector<vector<cv::Point> > cnts;
cv::Mat origin; cv::Mat origin;
...@@ -618,6 +620,8 @@ private: ...@@ -618,6 +620,8 @@ private:
// auto config // auto config
if(detPara.resize == 0) { if(detPara.resize == 0) {
detPara.resize = detPara.size*1.0/h; detPara.resize = detPara.size*1.0/h;
}else{
detPara.size = int(h * detPara.resize);
} }
if(detPara.resize > 0 && detPara.resize < 1){ if(detPara.resize > 0 && detPara.resize < 1){
...@@ -650,7 +654,8 @@ private: ...@@ -650,7 +654,8 @@ private:
avg.release(); avg.release();
avg = gray.clone(); avg = gray.clone();
first = false; first = false;
spdlog::info("{} resize: {}, area: {}, origin area: {}", selfId, detPara.resize, detPara.area * detPara.resize * detPara.resize, detPara.area); area = detPara.area == 0 ? (AREA_1080P * detPara.size * 1.0/1080) : detPara.area;
spdlog::info("{} resize: {}, area: {}, origin area: {}", selfId, detPara.resize, area, detPara.area);
return; return;
} }
...@@ -680,7 +685,6 @@ private: ...@@ -680,7 +685,6 @@ private:
bool hasEvent = false; bool hasEvent = false;
static int evtCnt = 0; static int evtCnt = 0;
int i = 0; int i = 0;
static double area = (double)(detPara.area * detPara.resize * detPara.resize);
// avoid vage cases // avoid vage cases
if(area < 5) { if(area < 5) {
area = 5; area = 5;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论