提交 7becf796 authored 作者: blu's avatar blu

motion detect: new alg revise

上级 9393c9f1
......@@ -682,33 +682,46 @@ private:
evtStartTmLast = packetTm;
return;
}
static long long pktDelt = 0;
if(pktCnt %18 == 0){
auto tmp = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
pktDelt = tmp - packetTm;
}
switch(evtState) {
case NONE:
case PRE:
if(dura >= detPara.pre) {
auto thr = frameProcessed/2;
if(evtCnt <= thr) {
if(evtState == PRE) {
spdlog::info("{} state: PRE->NONE ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
evtState = NONE;
evtStartTmOrig = packetTm - detPara.pre;
}else{
spdlog::info("state: NONE->NONE ({}, {}, {}, {}, {}, {})", this->fps, dura, frameProcessed, evtCnt, thr, _area);
}
// if(evtState == PRE) {
// spdlog::info("{} state: PRE->NONE ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
// evtState = NONE;
// evtStartTmOrig = packetTm - detPara.pre;
// }else{
// spdlog::info("state: NONE->NONE ({}, {}, {}, {}, {}, {})", this->fps, dura, frameProcessed, evtCnt, thr, _area);
// }
spdlog::info("state: NONE->NONE ({}, {}, {}, {}, {}, {}, {})", pktDelt, this->fps, dura, frameProcessed, evtCnt, thr, _area);
}else{
if(evtState == PRE) {
// if(evtState == PRE) {
// json p;
// evtState = IN;
// spdlog::info("{} state: PRE->IN ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
// makeEvent(EV_MSG_EVENT_MOTION_START, evtStartTmOrig);
// auto tmp = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
// packetTsDelta = tmp - packetTm;
// spdlog::info("{} packet ts delta: {}", selfId, packetTsDelta);
// }else{
// evtState = PRE;
// spdlog::info("{} state: NONE->PRE ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
// evtStartTmOrig = packetTm;
// }
json p;
evtState = IN;
spdlog::info("{} state: PRE->IN ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
evtStartTmOrig = packetTm - detPara.pre;
spdlog::info("{} state: NONE->IN ({}, {}, {}, {}, {}, {}, {})", selfId, pktDelt, this->fps, dura, frameProcessed, evtCnt, thr, _area);
makeEvent(EV_MSG_EVENT_MOTION_START, evtStartTmOrig);
auto tmp = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
packetTsDelta = tmp - packetTm;
spdlog::info("{} packet ts delta: {}", selfId, packetTsDelta);
}else{
evtState = PRE;
spdlog::info("{} state: NONE->PRE ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
evtStartTmOrig = packetTm;
}
}
evtCnt = 0;
frameProcessed = 0;
......@@ -729,9 +742,9 @@ private:
auto thr = frameProcessed/5;
if(evtCnt <= thr){
evtState = POST;
spdlog::info("{} state: IN->POST ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
spdlog::info("{} state: IN->POST ({}, {}, {}, {}, {}, {}, {})", selfId, pktDelt, this->fps, dura, frameProcessed, evtCnt, thr, _area);
}else{
spdlog::info("{} state: IN->IN ({}, {}, {}, {}, {}, {})", selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
spdlog::info("{} state: IN->IN ({}, {}, {}, {}, {}, {}, {})", selfId, pktDelt, this->fps, dura, frameProcessed, evtCnt, thr, _area);
}
evtCnt = 0;
frameProcessed = 0;
......@@ -743,11 +756,11 @@ private:
if(dura >= detPara.post/2){
auto thr = frameProcessed/5;
if(evtCnt <= thr){
spdlog::info("{} state: POST->NONE ({}, {}, {}, {}, {}, {})",selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
spdlog::info("{} state: POST->NONE ({}, {}, {}, {}, {}, {}, {})",selfId, pktDelt, this->fps, dura, frameProcessed, evtCnt, thr, _area);
evtState = NONE;
makeEvent(EV_MSG_EVENT_MOTION_END, packetTs - detPara.post/2);
}else{
spdlog::info("{} state: POST->IN ({}, {}, {}, {}, {}, {})",selfId, this->fps, dura, frameProcessed, evtCnt, thr, _area);
spdlog::info("{} state: POST->IN ({}, {}, {}, {}, {}, {}, {})",selfId, pktDelt, this->fps, dura, frameProcessed, evtCnt, thr, _area);
evtState = IN;
}
evtCnt = 0;
......
......@@ -840,7 +840,7 @@ protected:
}
// find video files
vector<string> findSlicesByRange(long tss, long tse, int offsetS, int offsetE)
vector<string> findSlicesByRange(long tss, long tse, long & offsetS, long &offsetE)
{
vector<string> ret;
......@@ -883,6 +883,7 @@ protected:
if(found == 1) {
string sf;
auto itr = tmp.begin();
offsetS = tss - *itr;
for(; itr != tmp.end(); itr++) {
string fname = videoFileTs2Name(*itr, true);
sf += "\n\t" + this->urlOut + "/" + fname + ".mp4, " + to_string(*itr);
......@@ -1070,8 +1071,8 @@ public:
params["startTime"] = to_string(tss);
params["endTime"] = to_string(tse);
params["cameraId"] = ipcSn;
params["headOffset"] = to_string(offsetS);
params["tailOffset"] = to_string(offsetE);
params["headOffset"] = "0";//to_string(offsetS);
params["tailOffset"] = "0";//to_string(offsetE);
params["type"] = jEvt["type"].get<string>();
json fileNames;
string sf;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论