增加行为区域和人体画框,靠右行还存在问题,流截图存数据库及接口修改
| | |
| | | str_imgName +="-"; |
| | | str_imgName += "snapshot.jpg"; |
| | | //admin:a1234567@192.168.1.201:554/h264/ch1/main/av_stream -r 1/25 -f image2 -s 1920*1080 /home/basic/work_src/a.jpg |
| | | std::string cmd("ffmpeg -i " + rtsp_url + " -r 1/25 -f image2 -s 1920*1080 -y " + str_imgName); |
| | | std::string cmd("ffmpeg -i " + rtsp_url + " -vf select='eq(pict_type\\,I)',setpts='N/(25*TB)' -f image2 -s 1920*1080 -y " + str_imgName); |
| | | // std::string cmd("ffmpeg -i " + rtsp_url + " -r 1/25 -f image2 -s 1920*1080 -y " + str_imgName); |
| | | DBG(cmd); |
| | | system(cmd.c_str()); |
| | | |
| | |
| | | CvUtil::cvMat2Buffer(img, buffer); |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient.fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | strImgUrl.append(fdfsClient.fastFds->getIp() + "/" + strImgUrlTmp); |
| | | // strImgUrl.append(fdfsClient.fastFds->getIp() + "/" + strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | } |
| | | fdfsClient.rwLock.unlock(); |
| | | Json::Value result; |
| | | result["imgUrl"] = strImgUrl; |
| | | db_c.updateCamDevSnapshot(QString::fromStdString(ip),QString::fromStdString(strImgUrl)); |
| | | |
| | | return result.toStyledString(); |
| | | |
| | |
| | | |
| | | void EncodeVideo::threadFunc() |
| | | { |
| | | |
| | | // std::string tmp="threadFunc"; |
| | | // ClockTimer cl(tmp); |
| | | |
| | | std::string src_path=getProperty("src_path"); |
| | | if(src_path.empty()) |
| | |
| | | |
| | | videoEncoderElement.doFunc(img); |
| | | } |
| | | usleep(2*1000); |
| | | // usleep(1000); |
| | | } |
| | | |
| | | videoEncoderElement.threadClosing(); |
| | |
| | | #include "EncodeVideoManager.h" |
| | | #include "NewRecordVideoElement.h" |
| | | #include <basic/util/app/AppConfig.h> |
| | | #include <qdatetime.h> |
| | | |
| | | EncodeVideoManager::EncodeVideoManager(): |
| | | TimerElement(1000) |
| | | TimerElement(10*1000) |
| | | { |
| | | // m_hiredisTool.delKey("") |
| | | int thread_num=appConfig.getIntProperty("encode_thread_num"); |
| | |
| | | { |
| | | m_newEncodeVideoVec[i]->stop(); |
| | | delete m_newEncodeVideoVec[i]; |
| | | m_newEncodeVideoVec[i]=nullptr; |
| | | } |
| | | } |
| | | m_newEncodeVideoVec.clear(); |
| | | |
| | | } |
| | | void EncodeVideoManager::timerFunc() |
| | | { |
| | | // std::string tmp="camId="+m_camId+"videoCaptureElement"; |
| | | ClockTimer cl("timerFunc"); |
| | | std::map<std::string,int> fileMap=m_hiredisTool.findAllFileStatus(); |
| | | // auto it=fileMap.begin(); |
| | | for(auto it=fileMap.begin();it!=fileMap.end();it++) |
| | |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | //----/home/basic/work/qiaojia/cut/DS-2CD2T46WDA2-I20180622AACHC30488278/201901/22/2019012210/2019-01-22 10:32:38:171.mp4 |
| | | |
| | | std::string file_name=it->first; |
| | | int begin=file_name.find_last_of("/")+1; |
| | | int end= file_name.find(".mp4"); |
| | | std::string file_time=file_name.substr(begin,end-begin); |
| | | QDateTime dt = QDateTime::fromString(QString::fromStdString(file_time), "yyyy-MM-dd hh:mm:ss:zzz"); |
| | | if( (AppUtil::getCurrentUs()-dt.toMSecsSinceEpoch())>5*60*1000*1000) |
| | | { |
| | | DBG(file_name<<">5*60*1000*1000"); |
| | | m_hiredisTool.hashSet(file_list,file_name,RECORD_ENDING); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | // int max=appPref.getIntData("n_cut_max_duration"); |
| | | // recordInit(40,100); |
| | | videoCaptureElement.registerConnector([&] { |
| | | mutex.lock(); |
| | | cv::Mat imageTemp = videoCaptureElement.getImage(); |
| | | // mutex.lock(); |
| | | |
| | | |
| | | // std::string tmp="camId="+m_camId+"videoCaptureElement"; |
| | | // ClockTimer cl(tmp); |
| | | cv::Mat imageTemp = videoCaptureElement.getImage(); |
| | | std::string strNewTime = AppUtil::getTimeUSecString();; |
| | | |
| | | //DBG("m_camId="<<m_camId<<" strNewTime="<<strNewTime); |
| | | 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) { |
| | | |
| | | |
| | |
| | | strNewTime = newDt.toString("yyyy-MM-dd hh:mm:ss").toStdString(); |
| | | |
| | | } |
| | | mutex.unlock(); |
| | | // mutex.unlock(); |
| | | // DBG(strNewTime); |
| | | |
| | | // std::string tmp1="camId="+m_camId+"strNewTime"+strNewTime; |
| | | // ClockTimer cl1(tmp1); |
| | | if (!faceRpcElement.isBusy()) { |
| | | // faceRpcElement.setProperty("uuid", uuid); |
| | | //#todo |
| | |
| | | |
| | | //#在对比中添加特征值 |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personId"] = "wait todo";//关联底库人员id,人脸id |
| | | t_json["BaseName"] = "wait todo";//关联底库表名 |
| | | t_json["personId"] = "";//关联底库人员id,人脸id |
| | | t_json["BaseName"] = "";//关联底库表名 |
| | | //#end |
| | | // t_json["likePer"] = faceExtractQueueTmp[i].scoredRects[j].score;//人员相似度 Score |
| | | t_json["likeDate"] = AppUtil::getTimeSecString();//"2018-01-01 01:01:01";//比较时间 |
| | | |
| | | t_json["picName"] = "wait todo"; |
| | | t_json["picName"] = ""; |
| | | |
| | | |
| | | t_json["personPicUrl"] = "wait todo";//人员图片 store |
| | | t_json["personPicUrl"] = "";//人员图片 store |
| | | t_json["picAddress"] = getProperty("str_addr");//抓拍地址 |
| | | DBG("picAddress="<< t_json["picAddress"] ); |
| | | t_json["picMaxUrl"] = "wait todo";//大图路径 |
| | | t_json["picLocalUrl"] = "wait todo";//本地路径 |
| | | t_json["picMaxUrl"] = "";//大图路径 |
| | | t_json["picLocalUrl"] = "";//本地路径 |
| | | t_json["picSmUrl"] = strImgUrl;//人员抓小图 |
| | | //#todo |
| | | t_json["picDate"] = faceExtractQueueTmp[i].scoredRects[j].properties["time"]; |
| | |
| | | // DBG("timeC ::::B" << t_json["picDate"m_bIsMask].asString()); |
| | | // t_json["picDate"] = AppUtil::getTimeSecString(); |
| | | |
| | | t_json["content"] = "wait todo"; |
| | | t_json["viType"] = "1";//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型 |
| | | t_json["content"] = ""; |
| | | //t_json["viType"] = "2";//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型 |
| | | t_json["sdkType"] = std::to_string(m_sdkRule.nSdkType);//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型 |
| | | t_json["personIsHub"] = "4";//1: 报警 2: 可疑 3: 安全 4: 未知 |
| | | |
| | | |
| | |
| | | CvUtil::cvMat2Buffer(img,buf); |
| | | // json["time"]=info.time; |
| | | json["img"]=std::string(buf.begin(),buf.end()); |
| | | // buf.clear(); |
| | | std::string strBuf=std::string(buf.begin(),buf.end()); |
| | | if(!listLpush(file_name,json.toStyledString())); |
| | | if(!checkParam()) |
| | | { |
| | | return false; |
| | | } |
| | | redisReply *reply; |
| | | |
| | | reply = (redisReply*)redisCommand(m_redis,"lpush %s %s", file_name.c_str(),json.toStyledString().c_str()); |
| | | if(!checkResult(reply)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | //DBG(json.toStyledString()); |
| | | freeReplyObject(reply); |
| | | |
| | | return true; |
| | | } |
| | |
| | | JudgmentRetrogradeTool::JudgmentRetrogradeTool(const SdkRule &rule) : |
| | | m_triggerElement(0, 0), |
| | | m_sdkRule(rule), |
| | | pManagerEsDB(nullptr) |
| | | pManagerEsDB(nullptr), |
| | | pointArray(nullptr), |
| | | npts(0) |
| | | { |
| | | pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | } |
| | |
| | | delete pManagerEsDB; |
| | | pManagerEsDB = nullptr; |
| | | } |
| | | if(pointArray) |
| | | { |
| | | delete pointArray; |
| | | pointArray=nullptr; |
| | | } |
| | | |
| | | } |
| | | |
| | | bool JudgmentRetrogradeTool::init(QString area, QString line) { |
| | |
| | | if (arrayAreas.isEmpty()) { |
| | | return false; |
| | | } |
| | | int size=arrayAreas.size(); |
| | | QVector<QPoint> vec; |
| | | for (int i = 0; i < arrayAreas.size(); ++i) { |
| | | pointArray=new cv::Point2i[size]; |
| | | for (int i = 0; i < size; ++i) { |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toDouble() * 4; |
| | | int y = obj.value("y").toDouble() * 4; |
| | | pointArray[i]={x,y}; |
| | | vec.push_back(QPoint(x, y)); |
| | | } |
| | | |
| | |
| | | |
| | | if (getPerRet(scoredRect.id))//judgment.bool |
| | | { |
| | | |
| | | DBG("scoredRect.id" << scoredRect.id << " val=" << m_mapPerRet[scoredRect.id]); |
| | | m_mapPerRet[scoredRect.id] -=2400; |
| | | auto t_image = image( |
| | | CvUtil::zoomRectEqual(scoredRect.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // auto t_image = image( |
| | | // CvUtil::zoomRectEqual(scoredRect.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // auto t_image = image(scoredRect.rect& cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | |
| | | if(pointArray==nullptr) return; |
| | | const cv::Point2i* ppt[1] = { pointArray }; |
| | | |
| | | int npt[]={npts}; |
| | | cv::polylines(image, ppt,npt, 1, true,cv::Scalar(255,255,0)); |
| | | cv::arrowedLine(image,m_UpBaseLine.start_Point,m_UpBaseLine.end_Point,cv::Scalar(0,0,255)); |
| | | |
| | | cv::rectangle(image, scoredRect.rect, cv::Scalar(0, 0, 255), 2); |
| | | |
| | | std::string imgUrl = uploadImgToFdfs(image); |
| | | saveInfoToEs(imgUrl, scoredRect); |
| | | state=true; |
| | | |
| | |
| | | t_json["sdkType"] = to_string(m_sdkRule.nSdkType); |
| | | // t_json["Gender"] = obj.score; |
| | | |
| | | t_json["picName"] = "wait todo";// 抓拍照片名称 |
| | | t_json["content"] = "wait todo";// 内容描述 |
| | | t_json["picName"] = "";// 抓拍照片名称 |
| | | t_json["content"] = "";// 内容描述 |
| | | t_json["personPicUrl"] = "";// 人员 地库图片 |
| | | t_json["ChannlId"] = getProperty("ch_id"); // 通道id |
| | | t_json["likeDate"] = AppUtil::getTimeSecString(); // 比对时间 |
| | | t_json["picAddress"] = m_sdkRule.strAddr.toStdString();// 抓拍地址 |
| | | DBG("picAddress="<<m_sdkRule.strAddr.toStdString()); |
| | | t_json["picMaxUrl"] = "wait todo"; // 大图路径 |
| | | t_json["picMaxUrl"] = ""; // 大图路径 |
| | | |
| | | |
| | | // t_json["Age"] ="wait todo"; |
| | | // t_json["Age"] =""; |
| | | t_json["picDate"] = obj.properties["time"]; // 抓拍时间,必须有 |
| | | t_json["picLocalUrl"] = "wait todo"; // 本地路径 |
| | | t_json["picLocalUrl"] = ""; // 本地路径 |
| | | t_json["isDelete"] = "1";//默认1 ,0无效 1有效 |
| | | |
| | | t_json["likePer"] = obj.score; // 相似值 |
| | | t_json["likePer"] = 1.0; // 相似值 |
| | | |
| | | t_json["BaseName"] = "wait todo";// 地库名称 |
| | | t_json["BaseName"] = "";// 地库名称 |
| | | |
| | | t_json["videoNum"] = m_sdkRule.strCamId.toStdString();//Video设备编号 |
| | | t_json["picSmUrl"] = imgUrl; // 抓拍图片 |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID");;// 设备id |
| | | t_json["idcard"] = "wait todo"; |
| | | t_json["personId"] = "wait todo"; |
| | | t_json["idcard"] = ""; |
| | | t_json["personId"] = ""; |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME");// 设备名称 |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personIsHub"] = m_triggerElement.getTriggerState() ? "1" : "4"; //1: 报警 2: 可疑 3: 安全 4: 未知 |
| | |
| | | #include <jsoncpp/json/json.h> |
| | | #include <basic/pipe/PipeElement.h> |
| | | struct VectorPoint { |
| | | cv::Point2f start_Point; |
| | | cv::Point2f end_Point; |
| | | cv::Point2i start_Point; |
| | | cv::Point2i end_Point; |
| | | }; |
| | | |
| | | typedef VectorPoint BaseLine; |
| | |
| | | |
| | | cv::Mat image; |
| | | EsDBTool *pManagerEsDB; |
| | | cv::Point2i* pointArray; |
| | | |
| | | int npts; |
| | | }; |
| | | |
| | | |
| | |
| | | //#todo index int -> string |
| | | NewRecordVideoElement::NewRecordVideoElement(std::string camid) : |
| | | //videoEncoderElement(cv::Size(1920, 1080), 5, 0), |
| | | camID(camid) |
| | | camID(camid), |
| | | m_bSaveWH(false) |
| | | { |
| | | |
| | | // basicPath(); |
| | | isRecord=false; |
| | | //isRecord=false; |
| | | m_cutPath= appPref.getStringData("user.loop.absolute.path"); |
| | | |
| | | recordInit(appPref.getIntData("n_cut_min_duration"),appPref.getIntData("n_cut_max_duration")); |
| | |
| | | std::queue<ImgInfo> empty; |
| | | empty.swap(m_imgBufQue); |
| | | |
| | | //m_imgBufQue.clear(); |
| | | |
| | | } |
| | | |
| | | std::string NewRecordVideoElement::startRecord() { |
| | | |
| | | // ImgInfo info=m_HiredisTool.getImage(camID); |
| | | //isRecord=true; |
| | | |
| | | |
| | | ImgInfo info; |
| | | getImg(info); |
| | | std::string srcPath= getFileName(info.time); |
| | | m_filename=srcPath; |
| | | // DBG("m_filename: " << m_filename); |
| | | if(!m_bSaveWH) |
| | | { |
| | | m_bSaveWH=m_hiredisTool.hashSet(camID,"width",info.img.cols) && m_hiredisTool.hashSet(camID,"height",info.img.rows); |
| | | DBG("m_bSaveWH="<<m_bSaveWH); |
| | | } |
| | | |
| | | m_hiredisTool.pushImageBuf(m_filename,info.img); |
| | | m_hiredisTool.addFileInfo(m_filename,RECORD_DOING); |
| | |
| | | // DBG("sdkTrigger:" << sdkTrigger); |
| | | m_hiredisTool.pushImageBuf(m_filename,info.img); |
| | | m_hiredisTool.addFileInfo(m_filename,RECORD_ENDING); |
| | | // isRecord=false; |
| | | |
| | | } |
| | | |
| | | void NewRecordVideoElement::doRecord() { |
| | |
| | | } |
| | | void NewRecordVideoElement::pushImgBuf(const std::string& time,cv::Mat& img) |
| | | { |
| | | // std::string tmp="camId="+camID+"pushImgBuf"; |
| | | // ClockTimer cl(tmp); |
| | | ImgInfo info; |
| | | img.copyTo(info.img); |
| | | // info.img=img; |
| | |
| | | } |
| | | void NewRecordVideoElement::getImg(ImgInfo& info) |
| | | { |
| | | // std::string tmp="camId="+camID+"getImg"; |
| | | // ClockTimer cl(tmp); |
| | | info=m_imgBufQue.front(); |
| | | int size=m_imgBufQue.size(); |
| | | // DBG("m_imgBufQue size="<<size<<" camId="<<camID<<" fileMin="<<fileMin/2); |
| | |
| | | } |
| | | } |
| | | void NewRecordVideoElement::setSdkTrigger(bool isTrigger) { |
| | | // std::string tmp="camId="+camID+"setSdkTrigger"; |
| | | // ClockTimer cl(tmp); |
| | | if(isTrigger) |
| | | { |
| | | // DBG("setSdkTrigger time=" << AppUtil::getTimeUSecString()); |
| | |
| | | #define RECORD_STOP (0) |
| | | #define RECORD_DOING (1) |
| | | #define RECORD_ENDING (2) |
| | | |
| | | int recordStatus; |
| | | int videoLength; |
| | | int recordDelay; |
| | |
| | | std::queue<ImgInfo> m_imgBufQue; |
| | | HiredisTool m_hiredisTool; |
| | | std::string m_filename; |
| | | bool isRecord; |
| | | bool m_bSaveWH; |
| | | }; |
| | | |
| | | #endif // RECORDVIDEOELEMENT_H |
| | |
| | | if(!isInWeek(m_sdkRule.weekRuleVec)) |
| | | return; |
| | | int num=0; |
| | | |
| | | |
| | | for(auto obj:mObjs) |
| | | bool state=false; |
| | | time_t now= AppUtil::getCurrentUs(); |
| | | for(auto& obj:mObjs) |
| | | { |
| | | |
| | | if(obj.score < m_sdkRule.fSensitivity)continue; |
| | |
| | | QPoint center = rect.center(); |
| | | if(mPolygon.containsPoint(center,Qt::OddEvenFill) || !m_bIsMask) |
| | | { |
| | | for(auto score:m_lastScoreRect) |
| | | for(auto ele:m_lastScoreRect) |
| | | { |
| | | if(obj.id == score.id) |
| | | if(obj.id == ele.id && (obj.rect&ele.rect).area()>ele.rect.area()*m_sdkRule.fSensitivity) |
| | | { |
| | | obj.isMove = score.isMove; |
| | | if(obj.times ==0) |
| | | { |
| | | obj.times=AppUtil::getCurrentUs(); |
| | | } |
| | | else if( (now-obj.times)>m_sdkRule.nTriggerDelay*60*1000*1000) |
| | | { |
| | | DBG("now-obj.times="<<now-obj.times); |
| | | if(pointArray!=nullptr) |
| | | { |
| | | const cv::Point2i* ppt[1] = { pointArray }; |
| | | |
| | | int npt[]={npts}; |
| | | |
| | | cv::polylines(image, ppt,npt, 1, true,cv::Scalar(255,255,0)); |
| | | } |
| | | cv::rectangle(image, obj.rect, cv::Scalar(0, 0, 255), 2); |
| | | auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl=uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl,obj); |
| | | obj.times=0; |
| | | } |
| | | //DBG("moving? "<<_TrackingInfo.m_bMoveState) |
| | | break; |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | if((AppUtil::getCurrentUs()-m_lTime)>(m_sdkRule.nTriggerDelay*60*1000*1000)) |
| | | { |
| | | for(auto& obj: mObjs){ |
| | | |
| | | //compare with last temp memery and clear temp memery |
| | | for(auto ele:m_lastScoreRect) |
| | | { |
| | | if(ele.id==obj.id) |
| | | { |
| | | if((obj.rect&ele.rect).area()>ele.rect.area()*m_sdkRule.fSensitivity) |
| | | { |
| | | //not moving |
| | | obj.isMove = true; |
| | | |
| | | auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | std::string imgUrl=uploadImgToFdfs(t_image); |
| | | saveInfoToEs(imgUrl,obj); |
| | | m_triggerElement.setState(true); |
| | | //DBG("not moving") |
| | | } |
| | | else |
| | | { |
| | | obj.isMove = false; |
| | | m_triggerElement.setState(false); |
| | | //DBG("moving") |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | //do temp memery |
| | | |
| | | } |
| | | // m_lastScoreRect = mObjs; |
| | | m_lTime =AppUtil::getCurrentUs(); |
| | | } |
| | | |
| | | m_lastScoreRect=mObjs; |
| | | m_triggerElement.triggerOnce(); |
| | | // if((AppUtil::getCurrentUs()-m_lTime)>(m_sdkRule.nTriggerDelay*60*1000*1000)) |
| | | // { |
| | | // for(auto& obj: mObjs){ |
| | | |
| | | // //compare with last temp memery and clear temp memery |
| | | // for(auto ele:m_lastScoreRect) |
| | | // { |
| | | // if(ele.id==obj.id) |
| | | // { |
| | | // if((obj.rect&ele.rect).area()>ele.rect.area()*m_sdkRule.fSensitivity) |
| | | // { |
| | | // //not moving |
| | | // obj.isMove = true; |
| | | |
| | | // auto t_image = image(CvUtil::zoomRectEqual(obj.rect, 1.2, 1.2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); |
| | | // std::string imgUrl=uploadImgToFdfs(t_image); |
| | | // saveInfoToEs(imgUrl,obj); |
| | | // m_triggerElement.setState(true); |
| | | // //DBG("not moving") |
| | | // } |
| | | // else |
| | | // { |
| | | // obj.isMove = false; |
| | | // m_triggerElement.setState(false); |
| | | // //DBG("moving") |
| | | // } |
| | | // break; |
| | | // } |
| | | // } |
| | | // //do temp memery |
| | | |
| | | // } |
| | | // // m_lastScoreRect = mObjs; |
| | | // m_lTime =AppUtil::getCurrentUs(); |
| | | // } |
| | | |
| | | // m_lastScoreRect=mObjs; |
| | | |
| | | m_triggerElement.setState(true); |
| | | m_triggerElement.triggerOnce(); |
| | | |
| | | |
| | | fireConnectors(); |
| | |
| | | m_bIsMask=false; |
| | | return;//do not detect |
| | | } |
| | | int size=arrayAreas.size(); |
| | | npts=size; |
| | | pointArray=new cv::Point2i[size]; |
| | | for(int i = 0;i < arrayAreas.size();++i) |
| | | { |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | |
| | | t_json["sdkType"] =to_string(m_sdkRule.nSdkType); |
| | | // t_json["Gender"] = obj.score; |
| | | |
| | | t_json["picName"] = "wait todo";// 抓拍照片名称 |
| | | t_json["content"] = "wait todo";// 内容描述 |
| | | t_json["picName"] = "";// 抓拍照片名称 |
| | | t_json["content"] = "";// 内容描述 |
| | | t_json["personPicUrl"] = "";// 人员 地库图片 |
| | | t_json["ChannlId"] = getProperty("ch_id"); // 通道id |
| | | t_json["likeDate"] =AppUtil::getTimeSecString(); // 比对时间 |
| | | t_json["picAddress"] =m_sdkRule.strAddr.toStdString();// 抓拍地址 |
| | | t_json["picMaxUrl"] = "wait todo"; // 大图路径 |
| | | t_json["picMaxUrl"] = ""; // 大图路径 |
| | | |
| | | |
| | | // t_json["Age"] ="wait todo"; |
| | | // t_json["Age"] =""; |
| | | t_json["picDate"] = obj.properties["time"]; // 抓拍时间,必须有 |
| | | t_json["picLocalUrl"] = "wait todo"; // 本地路径 |
| | | t_json["picLocalUrl"] = ""; // 本地路径 |
| | | t_json["isDelete"] = "1";//默认1 ,0无效 1有效 |
| | | |
| | | t_json["likePer"] = obj.score; // 相似值 |
| | | t_json["likePer"] = 1.0; // 相似值 |
| | | |
| | | t_json["BaseName"] = "wait todo";// 地库名称 |
| | | t_json["BaseName"] = "";// 地库名称 |
| | | |
| | | t_json["videoNum"] = m_sdkRule.strCamId.toStdString();//Video设备编号 |
| | | t_json["picSmUrl"] = imgUrl; // 抓拍图片 |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID");;// 设备id |
| | | t_json["idcard"] = "wait todo"; |
| | | t_json["personId"] = "wait todo"; |
| | | t_json["idcard"] = ""; |
| | | t_json["personId"] = ""; |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME");// 设备名称 |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personIsHub"] = m_triggerElement.getTriggerState()?"1":"4"; //1: 报警 2: 可疑 3: 安全 4: 未知 |
| | |
| | | unsigned long long m_lTime; |
| | | EsDBTool* pManagerEsDB; |
| | | bool m_bIsMask; |
| | | cv::Point2i* pointArray; |
| | | int npts; |
| | | }; |
| | | |
| | | #endif // PAELEMENT_H |
| | |
| | | mRealNum(0), |
| | | m_triggerElement(rule.nTriggerDelay*8,0), |
| | | pManagerEsDB(nullptr), |
| | | m_bIsMask(true) |
| | | m_bIsMask(true), |
| | | pointArray(nullptr) |
| | | { |
| | | |
| | | pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | |
| | | if (pManagerEsDB) { |
| | | delete pManagerEsDB; |
| | | pManagerEsDB = nullptr; |
| | | } |
| | | if(pointArray) |
| | | { |
| | | // delete[] pointArray[0]; |
| | | delete[] pointArray; |
| | | } |
| | | } |
| | | |
| | |
| | | if (m_triggerElement.getTriggerState() ) |
| | | { |
| | | if(num > 0) { |
| | | cv::Mat t_image = image(CutMask()).clone(); |
| | | if(t_image.empty()) |
| | | |
| | | |
| | | |
| | | if(pointArray!=nullptr) |
| | | { |
| | | DBG("t_image empty"); |
| | | return; |
| | | const cv::Point2i* ppt[1] = { pointArray }; |
| | | |
| | | int npt[]={npts}; |
| | | |
| | | cv::polylines(image, ppt,npt, 1, true,cv::Scalar(255,255,0)); |
| | | } |
| | | std::string imgUrl = uploadImgToFdfs(t_image); |
| | | |
| | | for(auto rect:m_recVec) |
| | | { |
| | | cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2); |
| | | } |
| | | // cv::Mat t_image = image(CutMask()).clone(); |
| | | // if(t_image.empty()) |
| | | // { |
| | | // DBG("t_image empty"); |
| | | // return; |
| | | // } |
| | | std::string imgUrl = uploadImgToFdfs(image); |
| | | saveInfoToEs(imgUrl, picDate); |
| | | } |
| | | DBG("num=" << num << " lastnum=" << mRealNum); |
| | |
| | | } |
| | | int size = arrayAreas.size(); |
| | | npts = size; |
| | | // pointArray=new cv::Point2i*[1]; |
| | | // pointArray[0]=new cv::Point2i[size]; |
| | | |
| | | pointArray=new cv::Point2i[npts]; |
| | | |
| | | |
| | | for (int i = 0; i < size; ++i) { |
| | | |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toDouble() * 4; |
| | | int y = obj.value("y").toDouble() * 4; |
| | | |
| | | pointArray[i]={x,y}; |
| | | |
| | | |
| | | if(m_sdkRule.nSdkType == PerimeterSdk) |
| | | { |
| | | poly1.push_back(Point(x,y)); |
| | |
| | | // DBG("to_string(m_sdkRule.nSdkType)="<<to_string(m_sdkRule.nSdkType)); |
| | | // t_json["Gender"] = obj.score; |
| | | |
| | | t_json["picName"] = "wait todo";// 抓拍照片名称 |
| | | t_json["content"] = "wait todo";// 内容描述 |
| | | t_json["picName"] = "";// 抓拍照片名称 |
| | | t_json["content"] = "";// 内容描述 |
| | | t_json["personPicUrl"] = "";// 人员 地库图片 |
| | | t_json["ChannlId"] = getProperty("ch_id"); // 通道id |
| | | t_json["likeDate"] = AppUtil::getTimeSecString(); // 比对时间 |
| | | t_json["picAddress"] = m_sdkRule.strAddr.toStdString();// 抓拍地址 |
| | | DBG("picAddress="<<m_sdkRule.strAddr.toStdString()); |
| | | t_json["picMaxUrl"] = "wait todo"; // 大图路径 |
| | | t_json["picMaxUrl"] = ""; // 大图路径 |
| | | |
| | | |
| | | // t_json["Age"] ="wait todo"; |
| | | t_json["picDate"] = time; // 抓拍时间,必须有 |
| | | DBG("picDate="<<time); |
| | | t_json["picLocalUrl"] = "wait todo"; // 本地路径 |
| | | t_json["picLocalUrl"] = ""; // 本地路径 |
| | | t_json["isDelete"] = "1";//默认1 ,0无效 1有效 |
| | | |
| | | t_json["likePer"] = "0"; // 相似值 |
| | | t_json["likePer"] = 1.0; // 相似值 |
| | | |
| | | t_json["BaseName"] = "wait todo";// 地库名称 |
| | | t_json["BaseName"] = "";// 地库名称 |
| | | |
| | | t_json["videoNum"] = m_sdkRule.strCamId.toStdString();//Video设备编号 |
| | | t_json["picSmUrl"] = imgUrl; // 抓拍图片 |
| | | t_json["indeviceid"] = appPref.getStringData("fxDevID");;// 设备id |
| | | t_json["idcard"] = "wait todo"; |
| | | t_json["personId"] = "wait todo"; |
| | | t_json["idcard"] = ""; |
| | | t_json["personId"] = ""; |
| | | t_json["indevicename"] = appPref.getStringData("fxDevNAME");// 设备名称 |
| | | t_json["FaceFeature"] = "base64"; |
| | | t_json["personIsHub"] = m_triggerElement.getTriggerState() ? "1" : "4"; //1: 报警 2: 可疑 3: 安全 4: 未知 |
| | |
| | | // DBG("RECT x="<<rect.x<<"y"<<rect.y<<"w"<<rect.width<<"h"<<rect.height); |
| | | return rect; |
| | | } |
| | | bool PerimeterElement::isAnd() |
| | | { |
| | | |
| | | } |
| | |
| | | void setMask(std::string mask); |
| | | bool isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek); |
| | | cv::Rect CutMask(); |
| | | bool isAnd(); |
| | | private: |
| | | cv::Mat image; |
| | | //cv::Mat mask; |
| | |
| | | EsDBTool* pManagerEsDB; |
| | | |
| | | |
| | | int npts; |
| | | int npts; |
| | | std::vector<cv::Rect> m_recVec; |
| | | |
| | | bool m_bIsMask; |
| | | std::vector<Point> poly1; |
| | | |
| | | cv::Point2i* pointArray; |
| | | |
| | | }; |
| | | |
| | |
| | | // faceRpcElement.setProperty("frame_number", frame_number); |
| | | t_json["picDate"] = obj.properties["time"]; |
| | | t_json["content"] = "wait todo"; |
| | | t_json["viType"] = "2";//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型 |
| | | t_json["sdkType"] = std::to_string(m_sdkRule.nSdkType); |
| | | //t_json["viType"] = "2";//只有4种类型 1:personface 2:personbody 3:car 4:bicycle 5:none 未知类型 |
| | | t_json["personIsHub"] = "4";//1: 报警 2: 可疑 3: 安全 4: 未知 |
| | | t_json["videoIp"] = getProperty("local_ip");//当前服务器IP地址 |
| | | |
| | |
| | | using namespace std; |
| | | |
| | | struct ScoredRect { |
| | | ScoredRect() : id(-1) ,isMove(false){} |
| | | ScoredRect() : id(-1) ,isMove(false),times(0){} |
| | | bool isMove; |
| | | time_t times; |
| | | float score; |
| | | cv::Rect rect; |
| | | long id; |
| | |
| | | QDateTime tim_start_time;//开始下载的文件的时间 |
| | | int n_duration;//每次下载的时间长度,单位:小时 |
| | | QString str_brand;//品牌 |
| | | QString str_reserved;//预留 |
| | | QString str_reserved;//截图地址 |
| | | }; |
| | | |
| | | struct Record_Cam_Dev |
| | |
| | | return false; |
| | | } |
| | | } |
| | | bool LDBTool::updateCamDevSnapshot(const QString& strIp,const QString& imgUrl) |
| | | { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("cam_dev"); |
| | | pModel.setFilter( |
| | | QObject::tr("ip = '%1'").arg(strIp)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | |
| | | QSqlRecord rec = pModel.record(0); |
| | | rec.setValue("reserved", imgUrl); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount > 0) |
| | | { |
| | | pModel.setRecord(0, rec);//TODO |
| | | } |
| | | |
| | | m_db.transaction();//开始事务操作 |
| | | |
| | | if (pModel.submitAll()) |
| | | { |
| | | m_db.commit();//提交 |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | m_db.rollback();//回滚 |
| | | ERR("updateCamDevSnapshot err ,Database Error: " << pModel.lastError().text().toStdString()); |
| | | return false; |
| | | } |
| | | } |
| | | int LDBTool::searchCamDevNumber(void) { |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("cam_dev"); |
| | |
| | | std::list<Record_Cam_Dev> searchCamDevTableAll(void); |
| | | int searchCamDevNumber(void); |
| | | bool searchCamDevByCamId(QString strCamId); |
| | | bool updateCamDevSnapshot(const QString& strIp ,const QString& imgUrl); |
| | | |
| | | //load_file_info |
| | | bool insertLoadFileTable(Record_Load_File_info loadfileRec); |
| | |
| | | // return -1; |
| | | // } |
| | | |
| | | int gpuindex = 1; |
| | | int gpuindex = 0; |
| | | int poolNum = 1; |
| | | int portNum = 10003; |
| | | |