Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
4fabe8c9
提交
4fabe8c9
authored
9月 07, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new feature entropy filter to ignore gray frame without iframe
上级
263c2693
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
187 行增加
和
218 行删除
+187
-218
config.json
opencv-motion-detect/config.json
+64
-43
evcloudsvc.cpp
opencv-motion-detect/evcloudsvc.cpp
+102
-98
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+2
-0
utils.hpp
opencv-motion-detect/inc/utils.hpp
+19
-77
没有找到文件。
opencv-motion-detect/config.json
浏览文件 @
4fabe8c9
{
"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"
:[
"T6L5N3KN"
:{
"addr"
:
"127.0.0.1"
,
"api-cloud"
:
"http://127.0.0.1:8089"
,
"ipcs"
:[
{
"sn"
:
"ILS-2"
,
"addr"
:
"localhost"
,
"iid"
:
2
,
"enabled"
:
1
,
"urlDest"
:
"rtsp://40.73.41.176:554/test1"
"addr"
:
"172.31.0.51"
,
"modules"
:{
"evml"
:[
{
"area"
:
300
,
"enabled"
:
1
,
"iid"
:
1
,
"post"
:
30
,
"pre"
:
3
,
"sn"
:
"T6L5N3KN"
,
"status"
:
0
,
"thresh"
:
80
,
"type"
:
"motion"
}
],
"evpuller"
:[
{
"addr"
:
"127.0.0.1"
,
"iid"
:
1
,
"port-pub"
:
5556
,
"sn"
:
"T6L5N3KN"
,
"status"
:
0
}
],
"evpusher"
:[
{
"enabled"
:
1
,
"iid"
:
1
,
"password"
:
""
,
"sn"
:
"T6L5N3KN"
,
"status"
:
0
,
"token"
:
""
,
"urlDest"
:
"rtsp://40.73.41.176:554/test1"
,
"user"
:
""
}
],
"evslicer"
:[
{
"enabled"
:
1
,
"iid"
:
1
,
"path"
:
"slices"
,
"sn"
:
"T6L5N3KN"
,
"status"
:
0
}
]
},
"password"
:
"FWBWTU"
,
"port"
:
554
,
"proto"
:
"rtsp"
,
"status"
:
0
,
"user"
:
"admin"
}
],
"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
}
]
"mqtt-cloud"
:
"<cloud_addr>"
,
"port-cloud"
:
5556
,
"port-router"
:
5550
,
"proto"
:
"zmq"
,
"sn"
:
"T6L5N3KN"
,
"status"
:
1
}
}
},
"lastupdated"
:
1567669674
}
\ No newline at end of file
opencv-motion-detect/evcloudsvc.cpp
浏览文件 @
4fabe8c9
...
...
@@ -27,116 +27,110 @@ class HttpSrv{
// sn:module -> sn_of_evmgr
json
configMap
;
json
config
(
string
body
){
json
config
(
json
&
newConfig
){
json
ret
;
int
iret
;
json
oldConfigMap
=
this
->
configMap
;
ret
[
"code"
]
=
0
;
ret
[
"msg"
]
=
"ok"
;
ret
[
"time"
]
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
spdlog
::
info
(
body
);
if
(
body
.
empty
()){
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"no body payload"
;
}
else
{
try
{
json
newConfig
=
json
::
parse
(
body
);
if
(
newConfig
.
count
(
"data"
)
==
0
||
newConfig
[
"data"
].
size
()
==
0
)
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloudsvc invalid config body received: "
+
body
;
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
json
&
data
=
newConfig
[
"data"
];
for
(
auto
&
[
k
,
v
]
:
data
.
items
())
{
// this is one evmgr
if
(
v
.
count
(
"sn"
)
==
0
||
v
[
"sn"
]
!=
k
)
{
ret
[
"code"
]
=
2
;
ret
[
"msg"
]
=
"evcloudsvc invalid value for key "
+
k
;
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
spdlog
::
info
(
newConfig
.
dump
());
try
{
if
(
newConfig
.
count
(
"data"
)
==
0
||
newConfig
[
"data"
].
size
()
==
0
)
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloudsvc invalid config body received: "
+
newConfig
.
dump
();
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
}
else
{
json
&
data
=
newConfig
[
"data"
];
for
(
auto
&
[
k
,
v
]
:
data
.
items
())
{
// this is one evmgr
if
(
v
.
count
(
"sn"
)
==
0
||
v
[
"sn"
]
!=
k
)
{
ret
[
"code"
]
=
2
;
ret
[
"msg"
]
=
"evcloudsvc invalid value for key "
+
k
;
spdlog
::
error
(
ret
[
"msg"
].
get
<
string
>
());
break
;
}
else
{
// find all modules
if
(
v
.
count
(
"ipcs"
)
==
0
||
v
[
"ipcs"
].
size
()
==
0
)
{
spdlog
::
error
(
"invalid ipcs in config body"
);
ret
[
"code"
]
=
3
;
break
;
}
else
{
// find all modules
if
(
v
.
count
(
"ipcs"
)
==
0
||
v
[
"ipcs"
].
size
()
==
0
)
{
spdlog
::
error
(
"invalid ipcs in config body"
);
ret
[
"code"
]
=
3
;
break
;
}
else
{
json
&
ipcs
=
v
[
"ipcs"
];
for
(
auto
&
ipc
:
ipcs
)
{
if
(
ipc
.
count
(
"modules"
)
==
0
||
ipc
[
"modules"
].
size
()
==
0
)
{
spdlog
::
error
(
"invalid modules in ipcs config body"
);
ret
[
"code"
]
=
4
;
break
;
}
else
{
json
&
modules
=
ipc
[
"modules"
];
for
(
auto
&
[
mn
,
ma
]
:
modules
.
items
())
{
for
(
auto
&
m
:
ma
)
{
if
(
m
.
count
(
"sn"
)
!=
0
&&
m
[
"sn"
].
size
()
!=
0
){
string
modKey
;
//ml
if
(
mn
==
"evml"
&&
m
.
count
(
"type"
)
!=
0
&&
m
[
"type"
].
size
()
!=
0
)
{
modKey
=
m
[
"sn"
].
get
<
string
>
()
+
":evml:"
+
m
[
"type"
].
get
<
string
>
();
}
else
{
modKey
=
m
[
"sn"
].
get
<
string
>
()
+
":"
+
mn
;
}
// modkey -> sn_of_evmgr
this
->
configMap
[
modKey
]
=
k
;
json
&
ipcs
=
v
[
"ipcs"
];
for
(
auto
&
ipc
:
ipcs
)
{
if
(
ipc
.
count
(
"modules"
)
==
0
||
ipc
[
"modules"
].
size
()
==
0
)
{
spdlog
::
error
(
"invalid modules in ipcs config body"
);
ret
[
"code"
]
=
4
;
break
;
}
else
{
json
&
modules
=
ipc
[
"modules"
];
for
(
auto
&
[
mn
,
ma
]
:
modules
.
items
())
{
for
(
auto
&
m
:
ma
)
{
if
(
m
.
count
(
"sn"
)
!=
0
&&
m
[
"sn"
].
size
()
!=
0
){
string
modKey
;
//ml
if
(
mn
==
"evml"
&&
m
.
count
(
"type"
)
!=
0
&&
m
[
"type"
].
size
()
!=
0
)
{
modKey
=
m
[
"sn"
].
get
<
string
>
()
+
":evml:"
+
m
[
"type"
].
get
<
string
>
();
}
else
{
string
msg
=
"evcloudsvc invalid config: "
+
data
.
dump
();;
ret
[
"code"
]
=
-
1
;
ret
[
"msg"
]
=
msg
;
spdlog
::
error
(
msg
);
break
;
modKey
=
m
[
"sn"
].
get
<
string
>
()
+
":"
+
mn
;
}
// modkey -> sn_of_evmgr
this
->
configMap
[
modKey
]
=
k
;
}
else
{
string
msg
=
"evcloudsvc invalid config: "
+
data
.
dump
();;
ret
[
"code"
]
=
-
1
;
ret
[
"msg"
]
=
msg
;
spdlog
::
error
(
msg
);
break
;
}
}
// for modules
if
(
ret
[
"code"
]
!=
0
)
{
break
;
}
}
// for ipc
}
}
}
// for modules
if
(
ret
[
"code"
]
!=
0
)
{
break
;
}
}
// update evmgr config
json
evmgrData
;
evmgrData
[
"data"
]
=
data
;
//evmgrData["lastupdated"] = newConfig["lastupdated"];
if
(
ret
[
"code"
]
!=
0
)
{
break
;
}
}
// for ipc
}
}
//save
iret
=
LVDB
::
setLocalConfig
(
evmgrData
,
k
);
if
(
iret
<
0
)
{
string
msg
=
"failed to save config "
+
k
+
" -> "
+
evmgrData
.
dump
();
spdlog
::
error
(
msg
);
ret
[
"code"
]
=
iret
;
ret
[
"msg"
]
=
msg
;
}
}
// for evmgr
if
(
ret
[
"code"
]
!=
0
)
{
break
;
}
}
// update evmgr config
json
evmgrData
;
evmgrData
[
"data"
]
=
data
;
// save configmap
if
(
ret
[
"code"
]
==
0
)
{
iret
=
LVDB
::
setValue
(
this
->
configMap
,
KEY_CONFIG_MAP
);
if
(
iret
>=
0
)
{
}
else
{
ret
[
"code"
]
=
iret
;
ret
[
"msg"
]
=
"failed to save configmap"
;
}
}
else
{
this
->
configMap
=
oldConfigMap
;
//save
iret
=
LVDB
::
setLocalConfig
(
evmgrData
,
k
);
if
(
iret
<
0
)
{
string
msg
=
"failed to save config "
+
k
+
" -> "
+
evmgrData
.
dump
();
spdlog
::
error
(
msg
);
ret
[
"code"
]
=
iret
;
ret
[
"msg"
]
=
msg
;
}
}
// for evmgr
ret
[
"data"
]
=
newConfig
[
"data"
];
// save configmap
if
(
ret
[
"code"
]
==
0
)
{
iret
=
LVDB
::
setValue
(
this
->
configMap
,
KEY_CONFIG_MAP
);
if
(
iret
>=
0
)
{
}
else
{
ret
[
"code"
]
=
iret
;
ret
[
"msg"
]
=
"failed to save configmap"
;
}
}
else
{
this
->
configMap
=
oldConfigMap
;
}
}
catch
(
exception
&
e
)
{
ret
.
clear
();
ret
[
"code"
]
=
-
1
;
ret
[
"msg"
]
=
e
.
what
();
ret
[
"data"
]
=
newConfig
[
"data"
];
}
}
catch
(
exception
&
e
)
{
ret
.
clear
();
ret
[
"code"
]
=
-
1
;
ret
[
"msg"
]
=
e
.
what
();
}
return
ret
;
}
...
...
@@ -155,7 +149,9 @@ class HttpSrv{
json
ret
;
try
{
string
sn
=
req
.
get_param_value
(
"sn"
);
string
module
=
req
.
get_param_value
(
"module"
);
string
module
=
req
.
get_param_value
(
"module"
);
bool
force
=
(
req
.
get_param_value
(
"force"
)
==
"true"
)
?
true
:
false
;
if
(
sn
.
empty
()
||
module
.
empty
()){
throw
StrException
(
"no para sn/module"
);
}
...
...
@@ -177,7 +173,7 @@ class HttpSrv{
modname
=
sn
+
":"
+
modname
;
if
(
this
->
configMap
.
count
(
modname
)
==
0
){
spdlog
::
info
(
"evcloudsvc no such edge module registred: {}, create new entry"
,
key
);
ret
=
this
->
config
(
req
.
body
);
ret
=
this
->
config
(
cfg
);
if
(
ret
[
"code"
]
==
0
)
{
}
else
{
spdlog
::
error
(
"failed to config: {}"
,
ret
.
dump
());
...
...
@@ -194,16 +190,15 @@ class HttpSrv{
ret
[
"msg"
]
=
"diff"
;
json
data
;
r
=
LVDB
::
getLocalConfig
(
data
,
key
);
if
(
r
<
0
)
{
ret
[
"code"
]
=
r
;
ret
[
"msg"
]
=
"failed to get config for: "
+
key
;
if
(
r
<
0
||
force
)
{
spdlog
::
error
(
"failed to get localconfig or force to updaste. create new"
)
;
ret
=
this
->
config
(
cfg
)
;
}
else
{
json
diff
=
json
::
diff
(
data
,
cfg
);
json
diff
=
json
::
diff
(
cfg
,
data
);
spdlog
::
info
(
"evcloudsvc diff: {}"
,
diff
.
dump
());
ret
[
"data"
]
=
diff
;
}
}
}
catch
(
exception
&
e
)
{
ret
.
clear
();
ret
[
"code"
]
=
-
1
;
...
...
@@ -260,7 +255,16 @@ class HttpSrv{
});
svr
.
Post
(
"/config"
,
[
this
](
const
Request
&
req
,
Response
&
res
){
auto
ret
=
this
->
config
(
req
.
body
);
json
ret
;
string
msg
;
try
{
json
cfg
=
json
::
parse
(
req
.
body
);
ret
=
this
->
config
(
cfg
);
}
catch
(
exception
&
e
)
{
msg
=
string
(
"evcloudsvc exception on POST /config: "
)
+
e
.
what
();
ret
[
"msg"
]
=
msg
;
ret
[
"code"
]
=
-
1
;
}
res
.
set_content
(
ret
.
dump
(),
"text/json"
);
});
...
...
opencv-motion-detect/evmgr.cpp
浏览文件 @
4fabe8c9
...
...
@@ -72,6 +72,8 @@ private:
spdlog
::
error
(
"failed to get local configuration"
);
exit
(
1
);
}
// set all module status to 0
ret
=
LVDB
::
traverseConfigureModules
(
config
,
[](
string
modname
,
json
&
m
,
void
*
pUser
)
->
int
{
...
...
opencv-motion-detect/inc/utils.hpp
浏览文件 @
4fabe8c9
...
...
@@ -8,89 +8,15 @@
#include <sstream>
#include "json.hpp"
#include "spdlog/spdlog.h"
#include "httplib.h"
using
namespace
std
;
using
namespace
nlohmann
;
using
namespace
httplib
;
// cloudutils
namespace
cloudutils
{
/**
* scn:
* evpuller, evmgr, evmotion, evslicer
*
* */
/*
{
"time":0,
"lastupdated": 0,
"code":0,
"data":{
"ILSEVMGR1":{
"lastupdated": 0,
"sn":"ILSEVMGR1",
"addr":"172.31.0.76",
"addr-cloud":"172.31.0.76",RzMbCp5W6^ZS
"proto":"zmq",
"port-cloud":5556,
"port-router":5550,
"status":1,
"ipcs":[
{
"addr":"172.31.0.51",
"proto":"rtsp",
"user":"admin",
"password":"FWBWTU",
"port": 554,
"status":1,
"modules":{
"evpuller":[
{
"sn":"ILSEVPULLER1",
"addr":"172.31.0.76",
"iid":1,
"port-pub":5556,
"status":1
}
],
"evpusher":[
{
"sn":"ILSEVPUSHER1",
"iid":1,
"urlDest":"rtsp://40.73.41.176:554/test1",
"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
}
]
}
}
]
}
}
}
*/
// const char *config = "{\"time\":0,\"code\":0,\"data\":{\"ILSEVMGR1\":{\"sn\":\"ILSEVMGR1\",\"addr\":\"127.0.0.1\",\"addr-cloud\":\"127.0.0.1\",\"proto\":\"zmq\",\"port-cloud\":5556,\"port-router\":5550,\"status\":1,\"ipcs\":[{\"addr\":\"172.31.0.51\",\"proto\":\"rtsp\",\"user\":\"admin\",\"password\":\"iLabService\",\"status\":1,\"modules\":{\"evpuller\":[{\"sn\":\"ILSEVPULLER1\",\"addr\":\"127.0.0.1\",\"iid\":1,\"port-pub\":5556,\"status\":1}],\"evpusher\":[{\"sn\":\"ILSEVPUSHER1\",\"iid\":1,\"urlDest\":\"rtsp://40.73.41.176:554/test1\",\"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}]}}]}}}";
vector
<
string
>
split
(
const
std
::
string
&
s
,
char
delimiter
)
{
...
...
@@ -104,6 +30,22 @@ vector<string> split(const std::string& s, char delimiter)
return
tokens
;
}
/// ref: ../config.json
json
registry
(
json
&
conf
,
string
sn
,
string
module
)
{
json
ret
;
string
api
;
try
{
api
=
conf
.
at
(
sn
).
at
(
"api-cloud"
).
get
<
string
>
()
+
"/register"
;
}
catch
(
exception
&
e
)
{
}
// /Client cli;
return
ret
;
}
}
// namespace cloudutils
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论