Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
b6eadb7d
提交
b6eadb7d
authored
8月 23, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
01b85e1c
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
138 行增加
和
152 行删除
+138
-152
config.json
opencv-motion-detect/config.json
+50
-67
database.cpp
opencv-motion-detect/database.cpp
+0
-0
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+1
-8
evmlmotion.cpp
opencv-motion-detect/evmlmotion.cpp
+78
-69
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+2
-2
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+1
-1
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+6
-5
没有找到文件。
opencv-motion-detect/config.json
浏览文件 @
b6eadb7d
{
"time"
:
0
,
"code"
:
0
,
"data"
:{
"ILSEVMGR1"
:{
"sn"
:
"ILSEVMGR1"
,
"addr"
:
"172.31.0.76"
,
"addr-cloud"
:
"172.31.0.76"
,
"proto"
:
"zmq"
,
"port-cloud"
:
5556
,
"port-router"
:
5550
,
"status"
:
1
,
"ipcs"
:[
{
"addr"
:
"172.31.0.51"
,
"proto"
:
"rtsp"
,
"user"
:
"admin"
,
"password"
:
"FWBWTU"
,
"status"
:
1
,
"modules"
:{
"evpuller"
:[
{
"sn"
:
"ILSEVPULLER1"
,
"addr"
:
"172.31.0.76"
,
"iid"
:
1
,
"port-pub"
:
"5556"
,
"status"
:
1
}
],
"evpusher"
:[
{
"sn"
:
"ILSEVPUSHER1"
,
"iid"
:
1
,
"proto"
:
"rtsp"
,
"addrDest"
:
"40.73.41.176"
,
"portDest"
:
554
,
"user"
:
""
,
"password"
:
""
,
"token"
:
""
,
"enabled"
:
1
,
"status"
:
1
}
],
"evslicer"
:[
{
"sn"
:
"ILSEVSLICER1"
,
"iid"
:
1
,
"path"
:
"slices"
,
"enabled"
:
1
,
"status"
:
1
}
],
"evml"
:[
{
"type"
:
"motion"
,
"sn"
:
"ILSEVMLMOTION1"
,
"iid"
:
1
,
"enabled"
:
1
,
"status"
:
1
}
]
}
}
]
}
}
}
\ No newline at end of file
"code"
:
0
,
"time"
:
0
,
"data"
:{
"ipc"
:
"172.31.0.51"
,
"username"
:
"admin"
,
"password"
:
"FWBWTU"
,
"services"
:{
"evmgr"
:{
"sn"
:
"ILS-1"
,
"addr"
:
"0.0.0.0"
,
"port-pub"
:
5556
,
"port-rep"
:
5557
,
"iid"
:
1
},
"evpuller"
:{
"sn"
:
"ILS-2"
,
"addr"
:
"0.0.0.0"
,
"port-pub"
:
5556
,
"port-rep"
:
5557
,
"iid"
:
2
},
"evpusher"
:[
{
"sn"
:
"ILS-2"
,
"addr"
:
"localhost"
,
"iid"
:
2
,
"enabled"
:
1
,
"urlDest"
:
"rtsp://40.73.41.176:554/test1"
}
],
"evslicer"
:[
{
"sn"
:
"ILS-3"
,
"addr"
:
"192.168.0.25"
,
"iid"
:
3
,
"path"
:
"/var/lib/slices/"
}
],
"evml"
:[
{
"feature"
:
"motion"
,
"sn"
:
"ILS-4"
,
"addr"
:
"192.168.0.26"
,
"iid"
:
4
}
]
}
}
}
\ No newline at end of file
opencv-motion-detect/database.cpp
浏览文件 @
b6eadb7d
差异被折叠。
点击展开。
opencv-motion-detect/evmgr.cpp
浏览文件 @
b6eadb7d
...
...
@@ -29,13 +29,6 @@ namespace fs = std::filesystem;
using
namespace
std
;
using
namespace
zmqhelper
;
/**
* functions:
* app update
* control msg
*
**/
class
EvMgr
:
public
TinyThread
{
private
:
void
*
pRouterCtx
=
NULL
;
...
...
@@ -129,7 +122,7 @@ private:
json
jEvt
;
jEvt
[
"type"
]
=
EV_MSG_TYPE_CONN_STAT
;
jEvt
[
"gid"
]
=
selfId
;
jEvt
[
'
ts
'
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
jEvt
[
"ts"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
if
(
eventConn
)
{
jEvt
[
"event"
]
=
EV_MSG_EVENT_CONN_CONN
;
}
...
...
opencv-motion-detect/evmlmotion.cpp
浏览文件 @
b6eadb7d
/*
module: evmlmotion
description:
description:
author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23
*/
...
...
@@ -136,10 +136,11 @@ private:
urlRouter
=
string
(
"tcp://"
)
+
evmgr
[
"addr"
].
get
<
string
>
()
+
":"
+
to_string
(
evmgr
[
"port-router"
]);
spdlog
::
info
(
"evmlmotion {} {} will connect to {} for sub, {} for router"
,
devSn
,
iid
,
urlPub
,
urlRouter
);
// TODO: multiple protocols support
if
(
evmlmotion
.
count
(
"path"
)
==
0
){
if
(
evmlmotion
.
count
(
"path"
)
==
0
)
{
spdlog
::
warn
(
"evslicer {} {} no params for path, using default: {}"
,
devSn
,
iid
,
URLOUT_DEFAULT
);
urlOut
=
URLOUT_DEFAULT
;
}
else
{
}
else
{
urlOut
=
evmlmotion
[
"path"
];
}
...
...
@@ -443,75 +444,79 @@ private:
// business logic for event
auto
dura
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
evtStartTm
-
evtStartTmLast
).
count
();
switch
(
evtState
)
{
case
NONE
:
{
if
(
hasEvent
)
{
case
NONE
:
{
if
(
hasEvent
)
{
evtState
=
PRE
;
spdlog
::
info
(
"state: NONE->PRE"
);
evtStartTmLast
=
evtStartTm
;
}
break
;
}
case
PRE
:
{
if
(
hasEvent
)
{
if
(
dura
>
detPara
.
pre
)
{
spdlog
::
info
(
"state: PRE->PRE"
);
evtState
=
PRE
;
spdlog
::
info
(
"state: NONE->PRE"
);
evtStartTmLast
=
evtStartTm
;
}
break
;
}
case
PRE
:
{
if
(
hasEvent
)
{
if
(
dura
>
detPara
.
pre
)
{
spdlog
::
info
(
"state: PRE->PRE"
);
evtState
=
PRE
;
}
else
{
evtState
=
IN
;
json
p
;
spdlog
::
info
(
"state: PRE->IN"
);
p
[
"type"
]
=
EV_MSG_TYPE_AI_MOTION
;
p
[
"gid"
]
=
selfId
;
p
[
"event"
]
=
EV_MSG_EVENT_MOTION_START
;
p
[
"ts"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
evtStartTmLast
.
time_since_epoch
()).
count
();
//p["frame"] = origin.clone();
evtQueue
->
push
(
p
.
dump
());
if
(
evtQueue
->
size
()
>
MAX_EVENT_QUEUE_SIZE
*
2
)
{
evtQueue
->
pop
();
}
}
}
else
{
if
(
dura
>
detPara
.
pre
){
evtState
=
NONE
;
spdlog
::
info
(
"state: PRE->NONE"
);
else
{
evtState
=
IN
;
json
p
;
spdlog
::
info
(
"state: PRE->IN"
);
p
[
"type"
]
=
EV_MSG_TYPE_AI_MOTION
;
p
[
"gid"
]
=
selfId
;
p
[
"event"
]
=
EV_MSG_EVENT_MOTION_START
;
p
[
"ts"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
evtStartTmLast
.
time_since_epoch
()).
count
();
//p["frame"] = origin.clone();
evtQueue
->
push
(
p
.
dump
());
if
(
evtQueue
->
size
()
>
MAX_EVENT_QUEUE_SIZE
*
2
)
{
evtQueue
->
pop
();
}
}
break
;
}
case
IN
:
{
if
(
!
hasEvent
){
if
(
dura
>
(
int
)(
detPara
.
post
/
2
)){
evtState
=
POST
;
spdlog
::
info
(
"state: IN->POST"
);
}
}
else
{
evtStartTmLast
=
evtStartTm
;
spdlog
::
info
(
"state: IN->IN"
);
else
{
if
(
dura
>
detPara
.
pre
)
{
evtState
=
NONE
;
spdlog
::
info
(
"state: PRE->NONE"
);
}
break
;
}
case
POST
:
{
if
(
!
hasEvent
)
{
if
(
dura
>
detPara
.
post
)
{
spdlog
::
info
(
"state: POST->NONE"
);
evtState
=
NONE
;
json
p
;
p
[
"type"
]
=
EV_MSG_TYPE_AI_MOTION
;
p
[
"gid"
]
=
selfId
;
p
[
"event"
]
=
EV_MSG_EVENT_MOTION_END
;
p
[
"ts"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
evtStartTmLast
.
time_since_epoch
()).
count
()
+
(
int
)(
detPara
.
post
/
2
);
evtQueue
->
push
(
p
.
dump
());
if
(
evtQueue
->
size
()
>
MAX_EVENT_QUEUE_SIZE
*
2
)
{
evtQueue
->
pop
();
}
break
;
}
case
IN
:
{
if
(
!
hasEvent
)
{
if
(
dura
>
(
int
)(
detPara
.
post
/
2
))
{
evtState
=
POST
;
spdlog
::
info
(
"state: IN->POST"
);
}
}
else
{
evtStartTmLast
=
evtStartTm
;
spdlog
::
info
(
"state: IN->IN"
);
}
break
;
}
case
POST
:
{
if
(
!
hasEvent
)
{
if
(
dura
>
detPara
.
post
)
{
spdlog
::
info
(
"state: POST->NONE"
);
evtState
=
NONE
;
json
p
;
p
[
"type"
]
=
EV_MSG_TYPE_AI_MOTION
;
p
[
"gid"
]
=
selfId
;
p
[
"event"
]
=
EV_MSG_EVENT_MOTION_END
;
p
[
"ts"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
evtStartTmLast
.
time_since_epoch
()).
count
()
+
(
int
)(
detPara
.
post
/
2
);
evtQueue
->
push
(
p
.
dump
());
if
(
evtQueue
->
size
()
>
MAX_EVENT_QUEUE_SIZE
*
2
)
{
evtQueue
->
pop
();
}
}
else
{
spdlog
::
info
(
"state: POST->IN"
);
evtState
=
IN
;
evtStartTmLast
=
evtStartTm
;
}
break
;
}
else
{
spdlog
::
info
(
"state: POST->IN"
);
evtState
=
IN
;
evtStartTmLast
=
evtStartTm
;
}
break
;
}
}
}
...
...
@@ -526,13 +531,14 @@ protected:
AVPacket
packet
;
//event thread
thEvent
=
thread
([
&
,
this
](){
json
meta
;
meta
[
"type"
]
=
EV_MSG_META_EVENT
;
thEvent
=
thread
([
&
,
this
]()
{
json
meta
;
meta
[
"type"
]
=
EV_MSG_META_EVENT
;
string
metaType
=
meta
.
dump
();
int
ret
=
0
;
vector
<
vector
<
uint8_t
>
>
v
=
{
str2body
(
this
->
pullerGid
),
str2body
(
metaType
),
str2body
(
""
)};
while
(
true
){
if
(
!
this
->
evtQueue
->
empty
()){
while
(
true
)
{
if
(
!
this
->
evtQueue
->
empty
())
{
string
evt
=
this
->
evtQueue
->
front
();
v
[
2
]
=
str2body
(
evt
);
this
->
evtQueue
->
pop
();
...
...
@@ -541,7 +547,8 @@ protected:
if
(
ret
<
0
)
{
spdlog
::
error
(
"evmlmotion {} {} failed to send event: {}, {}"
,
this
->
devSn
,
this
->
iid
,
evt
,
zmq_strerror
(
zmq_errno
()));
}
}
else
{
}
else
{
this_thread
::
sleep_for
(
chrono
::
seconds
(
3
));
}
}
...
...
@@ -610,7 +617,8 @@ public:
getInputFormat
();
setupStream
();
};
~
EvMLMotion
()
{
~
EvMLMotion
()
{
if
(
pSub
!=
NULL
)
{
zmq_close
(
pSub
);
pSub
=
NULL
;
...
...
@@ -658,7 +666,8 @@ int main(int argc, const char *argv[])
string
p
=
evtQueue
.
front
();
spdlog
::
info
(
"event: {}"
,
p
);
evtQueue
.
pop
();
}
else
{
}
else
{
this_thread
::
sleep_for
(
chrono
::
duration
(
chrono
::
seconds
(
2
)));
}
}
...
...
opencv-motion-detect/evpuller.cpp
浏览文件 @
b6eadb7d
/*
module: evpuller
description:
description:
author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23
*/
...
...
@@ -111,7 +111,7 @@ protected:
// });
// thPing.detach();
// init response msg
while
(
true
)
{
if
(
checkStop
()
==
true
)
{
...
...
opencv-motion-detect/evpusher.cpp
浏览文件 @
b6eadb7d
/*
module: evpusher
description:
description:
author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/23
*/
...
...
opencv-motion-detect/evslicer.cpp
浏览文件 @
b6eadb7d
/*
module: evslicer
description:
description:
author: Bruce.Lu <lzbgt@icloud.com>
update: 2019/08/20
*/
...
...
@@ -20,6 +20,7 @@ update: 2019/08/20
#include <filesystem>
namespace
fs
=
std
::
filesystem
;
#endif
#include <cstdlib>
#include "zmqhelper.hpp"
#include "tinythread.hpp"
...
...
@@ -128,7 +129,7 @@ private:
numSlices
=
24
*
days
*
60
/
minutes
;
// alloc memory
sliceIdxToName
=
new
vector
<
int
>
(
numSlices
);
// load db
//
TODO:
load db
// DB::exec(NULL, "select id, ts, last from slices;", DB::get_slices, sliceIdxToName);
spdlog
::
info
(
"mkdir -p {}"
,
urlOut
);
ret
=
system
((
string
(
"mkdir -p "
)
+
urlOut
).
c_str
());
...
...
@@ -443,13 +444,13 @@ protected:
break
;
}
}
end
=
chrono
::
system_clock
::
now
();
}
// while in slice
// write tail
// close output context
if
(
pAVFormatRemux
!=
NULL
){
if
(
pAVFormatRemux
->
pb
!=
NULL
){
if
(
pAVFormatRemux
!=
NULL
)
{
if
(
pAVFormatRemux
->
pb
!=
NULL
)
{
avio_closep
(
&
pAVFormatRemux
->
pb
);
}
avformat_free_context
(
pAVFormatRemux
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论