QiaoJiaSystem/DataManagerServer/http_configserver.cpp
@@ -2371,9 +2371,27 @@ std::string str_tmpTime = AppUtil::getCmdResult(cmd_getVideoFileTime); if (str_time > str_tmpTime) { ERR("{\"error\":\"Time error\"}" << str_time << " str_tmpTime " << str_tmpTime); str_time = str_tmpTime.size() > 0 ? str_tmpTime : str_time; //str_time = str_tmpTime.size() > 0 ? str_tmpTime : str_time; qint64 v_time=getVideoTime(str_tmpTime)-1000; int haomiao = (v_time % 1000) > 50 ? ((v_time % 1000) - 50) : 0; v_time /= 1000; int m = v_time; int shi, fen, miao; char ch_time[128]; if (m / 3600 < 24) { shi = m / 3600; fen = m / 60 % 60; miao = m % 60; sprintf(ch_time, "%02d:%02d:%02d.%02d", shi, fen, miao, haomiao / 10); } else printf("输入数值太大"); str_time=ch_time; ERR("{\"error\":\"Time error\"}" << str_time << " str_tmpTime " << str_tmpTime<<" ch_time="<<ch_time); // return "{\"error\":\"Time error\"}"; } @@ -2554,7 +2572,7 @@ DBG("path=" << vec[i]); t_FilePath += vec[i] + ".mp4"; sub = t - t1; find = sub < getVideoTime(t_FilePath); // find = sub < getVideoTime(t_FilePath); break; } @@ -2564,7 +2582,7 @@ DBG("path=" << vec[i]); t_FilePath += vec[i] + ".mp4"; find = sub < getVideoTime(t_FilePath); // find = sub < getVideoTime(t_FilePath); DBG("find:" << find); break; @@ -2574,18 +2592,18 @@ } DBG("sub=" << sub); if (!find) { t_FilePath = ""; } // if (!find) { // t_FilePath = ""; // } return t_FilePath; } qint64 devHttpServer_c::getVideoTime(const std::string &videoPath) { std::string cmd_getVideoFileTime( " ffmpeg -i '" + videoPath + "' 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//"); qint64 devHttpServer_c::getVideoTime(/*const std::string &videoPath,*/std::string& str_tmpTime) { // std::string cmd_getVideoFileTime( // " ffmpeg -i '" + videoPath + "' 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//"); std::string str_tmpTime = AppUtil::getCmdResult(cmd_getVideoFileTime); // str_tmpTime = AppUtil::getCmdResult(cmd_getVideoFileTime); DBG("str_tmpTime:" << str_tmpTime);//00:00:06.89 qint64 len_ms = 0; @@ -2814,4 +2832,4 @@ return ""; // return "{\"error\":\"传输错误,请检查!\"}"; } } } QiaoJiaSystem/DataManagerServer/http_configserver.h
@@ -174,7 +174,7 @@ std::vector<std::string> forEachFile(const std::string &dir_name); qint64 getVideoTime(const std::string& videoPath); qint64 getVideoTime(/*const std::string& videoPath,*/std::string& str_tmpTime); }; #endif QiaoJiaSystem/StructureApp/AppPipeController.cpp
@@ -161,12 +161,13 @@ std::string strNewTime; strNewTime = AppUtil::getTimeUSecString(); // cv::putText(imageTemp, strNewTime, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 5, // cv::Scalar(255, 255, 0), 2); cv::putText(imageTemp, strNewTime, cv::Point(408, 540), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 5, cv::Scalar(255, 255, 0), 2); if (m_camId.size() > 0) { if (bRecordVideoEnable) { DBG("strNewTime="<<strNewTime<<" camId="<<m_camId); newRecordVideoElement.pushImgBuf(strNewTime, imageTemp); newRecordVideoElement.setSdkTrigger(faceRpcElement.getTriggerState() ||//TODO yoloRpcElement.getTrigger() || @@ -174,9 +175,7 @@ rightJudgment.getTriggerState() || perimeterElement.getTriggerState() || crowdElement.getTriggerState()); if (!newRecordVideoElement.isBusy()) { newRecordVideoElement.submit(); } // newRecordVideoElement.submit(); } QiaoJiaSystem/StructureApp/CMakeLists.txt
@@ -8,11 +8,13 @@ SET(SOURCES # HiredisTool.cpp NewRecordVideoElement.cpp JudgmentRetrogradeTool.cpp PerimeterElement.cpp NewEncodeVideoManager.cpp NewEncodeVideo.cpp HiredisTool.cpp TrackingTrigger.cpp FaceRpcElement.cpp @@ -64,6 +66,8 @@ curl fastcommon fdfsclient hiredis ) include_directories( @@ -93,6 +97,8 @@ ../../../BasicPlatForm/libs/glog/include /usr/include/x86_64-linux-gnu/qt5 /usr/include/x86_64-linux-gnu/qt5/QtCore ../../BasicPlatForm/libs/hiredis-master/include ) link_directories( @@ -107,6 +113,8 @@ ../../../BasicPlatForm/libs/glog/lib ../../../BasicPlatForm/libs/crul/lib ../../BasicPlatForm/libs/hiredis-master/lib ) add_executable(${PROJECT_NAME} QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp
@@ -1,12 +1,16 @@ #include "NewRecordVideoElement.h" #include <basic/util/app/AppPreference.hpp> #include <QString> #include <QDateTime> //#todo index int -> string NewRecordVideoElement::NewRecordVideoElement(std::string camid) : videoEncoderElement(cv::Size(1920, 1080), 8, 0), camID(camid) { //videoEncoderElement(cv::Size(1920, 1080), 5, 0), camID(camid) { // basicPath(); m_cutPath = appPref.getStringData("user.loop.absolute.path"); // basicPath(); m_cutPath= appPref.getStringData("user.loop.absolute.path"); recordInit(60,360); } NewRecordVideoElement::~NewRecordVideoElement() { @@ -19,39 +23,43 @@ std::string NewRecordVideoElement::startRecord() { // ImgInfo info=m_HiredisTool.getImage(camID); ImgInfo info; getImg(info); std::string srcPath = getFileName(info.time); ImgInfo info; getImg(info); std::string srcPath= getFileName(info.time); m_filename=srcPath; DBG("m_filename: " << m_filename); // DBG("fisrt fps time"<<info.time); try { videoEncoderElement.threadInitial(srcPath, info.img); } catch (std::exception &e) { ERR(e.what()) } m_hiredisTool.pushImageBuf(m_filename,info.img); m_hiredisTool.addFileInfo(m_filename,RECORD_DOING); return srcPath; } void NewRecordVideoElement::endRecord() { doRecord(); doRecord(); doRecord(); videoEncoderElement.threadClosing(); ImgInfo info; getImg(info); DBG("m_filename: " << m_filename); DBG("recordDelay:" << recordDelay); DBG("videoLength:" << videoLength); DBG("sdkTrigger:" << sdkTrigger); m_hiredisTool.pushImageBuf(m_filename,info.img); m_hiredisTool.addFileInfo(m_filename,RECORD_ENDING); } void NewRecordVideoElement::doRecord() { // ImgInfo info=m_HiredisTool.getImage(camID); ImgInfo info; getImg(info); // DBG(" time="<<info.time); videoEncoderElement.doFunc(info.img); // ImgInfo info=m_HiredisTool.getImage(camID); ImgInfo info; getImg(info); m_hiredisTool.pushImageBuf(m_filename,info.img); m_hiredisTool.addFileInfo(m_filename,RECORD_DOING); } std::string NewRecordVideoElement::getFileName(std::string timeStamp) { std::string dirPath = makeDir(); std::string NewRecordVideoElement::getFileName(const std::string& timeStamp) { std::string dirPath=makeDir(timeStamp); char szDateTime[256] = {0}; sprintf(szDateTime, "%s%s.mp4", dirPath.c_str(), timeStamp.c_str()); @@ -60,7 +68,7 @@ } std::string NewRecordVideoElement::makeDir() { std::string NewRecordVideoElement::makeDir(const std::string& timeStamp) { //# ./camIndex/YYYYMM/DD/YYYYMMDDHH/ std::string t_FilePath = m_cutPath; @@ -69,136 +77,147 @@ t_FilePath.push_back('/'); } char buf[24]; QDateTime dt = QDateTime::fromString(QString::fromStdString(timeStamp), "yyyy-MM-dd hh:mm:ss:zzz"); time_t t = time(nullptr); // 20180901113048 2018-09-01 11:30:48 strftime(buf, 24, "%Y%m%d%H", localtime(&t)); std::string t_strTime(buf); //# ./camIndex/YYYYMM/DD/ t_FilePath.append(camID + "/" + t_strTime.substr(0, 6) + "/" + t_strTime.substr(6, 2) + "/"); //YYYYMMDDHH t_FilePath.append(t_strTime.substr(0, 10) + "/"); std::string t_cmd = "mkdir -p '"; std::string t_strTime=dt.toString("yyyyMMddhh").toStdString(); DBG("t_strTime="<<t_strTime); t_FilePath.append(camID + "/" + t_strTime.substr(0, 6)+ "/" +t_strTime.substr(6, 2) + "/"); //YYYYMMDDHH t_FilePath.append(t_strTime.substr(0,10)+ "/"); std::string t_cmd = "mkdir -p '"; t_cmd.append(t_FilePath + "'"); //#get path mkdir path system(t_cmd.c_str()); return t_FilePath; } void NewRecordVideoElement::pushImgBuf(const std::string &time, cv::Mat &img) { ImgInfo info; img.copyTo(info.img); void NewRecordVideoElement::pushImgBuf(const std::string& time,cv::Mat& img) { ImgInfo info; img.copyTo(info.img); // info.img=img; info.time = time; m_imgBufQue.push(info); info.time=time; m_imgBufQue.push(info); // int size=m_imgBufQue.size(); // DBG("m_imgBufQue size="<<size); } void NewRecordVideoElement::getImg(ImgInfo &info) { //todo int len = 20; info = m_imgBufQue.front(); int size = m_imgBufQue.size(); // DBG("m_imgBufQue size="<<size<<" time="<<info.time); if (size > len) { m_imgBufQue.pop(); } void NewRecordVideoElement::getImg(ImgInfo& info) { info=m_imgBufQue.front(); int size=m_imgBufQue.size(); DBG("m_imgBufQue size="<<size<<" camId="<<camID<<" fileMin="<<fileMin/2); if(size>fileMin/2) { m_imgBufQue.pop(); } } void NewRecordVideoElement::threadFunc() { Record(); } } void NewRecordVideoElement::threadFunc() { // Record(); } void NewRecordVideoElement::threadInitial() { void NewRecordVideoElement::threadInitial() { recordInit(40, 100); } void NewRecordVideoElement::Record() { switch (recordStatus) { case RECORD_STOP: // DBG("recordDelay:" << recordDelay); // DBG("videoLength:" << videoLength); // DBG("sdkTrigger:" << sdkTrigger); videoLength = 0; recordDelay = 0; if (sdkTrigger) { recordStatus = RECORD_DOING; startRecord(); } else { ImgInfo info; getImg(info); } break; } case RECORD_DOING: videoLength++; if (sdkTrigger) { if (videoLength < fileMax) { doRecord(); } else { recordStatus = RECORD_STOP; endRecord(); } } else { recordStatus = RECORD_ENDING; doRecord(); } break; void NewRecordVideoElement::Record() { switch(recordStatus) { case RECORD_STOP: // DBG("recordDelay:" << recordDelay); // DBG("videoLength:" << videoLength); // DBG("sdkTrigger:" << sdkTrigger); videoLength = 0; recordDelay = 0; if(sdkTrigger){ recordStatus = RECORD_DOING; startRecord(); } else { ImgInfo info; getImg(info); } break; case RECORD_ENDING: case RECORD_DOING: videoLength++; if(sdkTrigger){ if(videoLength < fileMax){ doRecord(); } else { recordStatus = RECORD_STOP; endRecord(); } } else { recordStatus = RECORD_ENDING; doRecord(); } break; case RECORD_ENDING: // DBG("recordDelay:" << recordDelay); // DBG("videoLength:" << videoLength); // DBG("sdkTrigger:" << sdkTrigger); recordDelay++; videoLength++; if (sdkTrigger) { if ((recordDelay < fileMin / 4) && (videoLength < fileMax)) { recordDelay++; videoLength++; if(sdkTrigger){ if( (recordDelay < fileMin/4) && (videoLength < fileMax)){ doRecord(); }else{ recordStatus = RECORD_STOP; endRecord(); } }else{ if( (recordDelay < fileMin/2) && (videoLength < fileMax)){ doRecord(); } else { recordStatus = RECORD_STOP; endRecord(); } } else { if ((recordDelay < fileMin / 2) && (videoLength < fileMax)) { doRecord(); } else { recordStatus = RECORD_STOP; endRecord(); } } break; }else{ recordStatus = RECORD_STOP; endRecord(); } } break; default: break; } } default: break; } } void NewRecordVideoElement::setSdkTrigger(bool isTrigger) { if(isTrigger) { DBG("setSdkTrigger time=" << AppUtil::getTimeUSecString()); triggerDelay = 0; sdkTrigger = true; } else { if(triggerDelay++ >= fileMin/2) { sdkTrigger = false; } else{ sdkTrigger = true; } } Record(); } void NewRecordVideoElement::recordInit(int videoMin, int videoMax) { void NewRecordVideoElement::setSdkTrigger(bool isTrigger) { if (isTrigger) { triggerDelay = 0; sdkTrigger = true; } else { if (triggerDelay++ >= fileMin / 2) { sdkTrigger = false; } else { sdkTrigger = true; } } } sdkTrigger = false; fileMin = videoMin; fileMax = videoMax; triggerDelay = fileMin/2; void NewRecordVideoElement::recordInit(int videoMin, int videoMax) { sdkTrigger = false; fileMin = videoMin; fileMax = videoMax; triggerDelay = fileMin / 2; recordStatus = RECORD_STOP; videoLength = 0; recordDelay = 0; } recordStatus = RECORD_STOP; videoLength = 0; recordDelay = 0; } QiaoJiaSystem/StructureApp/NewRecordVideoElement.h
@@ -2,11 +2,12 @@ #define NEWRECORDVIDEOELEMENT_H #include <basic/pipe/PipeElement.h> #include <basic/pipe_element/ffmpeg/FfmpegElement.h> struct ImgInfo { std::string time; cv::Mat img; }; #include "HiredisTool.h" //struct ImgInfo //{ // std::string time; // cv::Mat img; //}; class NewRecordVideoElement : public basic::PipeElement{ public: @@ -16,22 +17,16 @@ ~NewRecordVideoElement(); std::string startRecord(); void setSdkTrigger(bool isTrigger); void doRecord(); void endRecord(); void pushImgBuf(const std::string& time,cv::Mat& img); void getImg(ImgInfo& info); private: virtual void threadFunc() override; virtual void threadInitial() override; private: void recordInit(int videoMin, int videoMax); void Record(); int fileMin; int fileMax; bool sdkTrigger; @@ -44,16 +39,20 @@ int recordStatus; int videoLength; int recordDelay; private: std::string getFileName(std::string timeStamp); std::string makeDir(); std::string startRecord(); void doRecord(); void endRecord(); void getImg(ImgInfo& info); std::string getFileName(const std::string& timeStamp); std::string makeDir(const std::string& timeStamp); ffmpeg::VideoEncodeElement videoEncoderElement; std::string camID; std::string m_cutPath; std::queue<ImgInfo> m_imgBufQue; HiredisTool m_hiredisTool; std::string m_filename; }; #endif // RECORDVIDEOELEMENT_H QiaoJiaSystem/VideoAnalysFromHC/CMakeLists.txt
@@ -54,6 +54,9 @@ ../StructureApp/PerimeterElement.cpp ../StructureApp/NewRecordVideoElement.cpp ../StructureApp/NewEncodeVideoManager.cpp ../StructureApp/NewEncodeVideo.cpp ../StructureApp/HiredisTool.cpp ../YoloServer/rpc/YoloServer.cpp ../FaceDetectServer/rpc/FaceServer.cpp @@ -158,6 +161,7 @@ curl uuid pthread hiredis ) include_directories( @@ -199,6 +203,8 @@ /usr/include/x86_64-linux-gnu/qt5 /usr/include/x86_64-linux-gnu/qt5/QtCore/ /usr/include/x86_64-linux-gnu/qt5/QtSql/ ../../BasicPlatForm/libs/hiredis-master/include ) link_directories( @@ -215,6 +221,7 @@ ../../../BasicPlatForm/libs/hcTool/HCNetSDK64/lib/ ../../../BasicPlatForm/libs/hcTool/HCNetSDK64/lib/HCNetSDKCom/ ../../../BasicPlatForm/libs/libboost/lib ../../BasicPlatForm/libs/hiredis-master/lib ) add_executable(${PROJECT_NAME} QiaoJiaSystem/VideoAnalysFromHC/main.cpp
@@ -9,6 +9,7 @@ #include "DBManageClass.h" #include "RtspAnalysElement.h" #include <basic/debug/Debug.h> #include "StructureApp/NewEncodeVideoManager.h" //#include "PerimeterAlarmManager.h" //#include "KeepRightManager.h" //"192.168.1.4", 8000, "admin", "basic123" @@ -41,6 +42,8 @@ static void startRtspAnalysElement(LDBTool *_dbTool) { RtspAnalysElement rtspAnalysElement(_dbTool); NewEncodeVideoManager newEncodeVideoManager; newEncodeVideoManager.start(); while (1) { sleep(1 * 60 * 60 * 12); } @@ -127,7 +130,8 @@ bool loopRet = true; while (loopRet) { switch (_dbTool.searchDevTypeFromConfigTable()) { switch (_dbTool.searchDevTypeFromConfigTable()) { case 0: { DBG("case 0"); sleep(5); QiaoJiaSystem/build/DataWebServerold mode 100644 new mode 100755 Binary files differ
QiaoJiaSystem/build/FaceDetectServerold mode 100644 new mode 100755 Binary files differ
QiaoJiaSystem/build/FaceExtractServerold mode 100644 new mode 100755 Binary files differ
QiaoJiaSystem/build/FaceSearchServerold mode 100644 new mode 100755 Binary files differ
QiaoJiaSystem/build/StructureAppold mode 100644 new mode 100755 Binary files differ
QiaoJiaSystem/build/VideoAnalysFromHCold mode 100644 new mode 100755 Binary files differ
QiaoJiaSystem/build/config.jsonold mode 100644 new mode 100755
@@ -1,24 +1,23 @@ { "FaceDetectionSampleSize": 720, "mainServerIp": "192.168.1.203", "mainServerPort": "3697", "logPath": "/home/dell/work/log/", "logPath": "/home/basic/work_src/log/", "DEV_ID": "DSVAD010120181119", "ES_IP": "192.168.1.122", "ES_PORT": 9200, "FaceSeachSleepTime": 60, "TotalLoadSize": "500", "buildAddr": "/home/dell/Apps/QiaoJiaSystem/build/", "cutPath": "/home/dell/work/qiaojia/cut", "cutPath": "/home/basic/work_src/cut", "erlCookie": "", "erlFatherNode": "", "erlNode": "", "erlPath": "", "loadPath": "/home/dell/work/qiaojia/load", "loadPath": "/home/basic/work_src/load", "localPasswd": "123456", "netIfName": "eno1", "srsAddr": "rtmp://192.168.1.122:1934/live/", "webPort": 11111, "redis_ip": "127.0.0.1", "redis_buf_len": 750 "redis_ip":"192.168.1.158", "encode_thread_num":3 } QiaoJiaSystem/build/scpToSer.sh
@@ -9,7 +9,7 @@ echo $1 des_pass=123 expect -c " spawn scp ${CUR_PATH}"/"$1 basic@192.168.1.203:/home/basic/Apps/QiaoJiaSystem/build spawn scp ${CUR_PATH}"/"$1 basic@192.168.1.156:/home/basic/Apps/QiaoJiaSystem/build expect \"password:\" send \"${des_pass}\r\" expect eof QiaoJiaSystem/build/syncDBClientold mode 100644 new mode 100755 Binary files differ