Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
5391e33d
提交
5391e33d
authored
9月 23, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
fdcf06ff
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
13 行删除
+17
-13
fs_test.cpp
opencv-motion-detect/fs_test.cpp
+17
-13
没有找到文件。
opencv-motion-detect/fs_test.cpp
浏览文件 @
5391e33d
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
using
namespace
std
;
using
namespace
std
;
int
test_last_write_time
(){
int
test_last_write_time
()
{
fs
::
path
p
=
fs
::
current_path
()
/
"example.bin"
;
fs
::
path
p
=
fs
::
current_path
()
/
"example.bin"
;
std
::
ofstream
(
p
.
c_str
()).
put
(
'a'
);
// create file
std
::
ofstream
(
p
.
c_str
()).
put
(
'a'
);
// create file
auto
ftime
=
fs
::
last_write_time
(
p
);
auto
ftime
=
fs
::
last_write_time
(
p
);
...
@@ -29,19 +30,20 @@ int test_last_write_time(){
...
@@ -29,19 +30,20 @@ int test_last_write_time(){
return
0
;
return
0
;
}
}
void
ftime2ctime
(
fs
::
file_time_type
ftime
){
void
ftime2ctime
(
fs
::
file_time_type
ftime
)
{
std
::
time_t
cftime
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
std
::
time_t
cftime
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
std
::
cout
<<
"
\t\t
wt: "
<<
std
::
asctime
(
std
::
localtime
(
&
cftime
))
<<
std
::
endl
;
std
::
cout
<<
"
\t\t
wt: "
<<
std
::
asctime
(
std
::
localtime
(
&
cftime
))
<<
std
::
endl
;
}
}
vector
<
long
>
LoadVideoFiles
(
string
path
,
int
days
,
map
<
long
,
string
>
&
ts2fileName
,
list
<
long
>
&
tsRing
,
list
<
long
>
&
tsNeedProc
)
{
vector
<
long
>
LoadVideoFiles
(
string
path
,
int
days
,
map
<
long
,
string
>
&
ts2fileName
,
list
<
long
>
&
tsRing
,
list
<
long
>
&
tsNeedProc
)
{
vector
<
long
>
v
;
vector
<
long
>
v
;
// get current timestamp
// get current timestamp
auto
now
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
auto
now
=
chrono
::
duration_cast
<
chrono
::
seconds
>
(
chrono
::
system_clock
::
now
().
time_since_epoch
()).
count
();
try
{
try
{
for
(
const
auto
&
entry
:
fs
::
directory_iterator
(
path
))
for
(
const
auto
&
entry
:
fs
::
directory_iterator
(
path
))
{
{
if
(
entry
.
file_size
()
==
0
||
!
entry
.
is_regular_file
()
||
entry
.
path
().
extension
()
!=
".mp4"
)
{
if
(
entry
.
file_size
()
==
0
||
!
entry
.
is_regular_file
()
||
entry
.
path
().
extension
()
!=
".mp4"
)
{
spdlog
::
warn
(
"LoasdVideoFiles skipped {} (empty/directory/!mp4)"
,
entry
.
path
().
c_str
());
spdlog
::
warn
(
"LoasdVideoFiles skipped {} (empty/directory/!mp4)"
,
entry
.
path
().
c_str
());
continue
;
continue
;
...
@@ -49,38 +51,40 @@ vector<long> LoadVideoFiles(string path, int days, map<long, string> &ts2fileNam
...
@@ -49,38 +51,40 @@ vector<long> LoadVideoFiles(string path, int days, map<long, string> &ts2fileNam
auto
ftime
=
fs
::
last_write_time
(
entry
.
path
());
auto
ftime
=
fs
::
last_write_time
(
entry
.
path
());
auto
ts
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
auto
ts
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
// check i
t was
processed already
// check i
f
processed already
if
(
ts2fileName
.
count
(
ts
)
!=
0
)
{
if
(
ts2fileName
.
count
(
ts
)
!=
0
)
{
spdlog
::
warn
(
"LoasdVideoFiles multiple files with same timestamp: {}, {}(skipped), "
,
ts2fileName
[
ts
],
entry
.
path
().
c_str
());
spdlog
::
warn
(
"LoasdVideoFiles multiple files with same timestamp: {}, {}(skipped), "
,
ts2fileName
[
ts
],
entry
.
path
().
c_str
());
continue
;
continue
;
}
}
// check
it was
old files
// check old files
if
(
ts
-
now
>
days
*
24
*
60
*
60
)
{
if
(
ts
-
now
>
days
*
24
*
60
*
60
)
{
spdlog
::
info
(
"file {} old that {} days"
,
entry
.
path
().
c_str
(),
days
);
spdlog
::
info
(
"file {} old that {} days"
,
entry
.
path
().
c_str
(),
days
);
tsNeedProc
.
push_back
(
ts
);
tsNeedProc
.
push_back
(
ts
);
}
}
else
{
else
{
tsRing
.
insert
(
std
::
lower_bound
(
tsRing
.
begin
(),
tsRing
.
end
(),
ts
),
ts
);
tsRing
.
insert
(
std
::
lower_bound
(
tsRing
.
begin
(),
tsRing
.
end
(),
ts
),
ts
);
}
}
// add to map
// add to map
ts2fileName
[
ts
]
=
entry
.
path
();
ts2fileName
[
ts
]
=
entry
.
path
();
}
}
}
catch
(
exception
&
e
)
{
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"LoasdVideoFiles exception : {}"
,
e
.
what
());
spdlog
::
error
(
"LoasdVideoFiles exception : {}"
,
e
.
what
());
}
}
return
v
;
return
v
;
}
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
int
main
(
int
argc
,
const
char
*
argv
[])
{
std
::
string
path
=
argv
[
1
];
std
::
string
path
=
argv
[
1
];
list
<
long
>
tsRing
;
list
<
long
>
tsRing
;
list
<
long
>
tsProcess
;
list
<
long
>
tsProcess
;
map
<
long
,
string
>
ts2fileName
;
map
<
long
,
string
>
ts2fileName
;
LoadVideoFiles
(
path
,
2
,
ts2fileName
,
tsRing
,
tsProcess
);
LoadVideoFiles
(
path
,
2
,
ts2fileName
,
tsRing
,
tsProcess
);
for
(
auto
&
i
:
tsRing
)
{
for
(
auto
&
i
:
tsRing
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论