Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
0c0a296c
提交
0c0a296c
authored
9月 04, 2019
作者:
bruce.lu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init
上级
edc8960b
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
70 行增加
和
12 行删除
+70
-12
database.cpp
opencv-motion-detect/database.cpp
+10
-0
evcloudsvc.cpp
opencv-motion-detect/evcloudsvc.cpp
+20
-3
evmlmotion.cpp
opencv-motion-detect/evmlmotion.cpp
+36
-5
database.h
opencv-motion-detect/inc/database.h
+4
-4
没有找到文件。
opencv-motion-detect/database.cpp
浏览文件 @
0c0a296c
...
@@ -203,6 +203,12 @@ namespace LVDB {
...
@@ -203,6 +203,12 @@ namespace LVDB {
int
getValue
(
string
&
value
,
string
key
,
string
fileName
,
cb_verify_str
cb
)
{
int
getValue
(
string
&
value
,
string
key
,
string
fileName
,
cb_verify_str
cb
)
{
int
ret
=
0
;
int
ret
=
0
;
DB
*
pdb
=
NULL
;
DB
*
pdb
=
NULL
;
if
(
fileName
.
empty
()){
fileName
=
LVDB_FILE_GENERAL
;
}
ret
=
_getDB
(
fileName
,
&
pdb
);
ret
=
_getDB
(
fileName
,
&
pdb
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
ret
;
return
ret
;
...
@@ -231,6 +237,10 @@ namespace LVDB {
...
@@ -231,6 +237,10 @@ namespace LVDB {
}
}
}
}
if
(
fileName
.
empty
()){
fileName
=
LVDB_FILE_GENERAL
;
}
DB
*
pdb
=
NULL
;
DB
*
pdb
=
NULL
;
ret
=
_getDB
(
fileName
,
&
pdb
);
ret
=
_getDB
(
fileName
,
&
pdb
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
...
opencv-motion-detect/evcloudsvc.cpp
浏览文件 @
0c0a296c
...
@@ -67,10 +67,27 @@ class HttpSrv{
...
@@ -67,10 +67,27 @@ class HttpSrv{
try
{
try
{
json
newConfig
=
json
::
parse
(
req
.
body
);
json
newConfig
=
json
::
parse
(
req
.
body
);
if
(
newConfig
.
count
(
"data"
)
==
0
||
newConfig
[
"data"
].
size
()
==
0
)
{
if
(
newConfig
.
count
(
"data"
)
==
0
||
newConfig
[
"data"
].
size
()
==
0
)
{
ret
[
"code"
]
=
1
;
ret
[
"msg"
]
=
"evcloudsvc invalid config body received: "
+
req
.
body
;
spdlog
::
error
(
ret
[
"msg"
]);
}
else
{
//LVDB::setLocalConfig(newConfig);
//this->configMap = newConfig;
json
&
data
=
newConfig
[
"data"
];
for
(
auto
&
[
k
,
v
]
:
data
.
items
())
{
if
(
v
.
count
(
k
)
==
0
||
v
[
k
].
size
()
==
0
)
{
ret
[
"code"
]
=
2
;
ret
[
"msg"
]
=
"evcloudsvc invalid value for key "
+
k
;
spdlog
::
error
(
ret
[
"msg"
]);
}
else
{
//
LVDB
::
setLocalConfig
(
v
,
k
);
this
->
configMap
[
k
]
=
v
;
LVDB
::
setValue
(
this
->
configMap
,
"configmap"
)
}
}
}
LVDB
::
setLocalConfig
(
newConfig
);
}
this
->
configMap
=
newConfig
;
// TODO: restart other components
// TODO: restart other components
//
//
...
...
opencv-motion-detect/evmlmotion.cpp
浏览文件 @
0c0a296c
...
@@ -37,7 +37,8 @@ using namespace std;
...
@@ -37,7 +37,8 @@ using namespace std;
using
namespace
zmqhelper
;
using
namespace
zmqhelper
;
#define URLOUT_DEFAULT "frames"
#define URLOUT_DEFAULT "frames"
#define NUM_PKT_IGNORE 18*2
#define NUM_PKT_IGNORE 18*10
#define FRAME_SIZE 500
#define DEBUG
#define DEBUG
...
@@ -157,6 +158,7 @@ private:
...
@@ -157,6 +158,7 @@ private:
pullerGid
=
evpuller
[
"sn"
].
get
<
string
>
()
+
":evpuller:"
+
to_string
(
evpuller
[
"iid"
]);
pullerGid
=
evpuller
[
"sn"
].
get
<
string
>
()
+
":evpuller:"
+
to_string
(
evpuller
[
"iid"
]);
mgrSn
=
evmgr
[
"sn"
];
mgrSn
=
evmgr
[
"sn"
];
// TODO: connect to the first slicer
json
evslicer
=
ipc
[
"modules"
][
"evslicer"
][
0
];
json
evslicer
=
ipc
[
"modules"
][
"evslicer"
][
0
];
slicerGid
=
evslicer
[
"sn"
].
get
<
string
>
()
+
":evslicer:"
+
to_string
(
evslicer
[
"iid"
]);
slicerGid
=
evslicer
[
"sn"
].
get
<
string
>
()
+
":evslicer:"
+
to_string
(
evslicer
[
"iid"
]);
...
@@ -166,7 +168,7 @@ private:
...
@@ -166,7 +168,7 @@ private:
// TODO: multiple protocols support
// TODO: multiple protocols support
if
(
evmlmotion
.
count
(
"path"
)
==
0
)
{
if
(
evmlmotion
.
count
(
"path"
)
==
0
)
{
spdlog
::
warn
(
"ev
slicer
{} no params for path, using default: {}"
,
selfId
,
URLOUT_DEFAULT
);
spdlog
::
warn
(
"ev
mlmotion
{} no params for path, using default: {}"
,
selfId
,
URLOUT_DEFAULT
);
urlOut
=
URLOUT_DEFAULT
;
urlOut
=
URLOUT_DEFAULT
;
}
}
else
{
else
{
...
@@ -179,6 +181,35 @@ private:
...
@@ -179,6 +181,35 @@ private:
return
-
1
;
return
-
1
;
}
}
// detection params
if
(
evmlmotion
.
count
(
"thresh"
)
==
0
||
evmlmotion
[
"thresh"
]
<
10
||
evmlmotion
[
"thresh"
]
>=
255
)
{
spdlog
::
warn
(
"evmlmotion {} invalid thresh value. should be in (10,255), default to 80"
,
selfId
);
detPara
.
thre
=
80
;
}
else
{
detPara
.
thre
=
evmlmotion
[
"thresh"
];
}
if
(
evmlmotion
.
count
(
"area"
)
==
0
||
evmlmotion
[
"area"
]
<
10
||
evmlmotion
[
"area"
]
>=
int
(
FRAME_SIZE
*
FRAME_SIZE
)
*
9
/
10
)
{
spdlog
::
warn
(
"evmlmotion {} invalid area value. should be in (10, 500*500*/10), default to 500"
,
selfId
);
detPara
.
area
=
FRAME_SIZE
;
}
else
{
detPara
.
area
=
evmlmotion
[
"area"
];
}
if
(
evmlmotion
.
count
(
"pre"
)
==
0
||
evmlmotion
[
"pre"
]
<
1
||
evmlmotion
[
"pre"
]
>=
120
)
{
spdlog
::
warn
(
"evmlmotion {} invalid pre value. should be in (1, 120), default to 3"
,
selfId
);
detPara
.
pre
=
3
;
}
else
{
detPara
.
pre
=
evmlmotion
[
"pre"
];
}
if
(
evmlmotion
.
count
(
"post"
)
==
0
||
evmlmotion
[
"post"
]
<
6
||
evmlmotion
[
"post"
]
>=
120
)
{
spdlog
::
warn
(
"evmlmotion {} invalid post value. should be in (6, 120), default to 30"
,
selfId
);
detPara
.
post
=
30
;
}
else
{
detPara
.
post
=
evmlmotion
[
"post"
];
}
// setup sub
// setup sub
pSubCtx
=
zmq_ctx_new
();
pSubCtx
=
zmq_ctx_new
();
pSub
=
zmq_socket
(
pSubCtx
,
ZMQ_SUB
);
pSub
=
zmq_socket
(
pSubCtx
,
ZMQ_SUB
);
...
@@ -408,7 +439,7 @@ private:
...
@@ -408,7 +439,7 @@ private:
static
vector
<
vector
<
cv
::
Point
>
>
cnts
;
static
vector
<
vector
<
cv
::
Point
>
>
cnts
;
cv
::
Mat
origin
,
gray
,
thresh
;
cv
::
Mat
origin
,
gray
,
thresh
;
avcvhelpers
::
frame2mat
(
format
,
pFrame
,
origin
);
avcvhelpers
::
frame2mat
(
format
,
pFrame
,
origin
);
cv
::
resize
(
origin
,
gray
,
cv
::
Size
(
500
,
500
));
cv
::
resize
(
origin
,
gray
,
cv
::
Size
(
FRAME_SIZE
,
FRAME_SIZE
));
cv
::
cvtColor
(
gray
,
thresh
,
cv
::
COLOR_BGR2GRAY
);
cv
::
cvtColor
(
gray
,
thresh
,
cv
::
COLOR_BGR2GRAY
);
cv
::
GaussianBlur
(
thresh
,
gray
,
cv
::
Size
(
21
,
21
),
cv
::
THRESH_BINARY
);
cv
::
GaussianBlur
(
thresh
,
gray
,
cv
::
Size
(
21
,
21
),
cv
::
THRESH_BINARY
);
if
(
first
)
{
if
(
first
)
{
...
@@ -430,7 +461,7 @@ private:
...
@@ -430,7 +461,7 @@ private:
#endif
#endif
// TODO:
// TODO:
cv
::
threshold
(
thresh
,
gray
,
25
,
255
,
cv
::
THRESH_BINARY
);
cv
::
threshold
(
thresh
,
gray
,
detPara
.
thre
,
255
,
cv
::
THRESH_BINARY
);
cv
::
dilate
(
gray
,
thresh
,
cv
::
Mat
(),
cv
::
Point
(
-
1
,
-
1
),
2
);
cv
::
dilate
(
gray
,
thresh
,
cv
::
Mat
(),
cv
::
Point
(
-
1
,
-
1
),
2
);
#ifdef DEBUG
#ifdef DEBUG
...
@@ -441,7 +472,7 @@ private:
...
@@ -441,7 +472,7 @@ private:
bool
hasEvent
=
false
;
bool
hasEvent
=
false
;
for
(
int
i
=
0
;
i
<
cnts
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
cnts
.
size
();
i
++
)
{
// TODO:
// TODO:
if
(
cv
::
contourArea
(
cnts
[
i
])
<
200
)
{
if
(
cv
::
contourArea
(
cnts
[
i
])
<
detPara
.
area
)
{
// nothing
// nothing
}
}
else
{
else
{
...
...
opencv-motion-detect/inc/database.h
浏览文件 @
0c0a296c
...
@@ -25,10 +25,10 @@ namespace LVDB {
...
@@ -25,10 +25,10 @@ namespace LVDB {
typedef
int
(
*
cb_verify_json
)(
const
json
&
);
typedef
int
(
*
cb_verify_json
)(
const
json
&
);
int
setValue
(
const
string
&
value
,
string
key
,
string
fileName
,
cb_verify_str
cb
);
int
setValue
(
const
string
&
value
,
string
key
,
string
fileName
=
""
,
cb_verify_str
cb
=
NULL
);
int
getValue
(
string
&
value
,
string
key
,
string
fileName
,
cb_verify_str
cb
);
int
getValue
(
string
&
value
,
string
key
,
string
fileName
=
""
,
cb_verify_str
cb
=
NULL
);
int
setValue
(
const
json
&
value
,
string
key
,
string
fileName
,
cb_verify_json
cb
);
int
setValue
(
const
json
&
value
,
string
key
,
string
fileName
=
""
,
cb_verify_json
cb
=
NULL
);
int
getValue
(
json
&
value
,
string
key
,
string
fileName
,
cb_verify_json
cb
);
int
getValue
(
json
&
value
,
string
key
,
string
fileName
=
""
,
cb_verify_json
cb
=
NULL
);
//
//
json
*
findConfigModule
(
json
&
config
,
string
sn
,
string
moduleName
,
int
iid
);
json
*
findConfigModule
(
json
&
config
,
string
sn
,
string
moduleName
,
int
iid
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论