Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evcamera
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evcamera
Commits
5e950222
提交
5e950222
authored
5月 22, 2020
作者:
blu
浏览文件
操作
浏览文件
下载
差异文件
fsm and more
上级
cf53aa1b
5b92158f
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
64 行增加
和
3 行删除
+64
-3
motiondetect.hpp
hi3518/motiondetect.hpp
+33
-3
smart.cc
hi3518/smart.cc
+31
-0
没有找到文件。
hi3518/motiondetect.hpp
浏览文件 @
5e950222
...
...
@@ -22,10 +22,8 @@ namespace md{
const
string
kKeyM
=
"m"
;
const
string
kKeyN
=
"n"
;
const
string
kKeyP
=
"p"
;
const
int
kMaxCntMotionInPre
=
5
;
// about 20s
/// helpers
auto
event_inspection
(
auto
e
,
std
::
map
<
const
std
::
string
,
int
>
&
m
){
auto
event_inspection
(
auto
e
,
std
::
map
<
std
::
string
,
int
>
&
m
){
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
spdlog
::
info
(
"type is people: {}"
,
++
m
[
kKeyP
]);
}
else
if
(
std
::
is_same
<
decltype
(
e
),
motion
>::
value
){
...
...
@@ -109,6 +107,38 @@ namespace md{
inline
auto
operator
()()
noexcept
{
using
namespace
sml
;
=======
}
else
if
(
std
::
is_same
<
decltype
(
e
),
none
>::
value
){
spdlog
::
info
(
"type is none: {}"
,
++
m
[
kKeyN
]);
}
}
auto
make_guard_fn
(
const
std
::
map
<
std
::
string
,
int
>
&
konst
){
return
[
&
konst
](
auto
e
){
static
std
::
map
<
std
::
string
,
int
>
guards
=
{{
"m"
,
0
},
{
"p"
,
0
},
{
"n"
,
0
}};
event_inspection
(
e
,
guards
);
if
(
guards
[
kKeyM
]
!=
0
&&
guards
[
kKeyP
]
!=
0
){
guards
[
kKeyM
]
=
guards
[
kKeyP
]
=
guards
[
kKeyN
]
=
0
;
return
false
;
}
else
if
(
guards
[
kKeyP
]
>=
konst
[
kKeyP
]){
guards
[
kKeyP
]
=
guards
[
kKeyN
]
=
0
;
return
true
;
}
else
if
(
guards
[
kKeyM
]
>=
konst
[
kKeyM
]){
guards
[
kKeyM
]
=
guards
[
kKeyN
]
=
0
;
return
true
;
}
else
if
(
guards
[
kKeyN
]
>=
konst
[
kKeyN
]){
guards
[
kKeyN
]
=
0
;
return
true
;
}
return
false
;
};
}
struct
fsm
{
auto
operator
()()
const
noexcept
{
using
namespace
sml
;
const
auto
guard_in2post
=
make_guard_fn
(
kNumIn2Post
);
const
auto
guard_post2none
=
make_guard_fn
(
kNumPost2None
);
return
make_transition_table
(
*
"init"
_s
=
"none"
_s
,
"none"
_s
+
event
<
none
>/
[]{
spdlog
::
info
(
"none -> none"
);}
=
"none"
_s
,
...
...
hi3518/smart.cc
浏览文件 @
5e950222
...
...
@@ -173,6 +173,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
extern
atomic
<
uint64_t
>
frameCntTotal
;
uint64_t
frameCntLast
=
frameCntTotal
.
load
(
memory_order_relaxed
);
uint64_t
motionCntLast
=
gMotionCounter
.
load
(
memory_order_relaxed
);
<<<<<<<
HEAD
const
float
kMotionPerSecondThresh
=
2.5
;
const
int
kMotionDetectWindowSeconds
=
4
;
const
float
kMsPerMotion
=
1000.0
/
kMotionPerSecondThresh
;
...
...
@@ -180,6 +181,15 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
int
windowSecs
=
kMotionDetectWindowSeconds
;
ev_region_t
last_region
=
{
0
};
sml
::
sm
<
md
::
fsm
>
fsm
{
md
::
fsm
{}};
=======
const
int
kMotionPerSecondThresh
=
3
;
const
int
kMotionDetectWindowSeconds
=
4
;
const
float
kMsPerMotion
=
kMotionDetectWindowSeconds
*
1000.0
/
kMotionPerSecondThresh
;
int
state
=
0
;
int
windowSecs
=
kMotionDetectWindowSeconds
;
ev_region_t
last_region
=
{
0
};
sml
::
sm
<
md
::
fsm
>
fsm
;
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
bool
hasHuman
=
false
;
bool
hasMotion
=
false
;
while
(
1
)
{
...
...
@@ -197,7 +207,11 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
}
if
(
stMaQueSmartTarget
.
targetFDNum
>
0
)
{
hasHuman
=
true
;
<<<<<<<
HEAD
//last_region = {stMaQueSmartTarget.aFDRect[0].s16X1, stMaQueSmartTarget.aFDRect[0].s16Y1, stMaQueSmartTarget.aFDRect[0].s16X2, stMaQueSmartTarget.aFDRect[0].s16Y2};
=======
last_region
=
{
stMaQueSmartTarget
.
aFDRect
[
0
].
s16X1
,
stMaQueSmartTarget
.
aFDRect
[
0
].
s16Y1
,
stMaQueSmartTarget
.
aFDRect
[
0
].
s16X2
,
stMaQueSmartTarget
.
aFDRect
[
0
].
s16Y2
};
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
}
if
(
windowSecs
>
0
)
{
windowSecs
--
;
...
...
@@ -207,13 +221,17 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
auto
motionCnt_
=
gMotionCounter
.
load
(
memory_order_relaxed
);
float
deltaTimeMs
=
(
frameCntTotal_
-
frameCntLast
)
*
1000
/
pArg
->
module
.
sys
.
fps
;
<<<<<<<
HEAD
spdlog
::
info
(
"deltaTimeMs {}"
,
deltaTimeMs
);
=======
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
frameCntLast
=
frameCntTotal_
;
int
motionCntThresh
=
deltaTimeMs
/
kMsPerMotion
;
int
deltaMotionCnt
=
motionCnt_
-
motionCntLast
;
motionCntLast
=
motionCnt_
;
if
(
deltaMotionCnt
>=
motionCntThresh
)
{
hasMotion
=
true
;
<<<<<<<
HEAD
}
if
(
hasMotion
&&
hasHuman
)
{
fsm
.
process_event
(
md
::
mpboth
{});
...
...
@@ -225,13 +243,26 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
fsm
.
process_event
(
md
::
people
{});
}
else
{
=======
}
if
(
hasMotion
&&
hasHuman
){
fsm
.
process_event
(
md
::
mpboth
{});
}
else
if
(
hasMotion
){
fsm
.
process_event
(
md
::
motion
{});
}
else
if
(
hasHuman
){
fsm
.
process_event
(
md
::
people
{});
}
else
{
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
fsm
.
process_event
(
md
::
none
{});
}
// reset
windowSecs
=
kMotionDetectWindowSeconds
;
hasHuman
=
false
;
hasMotion
=
false
;
<<<<<<<
HEAD
last_region
=
{
0
,
0
,
0
,
0
};
=======
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论