VideoToImageMulth和VideoAnalyFromHC支持RPC的端口设置
| | |
| | | } |
| | | videoCaptureElement.registerConnector([&]{ |
| | | //if(!videoPublishElement.isBusy()){ |
| | | //videoPublishElement.setImage(videoCaptureElement.getImage()); |
| | | videoPublishElement.setImage(videoCaptureElement.getImage()); |
| | | //videoPublishElement.submit(); |
| | | //} |
| | | |
| | |
| | | FaceDetect::Faces FaceDetectServerI::faceDetect(Ice::Int width, Ice::Int height, const std::string &shareMemoryName, |
| | | const Ice::Current &) { |
| | | ClockTimer ct("FaceDetectServerI::faceDetect"); |
| | | INFO("Face Detect"); |
| | | FaceDetect::Faces faces; |
| | | QSharedMemory shareMemory(QString(shareMemoryName.c_str())); |
| | | if (shareMemory.attach()) { |
| | |
| | | |
| | | FaceDetect::ThftResult FaceDetectServerI::faceProperty(Ice::Int width, Ice::Int height, const FaceDetect::FacePos &pos, |
| | | const std::string &shareMemoryName, const Ice::Current &) { |
| | | INFO("faceProperty"); |
| | | QSharedMemory shareMemory(QString(shareMemoryName.c_str())); |
| | | if (shareMemory.attach()) { |
| | | FaceDetect::ThftResult thftResult; |
| | |
| | | FaceDetect::Data FaceExtractServerI::faceExtract(Ice::Int width, Ice::Int height, const FaceDetect::FacePos &pos, |
| | | const std::string &shareMemoryName, const Ice::Current &) { |
| | | ClockTimer ct("FaceExtractServerI::faceExtract"); |
| | | INFO("faceExtract"); |
| | | QSharedMemory shareMemory(QString(shareMemoryName.c_str())); |
| | | FaceDetect::Data feature; |
| | | if (shareMemory.attach()) { |
| | |
| | | |
| | | //} |
| | | AppPipeController::AppPipeController(std::string folderPath, const SdkRuleMap &ruleMap) : |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp"), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp"), |
| | | videoCaptureElement("filePath", 25, -1, appPref.getLongData("gpu.index")), |
| | | // videoCaptureElement(40), |
| | | m_index(0), |
| | |
| | | // intKeepRight(); |
| | | //} |
| | | AppPipeController::AppPipeController(std::string camId, const SdkRuleMap &ruleMap, bool RecordVideoEnable) : |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp"), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp"), |
| | | videoCaptureElement(appPref.getStringData(camId + "rtsp"), 25, 3000, appPref.getLongData("gpu.index")), |
| | | // videoCaptureElement(40), |
| | | m_index(0), |
| | |
| | | appPref.getIntData("faceSear.port"), "tcp"), |
| | | // faceSearchRpcClient("faceCmServer", "", 10004, "tcp") |
| | | m_sdkRule(rule), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp") |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp") |
| | | { |
| | | sharedMemory = new QSharedMemory(QString(shareMemoryName.c_str())); |
| | | if (!sharedMemory->create(4608 * 2592 * 4)) { |
| | |
| | | } |
| | | |
| | | void FaceExtractElement::timerFunc() { |
| | | INFO("MYH Run Here"); |
| | | std::vector<FaceToExtract> faceExtractQueueTmp; |
| | | { |
| | | std::lock_guard<std::mutex> lg(imageQueueMutex); |
| | | if (faceExtractQueue.empty())return; |
| | | if (faceExtractQueue.empty()) |
| | | { |
| | | ERR("faceExtractQueue.empty "); |
| | | return; |
| | | } |
| | | faceExtractQueueTmp.swap(faceExtractQueue); |
| | | faceExtractQueue.clear(); |
| | | } |
| | |
| | | // cv::imwrite(string1, image); |
| | | // } |
| | | if (feature.empty()) { |
| | | ERR("feature is empty"); |
| | | INFO("No Face Find: "<<getProperty("imgKey")); |
| | | continue; |
| | | } |
| | | features.clear(); |
| | |
| | | } |
| | | |
| | | void FaceRpcElement::threadFunc() { |
| | | INFO("MYH Run Here"); |
| | | // ClockTimer ct("FaceRpcElement::threadFunc"); |
| | | // { |
| | | // |
| | |
| | | // cv::imwrite(string1, image); |
| | | // } |
| | | if(!isInWeek(m_sdkRule.weekRuleVec)) |
| | | { |
| | | ERR("In Week"); |
| | | return; |
| | | } |
| | | triggerMats.clear(); |
| | | triggerFaces.clear(); |
| | | triggerScoredRects.clear(); |
| | |
| | | QPoint center = re.center(); |
| | | if(m_bIsMask && !mPolygon.containsPoint(center,Qt::OddEvenFill)) |
| | | { |
| | | ERR("m_bIsMask :"<<m_bIsMask) |
| | | return; |
| | | } |
| | | scoredRect.rect = {x, y, w, h}; |
| | |
| | | CvUtil::zoomRectEqual(scoredRect.rect, 1.5, 1.5) & cv::Rect(0, 0, image.cols, image.rows)).clone()); |
| | | triggerScoredRects.push_back(trackingTrigger->getLastRect()); |
| | | } else { |
| | | INFO("No Face Find: "<<getProperty("imgKey")); |
| | | // DBG("trackingTrigger->triggerOnce(scoredRect) is false "); |
| | | } |
| | | } |
| | | if(faces.empty()) |
| | | { |
| | | INFO("No Face Find: "<<getProperty("imgKey")); |
| | | } |
| | | trackingTrigger->triggerLine(); |
| | | // DBG("faces.size " << faces.size()); |
| | | if (getLastScoreRects().size() > 0) { |
| | |
| | | m_bSetWH(false), |
| | | pointArray(nullptr), |
| | | npts(0), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp") |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp") |
| | | { |
| | | pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | | } |
| | |
| | | #include <map> |
| | | #include <list> |
| | | #include <opencv2/opencv.hpp> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | //#include <basic/pipe/TimerElement.h> |
| | | #include "YoloRpcElement.h" |
| | | #include <QSharedMemory> |
| | |
| | | |
| | | class JudgmentRetrogradeTool : public basic::PipeElement{ |
| | | public: |
| | | JudgmentRetrogradeTool():m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp") {} |
| | | JudgmentRetrogradeTool():m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp") {} |
| | | |
| | | JudgmentRetrogradeTool(const SdkRule &rule); |
| | | //JudgmentRetrogradeTool(const SdkRule &rule,SaveVideoRpcClient_t& rpcClient); |
| | |
| | | m_bIsMask(true), |
| | | m_bSetWH(false), |
| | | pointArray(nullptr), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp") |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp") |
| | | { |
| | | |
| | | pManagerEsDB = new EsDBTool(appPref.getStringData("ipAdd"), appPref.getIntData("ipPort")); |
| | |
| | | #include "TrackingTrigger.h" |
| | | #include <QJsonArray> |
| | | #include <RapidStructureApp/TriggerElement.h> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include <basic/util/fastdfs/FastFds.hpp> |
| | | #include "DBStruct.h" |
| | | #include <basic/db/Elasticsearch/EsDBTool.h> |
| | |
| | | class PerimeterElement : public basic::PipeElement |
| | | { |
| | | public: |
| | | PerimeterElement():m_rpcClient("RtspAnalysServer", "127.0.0.1",10009,"tcp"){} |
| | | PerimeterElement():m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"tcp"){} |
| | | PerimeterElement(const SdkRule& rule); |
| | | public: |
| | | ~PerimeterElement(); |
| | |
| | | ENABLEGLOG(GET_STR_CONFIG("logPath").c_str()); |
| | | #endif |
| | | |
| | | appPref.setLongData("gpu.index", 1); |
| | | appPref.setLongData("gpu.index", 0); |
| | | appPref.setIntData("show.image", 0); |
| | | |
| | | //todo |
| | | appPref.setIntData("CamStart", atoi(argv[1])); |
| | | appPref.setIntData("CamStep", atoi(argv[2])); |
| | | appPref.setIntData("RpcServerPort",atoi(argv[3])); |
| | | |
| | | //#todo get from config File |
| | | // appPref.setStringData("ipAdd", "192.168.1.185"); |
| | |
| | | using std::string; |
| | | |
| | | RtspAnalysManager::RtspAnalysManager(LDBTool *_dbTool) : m_lDBTool(nullptr), m_maxCount(50), m_currentCount(0) { |
| | | INFO("MYH DEBUG HERE"); |
| | | m_lDBTool=new LDBTool; |
| | | init(); |
| | | |
| | |
| | | |
| | | //初始化函数 |
| | | void RtspAnalysManager::init() { |
| | | |
| | | INFO("MYH DEBUG HERE") |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | |
| | |
| | | appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration); |
| | | appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration); |
| | | if (lst.size() > 0) { |
| | | |
| | | int startCamNO = appPref.getIntData("CamStart") * appPref.getIntData("CamStep"); |
| | | int CamCount = appPref.getIntData("CamStep"); |
| | | INFO("StartCamNO: "<<startCamNO<<" CamStep: "<<CamCount); |
| | | auto itor = lst.begin(); |
| | | |
| | | if(startCamNO >= lst.size()) |
| | |
| | | } |
| | | |
| | | for(int i=0; i < startCamNO; i++){ |
| | | |
| | | std::string t_camIdex = itor->str_cam_dev_id.toStdString(); |
| | | std::string rtsp_url = rtspAddrBuild(itor->str_ip.toStdString(), 554, itor->str_username.toStdString(), |
| | | itor->str_password.toStdString(), itor->str_brand.toStdString()); |
| | | INFO("JumpCam: "<<t_camIdex<<" URL: "<<rtsp_url); |
| | | itor++; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | RtspAnalysManager::~RtspAnalysManager() { |
| | | INFO("Program Exit"); |
| | | for (auto controller: m_controllers) { |
| | | INFO("Delete Controller: "<<controller.first); |
| | | delete controller.second; |
| | | } |
| | | m_controllers.clear(); |
| | |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | |
| | | if (m_controllers.find(index) == m_controllers.end()) { |
| | | INFO("MYH DEBUG HERE"); |
| | | if (m_currentCount >= m_maxCount) { |
| | | ERR("addCamera faild, camera's num is full!") |
| | | return -1; |
| | | } |
| | | DBG("RTSP: "<<rtsp<<" INDEX:"<<index); |
| | | INFO("RTSP: "<<rtsp<<" INDEX:"<<index); |
| | | m_imgRedisControllers[index] = new RtspImageRedisElement(index); |
| | | m_imgRedisControllers[index]->start(); |
| | | |
| | |
| | | |
| | | } else { |
| | | removeCamera(index); |
| | | DBG("removeCamera " << index); |
| | | INFO("removeCamera " << index); |
| | | //DBG("removeCamera " << index); |
| | | return addCamera(index, rtsp); |
| | | } |
| | | } |
| | |
| | | * @return 总是0 |
| | | */ |
| | | int RtspAnalysManager::removeCamera(const std::string &index) { |
| | | INFO("MYH DEBUG HERE"); |
| | | if (m_controllers.find(index) == m_controllers.end())return -1; |
| | | auto controller = m_controllers[index]; |
| | | controller->stop(); |
| | |
| | | imgRedis->wait(); |
| | | delete imgRedis; |
| | | m_imgRedisControllers.erase(index); |
| | | INFO("MYH DEBUG HERE"); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | int RtspAnalysManager::removeAll() { |
| | | INFO("MYH DEBUG HERE"); |
| | | for (auto controller: m_controllers) { |
| | | controller.second->stop(); |
| | | } |
| | |
| | | delete controller.second; |
| | | } |
| | | m_controllers.clear(); |
| | | INFO("MYH DEBUG HERE"); |
| | | |
| | | |
| | | for (auto controller: m_imgRedisControllers) { |
| | |
| | | |
| | | |
| | | m_currentCount = 0; |
| | | INFO("MYH DEBUG HERE"); |
| | | return 0; |
| | | } |
| | | |
| | |
| | | //保存视频到RtspImageRedis的队列,由RtspCaptureElement调用 |
| | | bool RtspAnalysManager::SaveImageToRedis(const std::string& camId,const std::string& imageName,const cv::Mat& img) |
| | | { |
| | | INFO("MYH DEBUG HERE"); |
| | | auto item = m_imgRedisControllers.find(camId); |
| | | if(item!=m_imgRedisControllers.end()) |
| | | { |
| | | INFO("Save Succeed Cam: "<<camId<<" ImageKey: "<<imageName); |
| | | item->second->SaveImage(imageName,img); |
| | | } else { |
| | | ERR("Save Failed Cam: "<<camId<<" ImageKey: "<<imageName); |
| | | } |
| | | INFO("MYH DEBUG HERE"); |
| | | return true; |
| | | } |
| | | |
| | |
| | | } |
| | | void RtspCaptureElement::SaveVideo(const std::string &strImageName) |
| | | { |
| | | INFO("SaveVideo: "<<strImageName); |
| | | std::string strTimeStamp= AppUtil::getTimeUSecString(); |
| | | std::string strPath=MakeDir(strTimeStamp); |
| | | m_capture->SaveVideoByImageName(strPath,strImageName); |
| | |
| | | if(m_gpuIndex>=0){ |
| | | setenv("CUDA_VISIBLE_DEVICES", std::to_string(m_gpuIndex).c_str(),0); |
| | | } |
| | | INFO("Open Video "<<m_path<<" GPU_Index: "<<m_gpuIndex); |
| | | m_capture->open(m_path.c_str(),m_gpuIndex>=0); |
| | | } |
| | | |
| | | void RtspCaptureElement::threadInitial() |
| | | { |
| | | INFO("MYH DEBUG"); |
| | | openVideo(); |
| | | } |
| | | |
| | | void RtspCaptureElement::threadClosing() |
| | | { |
| | | INFO("MYH DEBUG"); |
| | | m_capture->close(); |
| | | delete m_capture; |
| | | m_capture = nullptr; |
| | |
| | | m_redisTool.setKeyImage(item.m_imgName,item.m_image); |
| | | m_redisTool.listLpush(m_camId, item.m_imgName); |
| | | m_imageQueue.pop(); |
| | | INFO("SaveImage To Redis Succeed CamID:"<<m_camId<<" ImageName:"<<item.m_imgName); |
| | | } |
| | | } |
| | | |
| | | //继承自父类,线程初始化的一些工作 |
| | | void RtspImageRedisElement::threadInitial() |
| | | { |
| | | |
| | | INFO("MYH DEBUG HERE"); |
| | | } |
| | | |
| | | //继承自父类,线程结束的时候调用 |
| | | void RtspImageRedisElement::threadClosing() |
| | | { |
| | | INFO("MYH DEBUG HERE"); |
| | | } |
| | | |
| | | //保存图片到队列中, |
| | |
| | | //保证队列中的图片不要过多 |
| | | if(m_imageQueue.size() < M_CAM_PIC_MAX_COUNT) |
| | | { |
| | | INFO("SaveImage Succeed ImgName:"<<imageName); |
| | | m_imageQueue.push(NameImagePair_s_t(imageName,img)); |
| | | } |
| | | else{ |
| | | ERR("SaveImage Failed ImgName:"<<imageName); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | //todo |
| | | appPref.setIntData("CamStart", atoi(argv[1])); |
| | | appPref.setIntData("CamStep", atoi(argv[2])); |
| | | appPref.setIntData("RpcServerPort",atoi(argv[3])); |
| | | |
| | | appPref.setStringData("user.loop.absolute.path", appConfig.getStringProperty("cutPath")); |
| | | IceRpcServer<RtspAnalysManager> server("RtspAnalysServer", 10009, "tcp"); |
| | | IceRpcServer<RtspAnalysManager> server("RtspAnalysServer",appPref.getIntData("RpcServerPort"), "tcp"); |
| | | server.setMessageSizeMax(1024 * 1024 * 50); |
| | | server.setPoolInitSize(1); |
| | | server.setPoolMaxSize(1); |