Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
6229c1f8
提交
6229c1f8
authored
9月 21, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
e302ec6b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
180 行增加
和
23 行删除
+180
-23
settings.json
.vscode/settings.json
+87
-1
fs_test.cpp
opencv-motion-detect/fs_test.cpp
+76
-0
common.hpp
opencv-motion-detect/inc/common.hpp
+0
-22
fs.h
opencv-motion-detect/inc/fs.h
+17
-0
没有找到文件。
.vscode/settings.json
浏览文件 @
6229c1f8
...
...
@@ -6,7 +6,92 @@
"optional"
:
"cpp"
,
"string"
:
"cpp"
,
"set"
:
"cpp"
,
"thread"
:
"cpp"
"thread"
:
"cpp"
,
"filesystem"
:
"cpp"
,
"__config"
:
"cpp"
,
"iosfwd"
:
"cpp"
,
"__bit_reference"
:
"cpp"
,
"__debug"
:
"cpp"
,
"__errc"
:
"cpp"
,
"__functional_base"
:
"cpp"
,
"__hash_table"
:
"cpp"
,
"__locale"
:
"cpp"
,
"__mutex_base"
:
"cpp"
,
"__node_handle"
:
"cpp"
,
"__nullptr"
:
"cpp"
,
"__split_buffer"
:
"cpp"
,
"__string"
:
"cpp"
,
"__threading_support"
:
"cpp"
,
"__tree"
:
"cpp"
,
"__tuple"
:
"cpp"
,
"algorithm"
:
"cpp"
,
"array"
:
"cpp"
,
"atomic"
:
"cpp"
,
"bitset"
:
"cpp"
,
"cctype"
:
"cpp"
,
"cinttypes"
:
"cpp"
,
"clocale"
:
"cpp"
,
"cmath"
:
"cpp"
,
"codecvt"
:
"cpp"
,
"complex"
:
"cpp"
,
"condition_variable"
:
"cpp"
,
"cstdarg"
:
"cpp"
,
"cstddef"
:
"cpp"
,
"cstdint"
:
"cpp"
,
"cstdio"
:
"cpp"
,
"cstdlib"
:
"cpp"
,
"cstring"
:
"cpp"
,
"ctime"
:
"cpp"
,
"cwchar"
:
"cpp"
,
"cwctype"
:
"cpp"
,
"deque"
:
"cpp"
,
"exception"
:
"cpp"
,
"coroutine"
:
"cpp"
,
"forward_list"
:
"cpp"
,
"fstream"
:
"cpp"
,
"functional"
:
"cpp"
,
"future"
:
"cpp"
,
"initializer_list"
:
"cpp"
,
"iomanip"
:
"cpp"
,
"ios"
:
"cpp"
,
"iostream"
:
"cpp"
,
"istream"
:
"cpp"
,
"iterator"
:
"cpp"
,
"limits"
:
"cpp"
,
"list"
:
"cpp"
,
"locale"
:
"cpp"
,
"map"
:
"cpp"
,
"memory"
:
"cpp"
,
"mutex"
:
"cpp"
,
"new"
:
"cpp"
,
"numeric"
:
"cpp"
,
"ostream"
:
"cpp"
,
"queue"
:
"cpp"
,
"random"
:
"cpp"
,
"ratio"
:
"cpp"
,
"regex"
:
"cpp"
,
"shared_mutex"
:
"cpp"
,
"sstream"
:
"cpp"
,
"stack"
:
"cpp"
,
"stdexcept"
:
"cpp"
,
"streambuf"
:
"cpp"
,
"string_view"
:
"cpp"
,
"strstream"
:
"cpp"
,
"system_error"
:
"cpp"
,
"tuple"
:
"cpp"
,
"type_traits"
:
"cpp"
,
"typeindex"
:
"cpp"
,
"typeinfo"
:
"cpp"
,
"unordered_map"
:
"cpp"
,
"unordered_set"
:
"cpp"
,
"utility"
:
"cpp"
,
"valarray"
:
"cpp"
,
"vector"
:
"cpp"
,
"hash_map"
:
"cpp"
,
"hash_set"
:
"cpp"
,
"bit"
:
"cpp"
,
"*.tcc"
:
"cpp"
,
"memory_resource"
:
"cpp"
},
"C_Cpp.errorSquiggles"
:
"Disabled"
}
\ No newline at end of file
opencv-motion-detect/fs_test.cpp
0 → 100644
浏览文件 @
6229c1f8
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include "inc/fs.h"
#include "inc/spdlog/spdlog.h"
using
namespace
std
;
int
test_last_write_time
(){
fs
::
path
p
=
fs
::
current_path
()
/
"example.bin"
;
std
::
ofstream
(
p
.
c_str
()).
put
(
'a'
);
// create file
auto
ftime
=
fs
::
last_write_time
(
p
);
// assuming system_clock for this demo
// note: not true on MSVC or GCC 9; C++20 will allow portable output
std
::
time_t
cftime
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
std
::
cout
<<
"File write time is "
<<
std
::
asctime
(
std
::
localtime
(
&
cftime
))
<<
'\n'
;
fs
::
last_write_time
(
p
,
ftime
+
1
h
);
// move file write time 1 hour to the future
ftime
=
fs
::
last_write_time
(
p
);
// read back from the filesystem
cftime
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
std
::
cout
<<
"File write time is "
<<
std
::
asctime
(
std
::
localtime
(
&
cftime
))
<<
'\n'
;
fs
::
remove
(
p
);
return
0
;
}
void
ftime2ctime
(
fs
::
file_time_type
ftime
){
std
::
time_t
cftime
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
std
::
cout
<<
"
\t\t
wt: "
<<
std
::
asctime
(
std
::
localtime
(
&
cftime
))
<<
std
::
endl
;
}
int
LoadVideoFiles
(
string
path
,
map
<
long
,
string
>
&
ts2fileName
,
list
<
long
>
&
tsRing
)
{
int
ret
=
0
;
try
{
for
(
const
auto
&
entry
:
fs
::
directory_iterator
(
path
))
{
if
(
entry
.
file_size
()
==
0
||
!
entry
.
is_regular_file
())
{
spdlog
::
warn
(
"LoasdVideoFiles skipped {} (empty or directory)"
,
entry
.
path
().
c_str
());
}
auto
ftime
=
fs
::
last_write_time
(
entry
.
path
());
auto
ts
=
decltype
(
ftime
)
::
clock
::
to_time_t
(
ftime
);
spdlog
::
debug
(
"ts: {}, file: {}"
,
ts
,
entry
.
path
().
c_str
());
if
(
ts2fileName
.
count
(
ts
)
!=
0
)
{
spdlog
::
warn
(
"LoasdVideoFiles multiple files with same timestamp: {}, {}(skipped), "
,
ts2fileName
[
ts
],
entry
.
path
().
c_str
());
continue
;
}
tsRing
.
insert
(
std
::
lower_bound
(
tsRing
.
begin
(),
tsRing
.
end
(),
ts
),
ts
);
ts2fileName
[
ts
]
=
entry
.
path
();
}
// for(auto &i: tsRing) {
// spdlog::debug("ts: {}, file: {}", i, ts2fileName[i]);
// }
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"LoasdVideoFiles exception : {}"
,
e
.
what
());
ret
=
-
1
;
}
return
ret
;
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
std
::
string
path
=
argv
[
1
];
list
<
long
>
tsRing
;
map
<
long
,
string
>
ts2fileName
;
LoadVideoFiles
(
path
,
ts2fileName
,
tsRing
);
return
0
;
}
\ No newline at end of file
opencv-motion-detect/inc/common.hpp
浏览文件 @
6229c1f8
...
...
@@ -13,26 +13,4 @@ update: 2019/08/23
#include "utils.hpp"
#include "av_common.hpp"
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
#if __has_include(<filesystem>)
#define GHC_USE_STD_FS
#include <filesystem>
namespace
fs
{
using
namespace
std
::
filesystem
;
using
ifstream
=
std
::
ifstream
;
using
ofstream
=
std
::
ofstream
;
using
fstream
=
std
::
fstream
;
}
#endif
#endif
#ifndef GHC_USE_STD_FS
#include "ghc/fs_fwd.hpp"
namespace
fs
{
using
namespace
ghc
::
filesystem
;
using
ifstream
=
ghc
::
filesystem
::
ifstream
;
using
ofstream
=
ghc
::
filesystem
::
ofstream
;
using
fstream
=
ghc
::
filesystem
::
fstream
;
}
#endif
#endif
opencv-motion-detect/inc/fs.h
0 → 100644
浏览文件 @
6229c1f8
#ifndef __EV_FS_H__
#define __EV_FS_H__
// #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
// #if __has_include(<filesystem>)
// #define GHC_USE_STD_FS
// #include <filesystem>
// namespace fs = std::filesystem;
// #endif
// #endif
// #ifndef GHC_USE_STD_FS
#include <ghc/filesystem.hpp>
namespace
fs
=
ghc
::
filesystem
;
// #endif
#endif
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论