From 963090c963b367333cd4f1b173cb51ae227551a5 Mon Sep 17 00:00:00 2001 From: zhangjixing <775834166@qq.com> Date: 星期六, 12 一月 2019 18:34:40 +0800 Subject: [PATCH] YOLO修改,行为算法优化,视频编辑接口修改 --- QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp | 73 +++++++++++++++++++----------------- 1 files changed, 39 insertions(+), 34 deletions(-) diff --git a/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp b/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp index a46ad7c..0ba53a9 100644 --- a/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp +++ b/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp @@ -1,18 +1,21 @@ #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), 5, 0), +//videoEncoderElement(cv::Size(1920, 1080), 5, 0), camID(camid) { // basicPath(); m_cutPath= appPref.getStringData("user.loop.absolute.path"); + + recordInit(appPref.getIntData("n_cut_min_duration"),appPref.getIntData("n_cut_max_duration")); } NewRecordVideoElement::~NewRecordVideoElement() { - queue<ImgInfo> empty; + std::queue<ImgInfo> empty; empty.swap(m_imgBufQue); //m_imgBufQue.clear(); @@ -24,22 +27,24 @@ 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() { @@ -49,13 +54,13 @@ ImgInfo info; getImg(info); -// DBG(" time="<<info.time); - videoEncoderElement.doFunc(info.img); + m_hiredisTool.pushImageBuf(m_filename,info.img); + m_hiredisTool.addFileInfo(m_filename,RECORD_DOING); } - std::string NewRecordVideoElement::getFileName(std::string timeStamp) + std::string NewRecordVideoElement::getFileName(const std::string& timeStamp) { - std::string dirPath=makeDir(); + std::string dirPath=makeDir(timeStamp); char szDateTime[256] = {0}; sprintf(szDateTime, "%s%s.mp4", dirPath.c_str(), timeStamp.c_str()); @@ -64,7 +69,7 @@ } -std::string NewRecordVideoElement::makeDir() { +std::string NewRecordVideoElement::makeDir(const std::string& timeStamp) { //# ./camIndex/YYYYMM/DD/YYYYMMDDHH/ std::string t_FilePath = m_cutPath; @@ -73,15 +78,13 @@ 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/ + 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) + "/"); + t_FilePath.append(t_strTime.substr(0,10)+ "/"); std::string t_cmd = "mkdir -p '"; t_cmd.append(t_FilePath + "'"); //#get path mkdir path @@ -101,12 +104,10 @@ } void NewRecordVideoElement::getImg(ImgInfo& info) { - //todo - int len=20; - info=m_imgBufQue.front(); + info=m_imgBufQue.front(); int size=m_imgBufQue.size(); -// DBG("m_imgBufQue size="<<size<<" time="<<info.time); - if(size>len) +// DBG("m_imgBufQue size="<<size<<" camId="<<camID<<" fileMin="<<fileMin/2); + if(size>fileMin/2) { m_imgBufQue.pop(); } @@ -116,11 +117,12 @@ } void NewRecordVideoElement::threadFunc() { - Record(); +// Record(); } void NewRecordVideoElement::threadInitial() { - recordInit(40,100); + + } void NewRecordVideoElement::Record() { @@ -194,6 +196,7 @@ void NewRecordVideoElement::setSdkTrigger(bool isTrigger) { if(isTrigger) { +// DBG("setSdkTrigger time=" << AppUtil::getTimeUSecString()); triggerDelay = 0; sdkTrigger = true; } @@ -206,11 +209,13 @@ sdkTrigger = true; } } + Record(); } void NewRecordVideoElement::recordInit(int videoMin, int videoMax) { + sdkTrigger = false; - fileMin = videoMin; - fileMax = videoMax; + fileMin = videoMin*8;//fps=8 + fileMax = videoMax*8; triggerDelay = fileMin/2; recordStatus = RECORD_STOP; -- Gitblit v1.8.0