Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
3b44a61e
提交
3b44a61e
authored
9月 19, 2019
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
big refacting of communitation architect
上级
7f32fb3f
全部展开
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
499 行增加
和
187 行删除
+499
-187
Makefile
opencv-motion-detect/Makefile
+19
-17
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+0
-5
common.hpp
opencv-motion-detect/inc/common.hpp
+22
-0
filesystem.hpp
opencv-motion-detect/inc/ghc/filesystem.hpp
+0
-0
fs_fwd.hpp
opencv-motion-detect/inc/ghc/fs_fwd.hpp
+46
-0
fs_impl.hpp
opencv-motion-detect/inc/ghc/fs_impl.hpp
+43
-0
fs_std.hpp
opencv-motion-detect/inc/ghc/fs_std.hpp
+64
-0
fs_std_fwd.hpp
opencv-motion-detect/inc/ghc/fs_std_fwd.hpp
+68
-0
fs_std_impl.hpp
opencv-motion-detect/inc/ghc/fs_std_impl.hpp
+51
-0
zmqhelper.cpp
opencv-motion-detect/inc/zmqhelper.cpp
+177
-0
zmqhelper.hpp
opencv-motion-detect/inc/zmqhelper.hpp
+9
-165
没有找到文件。
opencv-motion-detect/Makefile
浏览文件 @
3b44a61e
...
...
@@ -7,7 +7,7 @@ CFLAGS = $(DEBUG) -Wall
LIBOPENCV
=
`
pkg-config opencv
--cflags
--libs
`
LIBFFMPEG
=
`
pkg-config libavformat libavutil libavcodec libswscale
--cflags
--libs
`
LIBS
=
-Lvendor
/lib
-lpthread
-lleveldb
LIBS
=
-Lvendor
/lib
-lpthread
-lleveldb
-ldl
-lm
-latomic
#-static
HEADERS
=
-Iinc
-Ivendor
/include
...
...
@@ -23,29 +23,31 @@ sqlite3.o: vendor/sqlite/sqlite3.c
gcc
-D
SQLITE_THREADSAFE
=
1
-c
vendor/sqlite/sqlite3.c
objs/database.o
:
database.cpp inc/database.h
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-c
database.cpp
-o
objs/database.o
$(HEADERS)
objs/zmqhelper.o
:
inc/zmqhelper.cpp inc/zmqhelper.hpp
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-c
inc/zmqhelper.cpp
-o
objs/zmqhelper.o
$(HEADERS)
evmgr
:
evmgr.cpp database.cpp inc/utils.hpp inc/common.hpp objs/database.o
inc/zmqhelper.hpp
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evmgr evmgr.cpp
$(SQLITE)
objs/database.o
$(HEADERS)
$(LIBFFMPEG)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evmgr
:
evmgr.cpp database.cpp inc/utils.hpp inc/common.hpp objs/database.o
objs/zmqhelper.o
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evmgr evmgr.cpp
$(SQLITE)
objs/database.o
objs/zmqhelper.o
$(HEADERS)
$(LIBFFMPEG)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evpuller
:
evpuller.cpp database.cpp inc/av_common.hpp inc/utils.hpp inc/common.hpp objs/database.o
inc/zmqhelper.hpp
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evpuller evpuller.cpp
$(SQLITE)
objs/database.o
$(HEADERS)
$(LIBFFMPEG)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evpuller
:
evpuller.cpp database.cpp inc/av_common.hpp inc/utils.hpp inc/common.hpp objs/database.o
objs/zmqhelper.o
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evpuller evpuller.cpp
$(SQLITE)
objs/database.o
objs/zmqhelper.o
$(HEADERS)
$(LIBFFMPEG)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evpusher
:
evpusher.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/tinythread.hpp objs/database.o
inc/zmqhelper.hpp
$(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evpusher evpusher.cpp objs/database.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evpusher
:
evpusher.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/tinythread.hpp objs/database.o
objs/zmqhelper.o
$(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evpusher evpusher.cpp objs/database.o
objs/zmqhelper.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evslicer
:
evslicer.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/tinythread.hpp objs/database.o
inc/zmqhelper.hpp
$(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evslicer evslicer.cpp objs/database.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evslicer
:
evslicer.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/tinythread.hpp objs/database.o
objs/zmqhelper.o
$(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evslicer evslicer.cpp objs/database.o
objs/zmqhelper.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evmlmotion
:
evmlmotion.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/avcvhelpers.hpp objs/database.o
inc/zmqhelper.hpp
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evmlmotion evmlmotion.cpp objs/database.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
$(LIBOPENCV)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evmlmotion_d
:
evmlmotion.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/avcvhelpers.hpp objs/database.o
inc/zmqhelper.hpp
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
-DDEBUG
$(LD_FLAGS)
-o
evmlmotion_d evmlmotion.cpp objs/database.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
$(LIBOPENCV)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evmlmotion
:
evmlmotion.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/avcvhelpers.hpp objs/database.o
objs/zmqhelper.o
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evmlmotion evmlmotion.cpp objs/database.o
objs/zmqhelper.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
$(LIBOPENCV)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evmlmotion_d
:
evmlmotion.cpp inc/common.hpp inc/av_common.hpp inc/utils.hpp inc/avcvhelpers.hpp objs/database.o
objs/zmqhelper.o
inc/tinythread.hpp $(SQLITE_SRC)
$(CPP)
$(CPPFLAGS)
-DDEBUG
$(LD_FLAGS)
-o
evmlmotion_d evmlmotion.cpp objs/database.o
objs/zmqhelper.o
$(SQLITE)
$(LIBFFMPEG)
$(HEADERS)
$(LIBOPENCV)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evdaemon
:
evdaemon.cpp inc/common.hpp inc/utils.hpp objs/database.o
inc/zmqhelper.hpp
inc/tinythread.hpp database.cpp
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evdaemon evdaemon.cpp objs/database.o
$(SQLITE)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evdaemon
:
evdaemon.cpp inc/common.hpp inc/utils.hpp objs/database.o
objs/zmqhelper.o
inc/tinythread.hpp database.cpp
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evdaemon evdaemon.cpp objs/database.o
objs/zmqhelper.o
$(SQLITE)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evcloudsvc
:
evcloudsvc.cpp inc/utils.hpp objs/database.o
inc/zmqhelper.hpp
inc/tinythread.hpp
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evcloudsvc evcloudsvc.cpp objs/database.o
$(SQLITE)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
evcloudsvc
:
evcloudsvc.cpp inc/utils.hpp objs/database.o
objs/zmqhelper.o
inc/tinythread.hpp
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
evcloudsvc evcloudsvc.cpp objs/database.o
objs/zmqhelper.o
$(SQLITE)
$(HEADERS)
`
pkg-config
--cflags
--libs
vendor/lib/pkgconfig/libzmq.pc
`
$(LIBS)
rtspr
:
rtsp-relay.cpp
$(CPP)
$(CPPFLAGS)
$(LD_FLAGS)
-o
rtspr rtsp-relay.cpp
$(LIBFFMPEG)
$(LD_FLAGS)
...
...
opencv-motion-detect/evslicer.cpp
浏览文件 @
3b44a61e
...
...
@@ -22,11 +22,6 @@ update: 2019/09/10
#include <vector>
#include <ctime>
#ifdef OS_LINUX
#include <filesystem>
namespace
fs
=
std
::
filesystem
;
#endif
#include <cstdlib>
#include "inc/zmqhelper.hpp"
#include "inc/tinythread.hpp"
...
...
opencv-motion-detect/inc/common.hpp
浏览文件 @
3b44a61e
...
...
@@ -13,4 +13,26 @@ 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/ghc/filesystem.hpp
0 → 100644
浏览文件 @
3b44a61e
差异被折叠。
点击展开。
opencv-motion-detect/inc/ghc/fs_fwd.hpp
0 → 100644
浏览文件 @
3b44a61e
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//---------------------------------------------------------------------------------------
// fs_fwd.hpp - The forwarding header for the header/implementation seperated usage of
// ghc::filesystem.
// This file can be include at any place, where ghc::filesystem api is needed while
// not bleeding implementation details (e.g. system includes) into the global namespace,
// as long as one cpp includes fs_impl.hpp to deliver the matching implementations.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_FWD_H
#define GHC_FILESYSTEM_FWD_H
#define GHC_FILESYSTEM_FWD
#include <ghc/filesystem.hpp>
#endif // GHC_FILESYSTEM_FWD_H
opencv-motion-detect/inc/ghc/fs_impl.hpp
0 → 100644
浏览文件 @
3b44a61e
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//---------------------------------------------------------------------------------------
// fs_impl.hpp - The implementation header for the header/implementation seperated usage of
// ghc::filesystem.
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
// The cpp has to include this before including fs_fwd.hpp directly or via a different
// header to work.
//---------------------------------------------------------------------------------------
#define GHC_FILESYSTEM_IMPLEMENTATION
#include <ghc/filesystem.hpp>
opencv-motion-detect/inc/ghc/fs_std.hpp
0 → 100644
浏览文件 @
3b44a61e
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//---------------------------------------------------------------------------------------
// fs_std.hpp - The dynamic switching header that includes std::filesystem if detected
// or ghc::filesystem if not, and makes the resulting API available in the
// namespace fs.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_STD_H
#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
#define GHC_WIN_WSTRING_STRING_TYPE
#include <ghc/filesystem.hpp>
namespace
fs
{
using
namespace
ghc
::
filesystem
;
using
ifstream
=
ghc
::
filesystem
::
ifstream
;
using
ofstream
=
ghc
::
filesystem
::
ofstream
;
using
fstream
=
ghc
::
filesystem
::
fstream
;
}
#endif
#endif // GHC_FILESYSTEM_STD_H
opencv-motion-detect/inc/ghc/fs_std_fwd.hpp
0 → 100644
浏览文件 @
3b44a61e
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//---------------------------------------------------------------------------------------
// fs_std_fwd.hpp - The forwarding header for the header/implementation seperated usage of
// ghc::filesystem that uses std::filesystem if it detects it.
// This file can be include at any place, where fs::filesystem api is needed while
// not bleeding implementation details (e.g. system includes) into the global namespace,
// as long as one cpp includes fs_std_impl.hpp to deliver the matching implementations.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_STD_FWD_H
#define GHC_FILESYSTEM_STD_FWD_H
#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
#define GHC_WIN_WSTRING_STRING_TYPE
#define GHC_FILESYSTEM_FWD
#include <ghc/filesystem.hpp>
namespace
fs
{
using
namespace
ghc
::
filesystem
;
using
ifstream
=
ghc
::
filesystem
::
ifstream
;
using
ofstream
=
ghc
::
filesystem
::
ofstream
;
using
fstream
=
ghc
::
filesystem
::
fstream
;
}
#endif
#endif // GHC_FILESYSTEM_STD_FWD_H
opencv-motion-detect/inc/ghc/fs_std_impl.hpp
0 → 100644
浏览文件 @
3b44a61e
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors
// may be used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//---------------------------------------------------------------------------------------
// fs_std_impl.hpp - The implementation header for the header/implementation seperated usage of
// ghc::filesystem that does nothing if std::filesystem is detected.
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
// The cpp has to include this before including fs_std_fwd.hpp directly or via a different
// header to work.
//---------------------------------------------------------------------------------------
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)
#if __has_include(<filesystem>)
#define GHC_USE_STD_FS
#endif
#endif
#ifndef GHC_USE_STD_FS
#define GHC_WIN_WSTRING_STRING_TYPE
#define GHC_FILESYSTEM_IMPLEMENTATION
#include <ghc/filesystem.hpp>
#endif
opencv-motion-detect/inc/zmqhelper.cpp
0 → 100644
浏览文件 @
3b44a61e
#include "zmqhelper.hpp"
namespace
zmqhelper
{
//
string
body2str
(
vector
<
uint8_t
>
body
)
{
return
string
((
char
*
)(
body
.
data
()),
body
.
size
());
}
vector
<
uint8_t
>
data2body
(
char
*
data
,
int
len
)
{
vector
<
uint8_t
>
v
;
v
.
insert
(
v
.
end
(),
(
uint8_t
*
)
data
,
(
uint8_t
*
)
data
+
len
);
return
v
;
}
vector
<
uint8_t
>
str2body
(
string
const
&
str
)
{
vector
<
uint8_t
>
v
;
v
.
insert
(
v
.
end
(),
(
uint8_t
*
)(
str
.
data
()),
(
uint8_t
*
)(
str
.
data
())
+
str
.
size
());
return
v
;
}
// proto: 1. on router [sender_id] [target_id] [body]
// 2. on dealer [sender_id] [body]
vector
<
vector
<
uint8_t
>
>
z_recv_multiple
(
void
*
s
,
bool
nowait
)
{
int64_t
more
=
1
;
vector
<
vector
<
uint8_t
>
>
body
;
int
cnt
=
0
;
int
ret
=
0
;
while
(
more
>
0
)
{
cnt
++
;
zmq_msg_t
msg
;
ret
=
zmq_msg_init
(
&
msg
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"failed to receive multiple msg on zmq_msg_init: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
ret
=
zmq_recvmsg
(
s
,
&
msg
,
nowait
?
ZMQ_DONTWAIT
:
0
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_recv_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
vector
<
uint8_t
>
v
;
v
.
insert
(
v
.
end
(),
(
uint8_t
*
)
zmq_msg_data
(
&
msg
),
(
uint8_t
*
)
zmq_msg_data
(
&
msg
)
+
ret
);
body
.
push_back
(
v
);
spdlog
::
debug
(
"z_rcv_multiple: {}"
,
body2str
(
v
).
substr
(
0
,
v
.
size
()
>
100
?
15
:
v
.
size
()));
zmq_msg_close
(
&
msg
);
size_t
more_size
=
sizeof
(
more
);
ret
=
zmq_getsockopt
(
s
,
ZMQ_RCVMORE
,
&
more
,
&
more_size
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_recv_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
}
return
body
;
}
// proto [sender_id(only when no identifier set in setsockopts)] [target_id] [body]
int
z_send_multiple
(
void
*
s
,
vector
<
vector
<
uint8_t
>
>&
body
)
{
size_t
cnt
=
0
;
int
ret
=
0
;
zmq_msg_t
msg
;
for
(
auto
&
i
:
body
)
{
ret
=
zmq_msg_init_size
(
&
msg
,
i
.
size
());
memcpy
(
zmq_msg_data
(
&
msg
),
(
void
*
)(
i
.
data
()),
i
.
size
());
spdlog
::
debug
(
"z_send_multiple: {}"
,
body2str
(
i
).
substr
(
0
,
i
.
size
()
>
100
?
15
:
i
.
size
()));
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_send_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
ret
=
zmq_msg_send
(
&
msg
,
s
,
cnt
==
(
body
.
size
()
-
1
)
?
0
:
(
ZMQ_SNDMORE
));
zmq_msg_close
(
&
msg
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_send_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
cnt
++
;
}
return
ret
;
}
/// setup router
int
setupRouter
(
void
**
ctx
,
void
**
s
,
string
addr
){
int
ret
=
0
;
int
opt_notify
=
ZMQ_NOTIFY_DISCONNECT
|
ZMQ_NOTIFY_CONNECT
;
*
ctx
=
zmq_ctx_new
();
*
s
=
zmq_socket
(
*
ctx
,
ZMQ_ROUTER
);
zmq_setsockopt
(
*
s
,
ZMQ_ROUTER_NOTIFY
,
&
opt_notify
,
sizeof
(
opt_notify
));
ret
=
zmq_bind
(
*
s
,
addr
.
c_str
());
if
(
ret
<
0
)
{
spdlog
::
debug
(
"failed to bind zmq at {} for reason: {}, retrying load configuration..."
,
addr
,
zmq_strerror
(
zmq_errno
()));
}
return
ret
;
}
/// setup dealer
/// @return 0 success, otherwise failed
int
setupDealer
(
void
**
ctx
,
void
**
s
,
string
addr
,
string
ident
)
{
int
ret
=
0
;
*
ctx
=
zmq_ctx_new
();
*
s
=
zmq_socket
(
*
ctx
,
ZMQ_DEALER
);
ret
=
zmq_setsockopt
(
*
s
,
ZMQ_IDENTITY
,
ident
.
c_str
(),
ident
.
size
());
ret
+=
zmq_setsockopt
(
*
s
,
ZMQ_ROUTING_ID
,
ident
.
c_str
(),
ident
.
size
());
if
(
ret
<
0
)
{
spdlog
::
debug
(
"{} failed setsockopts ZMQ_ROUTING_ID to {}: {}"
,
ident
,
addr
,
zmq_strerror
(
zmq_errno
()));
}
else
{
ret
=
zmq_connect
(
*
s
,
addr
.
c_str
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"{} failed connect dealer: {}"
,
ident
,
addr
);
}
}
return
ret
;
}
/// recv config msg:
/// @return 0 success, otherwise failed.
int
recvConfigMsg
(
void
*
s
,
json
&
config
,
string
addr
,
string
ident
){
bool
bConfigGot
=
false
;
while
(
!
bConfigGot
){
auto
v
=
zmqhelper
::
z_recv_multiple
(
s
);
if
(
v
.
size
()
!=
3
)
{
spdlog
::
error
(
"{} invalid msg from daemon: {}"
,
ident
,
addr
);
return
-
1
;
}
spdlog
::
debug
(
"{} configuration msg received: {} {} {}"
,
ident
,
body2str
(
v
[
0
]),
body2str
(
v
[
1
]),
body2str
(
v
[
2
]));
try
{
string
sMeta
=
json
::
parse
(
body2str
(
v
[
1
]))[
"type"
];
if
(
sMeta
!=
EV_MSG_META_CONFIG
)
{
throw
StrException
(
"meta type is:"
+
sMeta
+
", but expecting "
+
EV_MSG_META_CONFIG
);
}
config
=
json
::
parse
(
body2str
(
v
[
2
]));
bConfigGot
=
true
;
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"{} invalid config msg from daemon {}, {}"
,
ident
,
addr
,
e
.
what
());
return
-
1
;
}
}
return
0
;
}
int
forkSubsystem
(
string
devSn
,
string
peerId
,
int
drPort
,
pid_t
&
pid
){
int
ret
=
0
;
auto
v
=
strutils
::
split
(
peerId
,
':'
);
string
modName
=
v
[
1
];
string
sn
=
v
[
0
];
if
(
(
pid
=
fork
())
==
-
1
)
{
spdlog
::
error
(
"evdamon {} failed to fork subsytem - evmgr"
,
devSn
);
return
-
1
;
}
else
if
(
pid
==
0
)
{
ret
+=
setenv
(
"PEERID"
,
peerId
.
c_str
(),
1
);
ret
+=
setenv
(
"DR_PORT"
,
to_string
(
drPort
).
c_str
(),
1
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"evdaemon {} failed to set env"
,
devSn
);
return
-
2
;
}
execl
((
string
(
"./"
)
+
modName
).
c_str
(),
NULL
,
NULL
,
NULL
);
spdlog
::
error
(
"evdaemon {} failed to startup evmgr"
,
devSn
);
}
else
{
// parent
}
return
0
;
}
}
\ No newline at end of file
opencv-motion-detect/inc/zmqhelper.hpp
浏览文件 @
3b44a61e
...
...
@@ -46,178 +46,23 @@ namespace zmqhelper {
#define MAX_EVENT_QUEUE_SIZE 50
//
string
body2str
(
vector
<
uint8_t
>
body
)
{
return
string
((
char
*
)(
body
.
data
()),
body
.
size
());
}
vector
<
uint8_t
>
data2body
(
char
*
data
,
int
len
)
{
vector
<
uint8_t
>
v
;
v
.
insert
(
v
.
end
(),
(
uint8_t
*
)
data
,
(
uint8_t
*
)
data
+
len
);
return
v
;
}
vector
<
uint8_t
>
str2body
(
string
const
&
str
)
{
vector
<
uint8_t
>
v
;
v
.
insert
(
v
.
end
(),
(
uint8_t
*
)(
str
.
data
()),
(
uint8_t
*
)(
str
.
data
())
+
str
.
size
());
return
v
;
}
string
body2str
(
vector
<
uint8_t
>
body
);
vector
<
uint8_t
>
data2body
(
char
*
data
,
int
len
);
vector
<
uint8_t
>
str2body
(
string
const
&
str
);
// proto: 1. on router [sender_id] [target_id] [body]
// 2. on dealer [sender_id] [body]
vector
<
vector
<
uint8_t
>
>
z_recv_multiple
(
void
*
s
,
bool
nowait
=
false
)
{
int64_t
more
=
1
;
vector
<
vector
<
uint8_t
>
>
body
;
int
cnt
=
0
;
int
ret
=
0
;
while
(
more
>
0
)
{
cnt
++
;
zmq_msg_t
msg
;
ret
=
zmq_msg_init
(
&
msg
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"failed to receive multiple msg on zmq_msg_init: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
ret
=
zmq_recvmsg
(
s
,
&
msg
,
nowait
?
ZMQ_DONTWAIT
:
0
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_recv_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
vector
<
uint8_t
>
v
;
v
.
insert
(
v
.
end
(),
(
uint8_t
*
)
zmq_msg_data
(
&
msg
),
(
uint8_t
*
)
zmq_msg_data
(
&
msg
)
+
ret
);
body
.
push_back
(
v
);
spdlog
::
debug
(
"z_rcv_multiple: {}"
,
body2str
(
v
).
substr
(
0
,
v
.
size
()
>
100
?
15
:
v
.
size
()));
zmq_msg_close
(
&
msg
);
size_t
more_size
=
sizeof
(
more
);
ret
=
zmq_getsockopt
(
s
,
ZMQ_RCVMORE
,
&
more
,
&
more_size
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_recv_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
}
return
body
;
}
vector
<
vector
<
uint8_t
>
>
z_recv_multiple
(
void
*
s
,
bool
nowait
=
false
);
// proto [sender_id(only when no identifier set in setsockopts)] [target_id] [body]
int
z_send_multiple
(
void
*
s
,
vector
<
vector
<
uint8_t
>
>&
body
)
{
size_t
cnt
=
0
;
int
ret
=
0
;
zmq_msg_t
msg
;
for
(
auto
&
i
:
body
)
{
ret
=
zmq_msg_init_size
(
&
msg
,
i
.
size
());
memcpy
(
zmq_msg_data
(
&
msg
),
(
void
*
)(
i
.
data
()),
i
.
size
());
spdlog
::
debug
(
"z_send_multiple: {}"
,
body2str
(
i
).
substr
(
0
,
i
.
size
()
>
100
?
15
:
i
.
size
()));
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_send_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
ret
=
zmq_msg_send
(
&
msg
,
s
,
cnt
==
(
body
.
size
()
-
1
)
?
0
:
(
ZMQ_SNDMORE
));
zmq_msg_close
(
&
msg
);
if
(
ret
<
0
)
{
spdlog
::
debug
(
"z_send_multiple: {}"
,
zmq_strerror
(
zmq_errno
()));
break
;
}
cnt
++
;
}
return
ret
;
}
int
z_send_multiple
(
void
*
s
,
vector
<
vector
<
uint8_t
>
>&
body
);
/// setup router
int
setupRouter
(
void
**
ctx
,
void
**
s
,
string
addr
){
int
ret
=
0
;
int
opt_notify
=
ZMQ_NOTIFY_DISCONNECT
|
ZMQ_NOTIFY_CONNECT
;
*
ctx
=
zmq_ctx_new
();
*
s
=
zmq_socket
(
*
ctx
,
ZMQ_ROUTER
);
zmq_setsockopt
(
*
s
,
ZMQ_ROUTER_NOTIFY
,
&
opt_notify
,
sizeof
(
opt_notify
));
ret
=
zmq_bind
(
*
s
,
addr
.
c_str
());
if
(
ret
<
0
)
{
spdlog
::
debug
(
"failed to bind zmq at {} for reason: {}, retrying load configuration..."
,
addr
,
zmq_strerror
(
zmq_errno
()));
}
return
ret
;
}
int
setupRouter
(
void
**
ctx
,
void
**
s
,
string
addr
);
/// setup dealer
/// @return 0 success, otherwise failed
int
setupDealer
(
void
**
ctx
,
void
**
s
,
string
addr
,
string
ident
)
{
int
ret
=
0
;
*
ctx
=
zmq_ctx_new
();
*
s
=
zmq_socket
(
*
ctx
,
ZMQ_DEALER
);
ret
=
zmq_setsockopt
(
*
s
,
ZMQ_IDENTITY
,
ident
.
c_str
(),
ident
.
size
());
ret
+=
zmq_setsockopt
(
*
s
,
ZMQ_ROUTING_ID
,
ident
.
c_str
(),
ident
.
size
());
if
(
ret
<
0
)
{
spdlog
::
debug
(
"{} failed setsockopts ZMQ_ROUTING_ID to {}: {}"
,
ident
,
addr
,
zmq_strerror
(
zmq_errno
()));
}
else
{
ret
=
zmq_connect
(
*
s
,
addr
.
c_str
());
if
(
ret
!=
0
)
{
spdlog
::
error
(
"{} failed connect dealer: {}"
,
ident
,
addr
);
}
}
return
ret
;
}
int
setupDealer
(
void
**
ctx
,
void
**
s
,
string
addr
,
string
ident
);
/// recv config msg:
/// @return 0 success, otherwise failed.
int
recvConfigMsg
(
void
*
s
,
json
&
config
,
string
addr
,
string
ident
){
bool
bConfigGot
=
false
;
while
(
!
bConfigGot
){
auto
v
=
zmqhelper
::
z_recv_multiple
(
s
);
if
(
v
.
size
()
!=
3
)
{
spdlog
::
error
(
"{} invalid msg from daemon: {}"
,
ident
,
addr
);
return
-
1
;
}
spdlog
::
debug
(
"{} configuration msg received: {} {} {}"
,
ident
,
body2str
(
v
[
0
]),
body2str
(
v
[
1
]),
body2str
(
v
[
2
]));
try
{
string
sMeta
=
json
::
parse
(
body2str
(
v
[
1
]))[
"type"
];
if
(
sMeta
!=
EV_MSG_META_CONFIG
)
{
throw
StrException
(
"meta type is:"
+
sMeta
+
", but expecting "
+
EV_MSG_META_CONFIG
);
}
config
=
json
::
parse
(
body2str
(
v
[
2
]));
bConfigGot
=
true
;
}
catch
(
exception
&
e
)
{
spdlog
::
error
(
"{} invalid config msg from daemon {}, {}"
,
ident
,
addr
,
e
.
what
());
return
-
1
;
}
}
return
0
;
}
int
forkSubsystem
(
string
devSn
,
string
peerId
,
int
drPort
,
pid_t
&
pid
){
int
ret
=
0
;
auto
v
=
strutils
::
split
(
peerId
,
':'
);
string
modName
=
v
[
1
];
string
sn
=
v
[
0
];
if
(
(
pid
=
fork
())
==
-
1
)
{
spdlog
::
error
(
"evdamon {} failed to fork subsytem - evmgr"
,
devSn
);
return
-
1
;
}
else
if
(
pid
==
0
)
{
ret
+=
setenv
(
"PEERID"
,
peerId
.
c_str
(),
1
);
ret
+=
setenv
(
"DR_PORT"
,
to_string
(
drPort
).
c_str
(),
1
);
if
(
ret
<
0
)
{
spdlog
::
error
(
"evdaemon {} failed to set env"
,
devSn
);
return
-
2
;
}
execl
((
string
(
"./"
)
+
modName
).
c_str
(),
NULL
,
NULL
,
NULL
);
spdlog
::
error
(
"evdaemon {} failed to startup evmgr"
,
devSn
);
}
else
{
// parent
}
return
0
;
int
recvConfigMsg
(
void
*
s
,
json
&
config
,
string
addr
,
string
ident
);
int
forkSubsystem
(
string
devSn
,
string
peerId
,
int
drPort
,
pid_t
&
pid
);
}
}
#endif
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论