Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evcamera
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evcamera
Commits
0b173acb
提交
0b173acb
authored
5月 27, 2020
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
video upload prototype
上级
5e950222
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
46 行增加
和
94 行删除
+46
-94
.DS_Store
.DS_Store
+0
-0
video_file_request.md
docs/video_file_request.md
+4
-0
video_upload_stream.md
docs/video_upload_stream.md
+1
-1
main.cc
hi3518/main.cc
+0
-0
motiondetect.hpp
hi3518/motiondetect.hpp
+37
-59
smart.cc
hi3518/smart.cc
+2
-34
CMakeLists.txt
server/CMakeLists.txt
+2
-0
没有找到文件。
.DS_Store
浏览文件 @
0b173acb
No preview for this file type
docs/video_file_request.md
浏览文件 @
0b173acb
...
@@ -79,3 +79,7 @@ payload: {
...
@@ -79,3 +79,7 @@ payload: {
```json
{ "time":1567669674, "cmd":"upload_video", "rid":"001231554A20", "data":{ "start":1590542800, "end":1590542900, "type":6 } }
```
docs/video_upload_stream.md
浏览文件 @
0b173acb
...
@@ -33,7 +33,7 @@ sequenceDiagram
...
@@ -33,7 +33,7 @@ sequenceDiagram
## 数据格式定义(DD)
## 数据格式定义(DD)
### STREAM_DATA_T:
大
端在前
### STREAM_DATA_T:
小
端在前
```
BNF
```
BNF
STREAM_DATA_T := MAGIC_HEAD, {PAYLOAD}-, MAGIC_TAIL # 总体定义
STREAM_DATA_T := MAGIC_HEAD, {PAYLOAD}-, MAGIC_TAIL # 总体定义
...
...
hi3518/main.cc
浏览文件 @
0b173acb
差异被折叠。
点击展开。
hi3518/motiondetect.hpp
浏览文件 @
0b173acb
...
@@ -22,8 +22,10 @@ namespace md{
...
@@ -22,8 +22,10 @@ namespace md{
const
string
kKeyM
=
"m"
;
const
string
kKeyM
=
"m"
;
const
string
kKeyN
=
"n"
;
const
string
kKeyN
=
"n"
;
const
string
kKeyP
=
"p"
;
const
string
kKeyP
=
"p"
;
const
int
kMaxCntMotionInPre
=
5
;
// about 20s
/// helpers
/// helpers
auto
event_inspection
(
auto
e
,
std
::
map
<
std
::
string
,
int
>
&
m
){
auto
event_inspection
(
auto
e
,
std
::
map
<
const
std
::
string
,
int
>
&
m
){
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
spdlog
::
info
(
"type is people: {}"
,
++
m
[
kKeyP
]);
spdlog
::
info
(
"type is people: {}"
,
++
m
[
kKeyP
]);
}
else
if
(
std
::
is_same
<
decltype
(
e
),
motion
>::
value
){
}
else
if
(
std
::
is_same
<
decltype
(
e
),
motion
>::
value
){
...
@@ -37,9 +39,9 @@ namespace md{
...
@@ -37,9 +39,9 @@ namespace md{
return
false
;
return
false
;
}
}
auto
make_guard_fn
(
const
std
::
map
<
const
std
::
string
,
int
>
&
konst
){
auto
make_guard_fn
(
const
std
::
map
<
const
std
::
string
,
int
>
&
konst
,
std
::
map
<
const
std
::
string
,
int
>
&
guards
){
return
[
&
konst
](
auto
e
){
return
[
&
konst
,
&
guards
](
auto
e
){
static
std
::
map
<
const
std
::
string
,
int
>
guards
=
{{
"m"
,
0
},
{
"p"
,
0
},
{
"n"
,
0
}};
//
static std::map<const std::string, int>guards = {{"m", 0}, {"p", 0}, {"n", 0}};
bool
trans
=
false
;
bool
trans
=
false
;
bool
reset
=
true
;
bool
reset
=
true
;
if
(
event_inspection
(
e
,
guards
)
||
(
guards
[
kKeyM
]
!=
0
&&
guards
[
kKeyP
]
!=
0
)){
if
(
event_inspection
(
e
,
guards
)
||
(
guards
[
kKeyM
]
!=
0
&&
guards
[
kKeyP
]
!=
0
)){
...
@@ -63,30 +65,34 @@ namespace md{
...
@@ -63,30 +65,34 @@ namespace md{
};
};
}
}
typedef
bool
(
*
fn_guard_t
)(
auto
e
);
struct
fsm
{
struct
fsm
{
const
fn_guard_t
guard_in2post
=
make_guard_fn
(
kNumIn2Post
);
auto
operator
()()
noexcept
{
const
bool
guard_post2none
=
make_guard_fn
(
kNumPost2None
);
const
auto
guard_in2post
=
make_guard_fn
(
kNumIn2Post
,
guards
);
const
void
action_none2in
=
[
this
](
auto
e
){
const
auto
guard_post2none
=
make_guard_fn
(
kNumPost2None
,
guards
);
this
->
timeStart
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
const
auto
action_none2in
=
[
this
](
auto
e
){
hasMotion
=
false
;
timeStart
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
spdlog
::
info
(
"none -p-> in, {}"
,
this
->
timeStart
/
1000
);
spdlog
::
info
(
"none -p-> in, {}"
,
timeStart
/
1000
);
}
else
if
(
std
::
is_same
<
decltype
(
e
),
mpboth
>::
value
){
}
else
if
(
std
::
is_same
<
decltype
(
e
),
mpboth
>::
value
){
spdlog
::
info
(
"none -b-> in, {}"
,
this
->
timeStart
/
1000
);
spdlog
::
info
(
"none -b-> in, {}"
,
timeStart
/
1000
);
this
->
hasMotion
=
true
;
hasMotion
=
true
;
}
}
/// TODO: force event generation when max time duration reached
};
};
const
void
action_pre2in
=
[
this
](
auto
e
){
const
auto
action_pre2in
=
[
this
](
auto
e
){
if
(
this
->
timeStart
==
0
)
if
(
timeStart
==
0
)
this
->
timeStart
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
timeStart
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
spdlog
::
info
(
"pre -p-> in: time {}"
,
this
->
timeStart
/
1000
);
spdlog
::
info
(
"pre -p-> in: time {}"
,
timeStart
/
1000
);
}
else
if
(
std
::
is_same
<
decltype
(
e
),
mpboth
>::
value
){
}
else
if
(
std
::
is_same
<
decltype
(
e
),
mpboth
>::
value
){
spdlog
::
info
(
"pre -b-> in: time {}"
,
this
->
timeStart
/
1000
);
spdlog
::
info
(
"pre -b-> in: time {}"
,
timeStart
/
1000
);
}
}
this
->
hasMotion
=
true
;
hasMotion
=
true
;
};
};
const
void
action_post2none
=
[
this
](
auto
e
){
const
auto
action_post2none
=
[
this
](
auto
e
){
auto
timeEnd
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
auto
timeEnd
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
if
(
std
::
is_same
<
decltype
(
e
),
people
>::
value
){
spdlog
::
info
(
"post -p-> none, {}"
,
timeEnd
/
1000
);
spdlog
::
info
(
"post -p-> none, {}"
,
timeEnd
/
1000
);
...
@@ -95,50 +101,20 @@ namespace md{
...
@@ -95,50 +101,20 @@ namespace md{
}
else
if
(
std
::
is_same
<
decltype
(
e
),
none
>::
value
){
}
else
if
(
std
::
is_same
<
decltype
(
e
),
none
>::
value
){
spdlog
::
info
(
"post -n-> none, {}"
,
timeEnd
/
1000
);
spdlog
::
info
(
"post -n-> none, {}"
,
timeEnd
/
1000
);
}
}
/// TODO: force event generation when max time duration reached
spdlog
::
info
(
"event start:{}, end:{}, hasMotion: {}"
,
timeStart
,
timeEnd
,
hasMotion
);
/// TODO: generate event for uploading
};
};
const
void
action_pre2pre
=
[
this
](
auto
e
){
const
auto
action_pre2pre
=
[
this
](
auto
e
){
static
int
cntMotionOnly
=
0
;
cntMotionOnly
++
;
cntMotionOnly
++
;
if
(
cntMotionOnly
>=
kMaxCntMotionInPre
)
{
if
(
cntMotionOnly
>=
kMaxCntMotionInPre
)
{
cntMotionOnly
=
0
;
cntMotionOnly
=
0
;
this
->
timeStart
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
timeStart
=
chrono
::
duration_cast
<
chrono
::
milliseconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
}
};
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
;
using
namespace
sml
;
const
auto
guard_in2post
=
make_guard_fn
(
kNumIn2Post
);
const
auto
guard_post2none
=
make_guard_fn
(
kNumPost2None
);
return
make_transition_table
(
return
make_transition_table
(
*
"init"
_s
=
"none"
_s
,
*
"init"
_s
=
"none"
_s
,
"none"
_s
+
event
<
none
>/
[]{
spdlog
::
info
(
"none -> none"
);}
=
"none"
_s
,
"none"
_s
+
event
<
none
>/
[]{
spdlog
::
info
(
"none -> none"
);}
=
"none"
_s
,
...
@@ -163,9 +139,11 @@ namespace md{
...
@@ -163,9 +139,11 @@ namespace md{
"none"
_s
+
sml
::
on_entry
<
_
>
/
[
this
]{
hasMotion
=
false
,
timeStart
=
0
;}
"none"
_s
+
sml
::
on_entry
<
_
>
/
[
this
]{
hasMotion
=
false
,
timeStart
=
0
;}
);
);
}
}
public
:
private
:
bool
hasMotion
=
false
;
bool
hasMotion
{
false
};
uint64_t
timeStart
=
0
;
int
cntMotionOnly
=
0
;
uint64_t
timeStart
{
0
};
std
::
map
<
const
std
::
string
,
int
>
guards
{{
"m"
,
0
},
{
"p"
,
0
},
{
"n"
,
0
}};
};
};
}
}
...
...
hi3518/smart.cc
浏览文件 @
0b173acb
...
@@ -40,7 +40,6 @@ XM_S32 MaQue_JpegEnc_getFrame_callback (XM_VOID *pUserArg, MaQueSmartJpegFrame_s
...
@@ -40,7 +40,6 @@ XM_S32 MaQue_JpegEnc_getFrame_callback (XM_VOID *pUserArg, MaQueSmartJpegFrame_s
}
}
void
maq_smart_task_entry
(
ev_module_config_t
*
pArg
)
void
maq_smart_task_entry
(
ev_module_config_t
*
pArg
)
{
{
if
(
!
pArg
->
module
.
ai
.
enabled
)
{
if
(
!
pArg
->
module
.
ai
.
enabled
)
{
...
@@ -173,7 +172,6 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
...
@@ -173,7 +172,6 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
extern
atomic
<
uint64_t
>
frameCntTotal
;
extern
atomic
<
uint64_t
>
frameCntTotal
;
uint64_t
frameCntLast
=
frameCntTotal
.
load
(
memory_order_relaxed
);
uint64_t
frameCntLast
=
frameCntTotal
.
load
(
memory_order_relaxed
);
uint64_t
motionCntLast
=
gMotionCounter
.
load
(
memory_order_relaxed
);
uint64_t
motionCntLast
=
gMotionCounter
.
load
(
memory_order_relaxed
);
<<<<<<<
HEAD
const
float
kMotionPerSecondThresh
=
2.5
;
const
float
kMotionPerSecondThresh
=
2.5
;
const
int
kMotionDetectWindowSeconds
=
4
;
const
int
kMotionDetectWindowSeconds
=
4
;
const
float
kMsPerMotion
=
1000.0
/
kMotionPerSecondThresh
;
const
float
kMsPerMotion
=
1000.0
/
kMotionPerSecondThresh
;
...
@@ -181,15 +179,6 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
...
@@ -181,15 +179,6 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
int
windowSecs
=
kMotionDetectWindowSeconds
;
int
windowSecs
=
kMotionDetectWindowSeconds
;
ev_region_t
last_region
=
{
0
};
ev_region_t
last_region
=
{
0
};
sml
::
sm
<
md
::
fsm
>
fsm
{
md
::
fsm
{}};
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
hasHuman
=
false
;
bool
hasMotion
=
false
;
bool
hasMotion
=
false
;
while
(
1
)
{
while
(
1
)
{
...
@@ -207,11 +196,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
...
@@ -207,11 +196,7 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
}
}
if
(
stMaQueSmartTarget
.
targetFDNum
>
0
)
{
if
(
stMaQueSmartTarget
.
targetFDNum
>
0
)
{
hasHuman
=
true
;
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};
=======
last_region
=
{
stMaQueSmartTarget
.
aFDRect
[
0
].
s16X1
,
stMaQueSmartTarget
.
aFDRect
[
0
].
s16Y1
,
stMaQueSmartTarget
.
aFDRect
[
0
].
s16X2
,
stMaQueSmartTarget
.
aFDRect
[
0
].
s16Y2
};
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
}
}
if
(
windowSecs
>
0
)
{
if
(
windowSecs
>
0
)
{
windowSecs
--
;
windowSecs
--
;
...
@@ -219,19 +204,15 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
...
@@ -219,19 +204,15 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
else
{
else
{
auto
frameCntTotal_
=
frameCntTotal
.
load
(
memory_order_relaxed
);
auto
frameCntTotal_
=
frameCntTotal
.
load
(
memory_order_relaxed
);
auto
motionCnt_
=
gMotionCounter
.
load
(
memory_order_relaxed
);
auto
motionCnt_
=
gMotionCounter
.
load
(
memory_order_relaxed
);
float
deltaTimeMs
=
(
frameCntTotal_
-
frameCntLast
)
*
1000
/
pArg
->
module
.
sys
.
fps
;
float
deltaTimeMs
=
(
frameCntTotal_
-
frameCntLast
)
*
1000
/
pArg
->
module
.
sys
.
fps
;
<<<<<<<
HEAD
spdlog
::
info
(
"deltaTimeMs {}"
,
deltaTimeMs
);
=======
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
frameCntLast
=
frameCntTotal_
;
frameCntLast
=
frameCntTotal_
;
int
motionCntThresh
=
deltaTimeMs
/
kMsPerMotion
;
int
motionCntThresh
=
deltaTimeMs
/
kMsPerMotion
;
int
deltaMotionCnt
=
motionCnt_
-
motionCntLast
;
int
deltaMotionCnt
=
motionCnt_
-
motionCntLast
;
motionCntLast
=
motionCnt_
;
motionCntLast
=
motionCnt_
;
spdlog
::
info
(
"deltaTimeMs {}"
,
deltaTimeMs
);
if
(
deltaMotionCnt
>=
motionCntThresh
)
{
if
(
deltaMotionCnt
>=
motionCntThresh
)
{
hasMotion
=
true
;
hasMotion
=
true
;
<<<<<<<
HEAD
}
}
if
(
hasMotion
&&
hasHuman
)
{
if
(
hasMotion
&&
hasHuman
)
{
fsm
.
process_event
(
md
::
mpboth
{});
fsm
.
process_event
(
md
::
mpboth
{});
...
@@ -243,26 +224,13 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
...
@@ -243,26 +224,13 @@ void maq_smart_task_entry(ev_module_config_t *pArg)
fsm
.
process_event
(
md
::
people
{});
fsm
.
process_event
(
md
::
people
{});
}
}
else
{
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
{});
fsm
.
process_event
(
md
::
none
{});
}
}
// reset
// reset
windowSecs
=
kMotionDetectWindowSeconds
;
windowSecs
=
kMotionDetectWindowSeconds
;
hasHuman
=
false
;
hasHuman
=
false
;
hasMotion
=
false
;
hasMotion
=
false
;
<<<<<<<
HEAD
last_region
=
{
0
,
0
,
0
,
0
};
last_region
=
{
0
,
0
,
0
,
0
};
=======
>>>>>>>
5
b92158f6b6f54d698af4a1f24b2fcd7b03b5f5d
}
}
}
}
...
...
server/CMakeLists.txt
浏览文件 @
0b173acb
...
@@ -18,6 +18,8 @@ link_directories(${COMMON_LIB_DIR})
...
@@ -18,6 +18,8 @@ link_directories(${COMMON_LIB_DIR})
add_executable
(
vgw videogateway.cc
)
add_executable
(
vgw videogateway.cc
)
target_link_libraries
(
vgw PUBLIC
${
VGW_LIBS
}
${
COMM_LIBS
}
)
target_link_libraries
(
vgw PUBLIC
${
VGW_LIBS
}
${
COMM_LIBS
}
)
add_executable
(
test_curl test_curl.cc
)
target_link_libraries
(
vgw curl}
)
# add_executable(test_mqtt test_mqtt_rd.cc)
# add_executable(test_mqtt test_mqtt_rd.cc)
# target_link_libraries(test_mqtt PUBLIC ${COMM_LIBS})
# target_link_libraries(test_mqtt PUBLIC ${COMM_LIBS})
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论