提交 377d0ee2 authored 作者: blu's avatar blu

init

上级 d5ffd641
...@@ -4,7 +4,7 @@ CPPFLAGS = -g -Wall -std=gnu++1z ...@@ -4,7 +4,7 @@ CPPFLAGS = -g -Wall -std=gnu++1z
CFLAGS = -g -Wall CFLAGS = -g -Wall
LIBOPENCV = `pkg-config opencv --cflags --libs` LIBOPENCV = `pkg-config opencv --cflags --libs`
LIBFFMPEG = `pkg-config libavformat libavutil libavcodec --cflags --libs` LIBFFMPEG = `pkg-config libavformat libavutil libavcodec libswscale --cflags --libs`
LIBS=-lpthread LIBS=-lpthread
SQLITE=vendor/sqlite/sqlite3.c SQLITE=vendor/sqlite/sqlite3.c
HEADERS=-Iinc HEADERS=-Iinc
...@@ -33,7 +33,7 @@ evpusher: evpusher.cpp inc/common.hpp inc/tinythread.hpp database.cpp sqlite3.o ...@@ -33,7 +33,7 @@ evpusher: evpusher.cpp inc/common.hpp inc/tinythread.hpp database.cpp sqlite3.o
evslicer: evslicer.cpp inc/common.hpp inc/tinythread.hpp database.cpp sqlite3.o evslicer: evslicer.cpp inc/common.hpp inc/tinythread.hpp database.cpp sqlite3.o
$(CPP) $(CPPFLAGS) -o evslicer evslicer.cpp database.cpp sqlite3.o $(LIBFFMPEG) $(HEADERS) `pkg-config --cflags --libs vendor/lib/pkgconfig/libzmq.pc` $(LIBS) $(CPP) $(CPPFLAGS) -o evslicer evslicer.cpp database.cpp sqlite3.o $(LIBFFMPEG) $(HEADERS) `pkg-config --cflags --libs vendor/lib/pkgconfig/libzmq.pc` $(LIBS)
evmlmotion: evmlmotion.cpp inc/common.hpp inc/tinythread.hpp database.cpp sqlite3.o evmlmotion: evmlmotion.cpp inc/common.hpp inc/avcvhelpers.hpp inc/tinythread.hpp database.cpp sqlite3.o
$(CPP) $(CPPFLAGS) -o evmlmotion evmlmotion.cpp database.cpp sqlite3.o $(LIBFFMPEG) $(HEADERS) $(LIBOPENCV) `pkg-config --cflags --libs vendor/lib/pkgconfig/libzmq.pc` $(LIBS) $(CPP) $(CPPFLAGS) -o evmlmotion evmlmotion.cpp database.cpp sqlite3.o $(LIBFFMPEG) $(HEADERS) $(LIBOPENCV) `pkg-config --cflags --libs vendor/lib/pkgconfig/libzmq.pc` $(LIBS)
rtspr: rtsp-relay.cpp rtspr: rtsp-relay.cpp
......
...@@ -193,7 +193,7 @@ namespace DB { ...@@ -193,7 +193,7 @@ namespace DB {
} }
*/ */
// tables: device, evmgr, evpuller, evpusher, evslice, evml, ipc, log // tables: info, evmgr, evpuller, evpusher, evslice, evml, ipc, log
// schemas: // schemas:
// info: id, cls text, value text, version, update datetime // info: id, cls text, value text, version, update datetime
// ex: 1, sn, ILS112233, NULL, NULL // ex: 1, sn, ILS112233, NULL, NULL
...@@ -203,11 +203,11 @@ namespace DB { ...@@ -203,11 +203,11 @@ namespace DB {
// ipc: id, user, passwd, addr, status // ipc: id, user, passwd, addr, status
// ex: 1, admin, FWBWTU, 172.31.0.51, 0 // ex: 1, admin, FWBWTU, 172.31.0.51, 0
// evmgr: // evmgr: iid integer, cid <id_of_ipc>, addr text, status
// evpuller: iid, cid, addr, pub, rep, status; // evpuller: iid, cid <id_of_ipc>, addr, pub, rep, status;
// evpusher: iid, cid, addr, urldest, enabled, status; // evpusher: iid, pid <id_of_puller>, urldest, enabled, status;
// evslicer: iid, cid, addr, urldest, days, miniutes, status; // evslicer: iid, pid, urldest, days, miniutes, status;
// evml: iid, cid, type, addr, enabled, status // evml: iid, pid, cls, enabled, status
// //
// //
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
#endif #endif
#include <cstdlib> #include <cstdlib>
#include <opencv2/opencv.hpp>
#include "vendor/include/zmq.h" #include "vendor/include/zmq.h"
#include "tinythread.hpp" #include "tinythread.hpp"
#include "common.hpp" #include "common.hpp"
#include "avcvhelpers.hpp"
#include "database.h" #include "database.h"
using namespace std; using namespace std;
...@@ -261,25 +261,17 @@ private: ...@@ -261,25 +261,17 @@ private:
// save a grayscale frame into a .pgm file // save a grayscale frame into a .pgm file
string name = urlOut + "/"+ to_string(chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count()) + ".pgm"; // string name = urlOut + "/"+ to_string(chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count()) + ".pgm";
save_gray_frame(pFrame->data[0], pFrame->linesize[0], pFrame->width, pFrame->height, const_cast<char*>( name.c_str())); detectMotion(pFrame);
} }
spdlog::debug("ch4"); spdlog::debug("ch4");
} }
return 0; return 0;
} }
void save_gray_frame(unsigned char *buf, int wrap, int xsize, int ysize, char *filename) void detectMotion(AVFrame *pFrame)
{ {
FILE *f;
int i;
f = fopen(filename,"w");
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
// writing line by line
for (i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f);
fclose(f);
} }
protected: protected:
void run() void run()
...@@ -329,6 +321,7 @@ protected: ...@@ -329,6 +321,7 @@ protected:
break; break;
} }
av_frame_free(&pFrame);
av_packet_unref(&packet); av_packet_unref(&packet);
if (ret < 0) { if (ret < 0) {
spdlog::error("error muxing packet"); spdlog::error("error muxing packet");
......
...@@ -5,6 +5,7 @@ extern "C" ...@@ -5,6 +5,7 @@ extern "C"
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libavutil/time.h> #include <libavutil/time.h>
} }
#include <libavutil/timestamp.h> #include <libavutil/timestamp.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <json.hpp> #include <json.hpp>
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论