Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
1afbaa51
提交
1afbaa51
authored
8月 21, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
025ff250
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
32 行增加
和
38 行删除
+32
-38
Makefile
opencv-motion-detect/Makefile
+2
-2
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+5
-3
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+2
-2
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+22
-30
common.hpp
opencv-motion-detect/inc/common.hpp
+1
-1
没有找到文件。
opencv-motion-detect/Makefile
浏览文件 @
1afbaa51
CC
=
gcc
CPP
=
g++
CPPFLAGS
=
-
g
-
Wall
-std
=
gnu++1z
CFLAGS
=
-
g
-
Wall
CPPFLAGS
=
-Wall
-std
=
gnu++1z
CFLAGS
=
-Wall
LIBOPENCV
=
`
pkg-config opencv
--cflags
--libs
`
LIBFFMPEG
=
`
pkg-config libavformat libavutil libavcodec libswscale
--cflags
--libs
`
...
...
opencv-motion-detect/evmgr.cpp
浏览文件 @
1afbaa51
...
...
@@ -96,12 +96,12 @@ private:
// ID_SENDER, ID_TARGET, MSG
if
(
body
.
size
()
!=
3
)
{
spdlog
::
error
(
"evmgr {} illegal message received, frame num
: {}"
,
devSn
,
body
.
size
());
return
-
1
;
spdlog
::
warn
(
"evmgr {} dropped a message, since its size is incorrect
: {}"
,
devSn
,
body
.
size
());
return
0
;
}
// if need forward
if
(
memcmp
((
void
*
)(
body
[
1
].
data
()),
devSn
.
data
(),
body
[
1
].
size
())
!=
0
)
{
if
(
memcmp
((
void
*
)(
body
[
1
].
data
()),
(
devSn
+
":0:0"
)
.
data
(),
body
[
1
].
size
())
!=
0
)
{
spdlog
::
info
(
"evmgr {} route msg from {} to {}"
,
devSn
,
body2str
(
body
[
0
]),
body2str
(
body
[
1
]));
vector
<
vector
<
uint8_t
>
>
v
;
v
.
push_back
(
body
[
1
]);
...
...
@@ -159,6 +159,7 @@ public:
int
main
(
int
argc
,
const
char
*
argv
[])
{
EvMgr
mgr
;
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
mgr
.
join
();
return
0
;
}
\ No newline at end of file
opencv-motion-detect/evpuller.cpp
浏览文件 @
1afbaa51
...
...
@@ -47,7 +47,7 @@ protected:
// declare ready to router
vector
<
vector
<
uint8_t
>
>
body
;
// since identity is auto set
body
.
push_back
(
str2body
(
mgrSn
));
body
.
push_back
(
str2body
(
mgrSn
+
":0:0"
));
body
.
push_back
(
str2body
(
MSG_HELLO
));
ret
=
z_send_multiple
(
pDealer
,
body
);
...
...
@@ -328,7 +328,7 @@ public:
int
main
(
int
argc
,
char
**
argv
)
{
av_log_set_level
(
AV_LOG_INFO
);
spdlog
::
set_level
(
spdlog
::
level
::
info
);
spdlog
::
set_level
(
spdlog
::
level
::
debug
);
//DB::exec(NULL, NULL, NULL,NULL);
auto
evp
=
EvPuller
();
evp
.
join
();
...
...
opencv-motion-detect/evpusher.cpp
浏览文件 @
1afbaa51
...
...
@@ -108,7 +108,6 @@ private:
}
int
setupMq
()
{
teardownMq
();
int
ret
=
0
;
// setup sub
...
...
@@ -125,7 +124,7 @@ private:
return
-
2
;
}
// setup
req
// setup
dealer
pDealerCtx
=
zmq_ctx_new
();
pDealer
=
zmq_socket
(
pDealerCtx
,
ZMQ_DEALER
);
spdlog
::
info
(
"evpusher {} {} try create req to {}"
,
devSn
,
iid
,
urlDealer
);
...
...
@@ -141,9 +140,10 @@ private:
}
// send hello to router
spdlog
::
info
(
"evpusher {} {} send hello to router: {}"
,
devSn
,
iid
,
mgrSn
);
vector
<
vector
<
uint8_t
>
>
body
;
// since identity is auto set
body
.
push_back
(
str2body
(
mgrSn
));
body
.
push_back
(
str2body
(
mgrSn
+
":0:0"
));
body
.
push_back
(
str2body
(
MSG_HELLO
));
ret
=
z_send_multiple
(
pDealer
,
body
);
...
...
@@ -158,27 +158,6 @@ private:
return
0
;
}
int
teardownMq
()
{
if
(
pSub
!=
NULL
)
{
zmq_close
(
pSub
);
pSub
=
NULL
;
}
if
(
pSubCtx
!=
NULL
)
{
zmq_ctx_destroy
(
pSubCtx
);
pSubCtx
=
NULL
;
}
if
(
pDealer
!=
NULL
)
{
zmq_close
(
pSub
);
pDealer
=
NULL
;
}
if
(
pDealerCtx
!=
NULL
)
{
zmq_ctx_destroy
(
pSub
);
pDealerCtx
=
NULL
;
}
return
0
;
}
int
setupStream
()
{
...
...
@@ -187,12 +166,13 @@ private:
// req avformatcontext packet
// send hello to puller
spdlog
::
info
(
"evpusher {} {} send hello to puller: {}"
,
devSn
,
iid
,
pullerGid
);
vector
<
vector
<
uint8_t
>
>
body
;
body
.
push_back
(
str2body
(
pullerGid
));
body
.
push_back
(
str2body
(
MSG_HELLO
));
ret
=
z_send_multiple
(
pDealer
,
body
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"evpusher {} {}, failed to send hello: {}"
,
devSn
,
iid
,
zmq_strerror
(
zmq_errno
()));
spdlog
::
error
(
"evpusher {} {}, failed to send hello
to puller
: {}"
,
devSn
,
iid
,
zmq_strerror
(
zmq_errno
()));
return
ret
;
}
spdlog
::
info
(
"evpusher {} {} success send hello"
,
devSn
,
iid
);
...
...
@@ -347,16 +327,28 @@ public:
EvPusher
()
{
init
();
if
(
setupMq
()
<
0
)
{
// TODO: reconnect
exit
(
1
);
}
setupMq
();
setupStream
();
}
~
EvPusher
()
{
teardownMq
();
if
(
pSub
!=
NULL
)
{
zmq_close
(
pSub
);
pSub
=
NULL
;
}
if
(
pSubCtx
!=
NULL
)
{
zmq_ctx_destroy
(
pSubCtx
);
pSubCtx
=
NULL
;
}
if
(
pDealer
!=
NULL
)
{
zmq_close
(
pSub
);
pDealer
=
NULL
;
}
if
(
pDealerCtx
!=
NULL
)
{
zmq_ctx_destroy
(
pSub
);
pDealerCtx
=
NULL
;
}
// free avformatcontex
if
(
pAVFormatInput
!=
NULL
)
{
AVFormatCtxSerializer
::
freeCtx
(
pAVFormatInput
);
...
...
opencv-motion-detect/inc/common.hpp
浏览文件 @
1afbaa51
...
...
@@ -94,7 +94,7 @@ int encode(AVPacket &pkt, char **bytes)
memcpy
((
*
bytes
)
+
cnt
,
PS_MARK_E
,
strlen
(
PS_MARK_E
));
cnt
+=
strlen
(
PS_MARK_E
);
assert
(
cnt
==
wholeSize
);
spdlog
::
debug
(
"pkt origin size {:d}, serialized size: {:d}, elems: {:d}
"
,
pkt
.
size
,
wholeSize
,
pkt
.
side_data_elems
);
av_log
(
NULL
,
AV_LOG_DEBUG
,
"pkt origin size %d, serialized size: %d, elems: %d
"
,
pkt
.
size
,
wholeSize
,
pkt
.
side_data_elems
);
return
wholeSize
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论