| | |
| | | std::string publish_basepath = "rtmp://localhost:1934/live/cam" + std::to_string(554); |
| | | appPref.setIntData("gpu.index", 0); |
| | | appPref.setStringData("publish.basepath", publish_basepath); |
| | | appPref.setIntData("pulish.width", 640); |
| | | appPref.setIntData("pulish.height", 360); |
| | | // appPref.setIntData("pulish.width", 640); |
| | | // appPref.setIntData("pulish.height", 360); |
| | | |
| | | AppPipeController a(0, json); |
| | | a.start(); |
| | |
| | | VssDomainUnitTblController::instance()->registerHttpServices(_HttpSrvRetRecieve); |
| | | VssLocalSettingTblController::instance()->registerHttpServices(_HttpSrvRetRecieve); |
| | | CamDevController::instance()->registerHttpServices(_HttpSrvRetRecieve); |
| | | //todo |
| | | CamDevController::instance()->nsqMsgProducerSet(nsqMsgProducer); |
| | | VssUpperSvrTblController::instance()->registerHttpServices(_HttpSrvRetRecieve); |
| | | |
| | | |
| | |
| | | #include "vss/model/CamDev.h" |
| | | #include "VssBaseController.h" |
| | | #include <mysql++.h> |
| | | #include <NsqMsgTool.hpp> |
| | | |
| | | using namespace std; |
| | | |
| | |
| | | static CamDevController *instance() { |
| | | static CamDevController instance; |
| | | return &instance; |
| | | } |
| | | |
| | | private: |
| | | //shared_ptr |
| | | BasicMsg::Nsq::NsqMsgProducer *_nsqMsgProducer; |
| | | public: |
| | | void nsqMsgProducerSet(BasicMsg::Nsq::NsqMsgProducer *nsqMsgProducer){ |
| | | _nsqMsgProducer = nsqMsgProducer; |
| | | } |
| | | |
| | | public: |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | { |
| | | std::string topic = "VideoToImageMulth"; |
| | | std::string topic1 = "VideoAnalysFromHC"; |
| | | Json::Value json_cfg; |
| | | json_cfg["cam_del"] = content; |
| | | std::string msg = json_cfg.toStyledString(); |
| | | DBG("msg:" << msg); |
| | | _nsqMsgProducer->Publish(topic, (void *) (&msg)); |
| | | _nsqMsgProducer->Publish(topic1, (void *) (&msg)); |
| | | } |
| | | |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | |
| | | idJsonValue.asString()); |
| | | } |
| | | } |
| | | |
| | | { |
| | | std::string topic = "VideoToImageMulth"; |
| | | std::string topic1 = "VideoAnalysFromHC"; |
| | | Json::Value json_cfg; |
| | | json_cfg["cam_edit"] = content; |
| | | std::string msg = json_cfg.toStyledString(); |
| | | DBG("msg:" << msg); |
| | | _nsqMsgProducer->Publish(topic, (void *) (&msg)); |
| | | _nsqMsgProducer->Publish(topic1, (void *) (&msg)); |
| | | } |
| | | |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | |
| | | |
| | | bool BASICGB28181::FFmpegDecoderJPG::stopThd() { |
| | | TryCath( |
| | | DBG(m_camIdx << " FFmpegDecoderJPG stopThd ... " << m_camIdx); |
| | | DBG("FFmpegDecoderJPG stopThd ... " << m_camIdx); |
| | | m_running = false; |
| | | ); |
| | | return true; |
| | |
| | | } else { |
| | | |
| | | // 根据reopenTime判断是否需要重启 |
| | | if (reopenTime < 0) { |
| | | if (p_this->reopenTime < 0) { |
| | | p_this->m_running = false; |
| | | stop(); |
| | | INFO("grabFrame faild, element stopping"); |
| | | } else { |
| | | //todo 业务死锁 |
| | | usleep((6 - reopenTime--) * 1000000); |
| | | INFO("grabFrame faild, try reopen video, reopenTime:" << reopenTime); |
| | | usleep((6 - p_this->reopenTime--) * 1000000); |
| | | INFO("grabFrame faild, try reopen video, reopenTime:" << p_this->reopenTime); |
| | | |
| | | //关闭ffmpeg解码模块 |
| | | p_this->m_fFmpegDecoderJPG.stopThd(); |
| | |
| | | } |
| | | |
| | | void FaceExtractElement::timerFunc() { |
| | | INFO("MYH Run Here"); |
| | | // INFO("MYH Run Here"); |
| | | std::vector<FaceToExtract> faceExtractQueueTmp; |
| | | { |
| | | std::lock_guard<std::mutex> lg(imageQueueMutex); |
| | | if (faceExtractQueue.empty()) { |
| | | ERR("faceExtractQueue.empty "); |
| | | // ERR("faceExtractQueue.empty "); |
| | | return; |
| | | } |
| | | faceExtractQueueTmp.swap(faceExtractQueue); |
| | |
| | | float t_com_sc = m_sdkRule.nThreshold == 0 ? 75 : m_sdkRule.nThreshold; |
| | | |
| | | |
| | | DBG(" TESTCODE getValue" << t_camIdex << " " << t_com_sc << " " << t_com_sc / 100); |
| | | // DBG(" TESTCODE getValue" << t_camIdex << " " << t_com_sc << " " << t_com_sc / 100); |
| | | |
| | | t_com_sc = t_com_sc / 100; |
| | | |
| | |
| | | |
| | | unsigned long size = faceExtractQueueTmp[i].facesPos.size(); |
| | | for (int j = 0; j < size; j++) { |
| | | auto feature = extractServer->faceExtract(image.cols, image.rows, faceExtractQueueTmp[i].facesPos[j], |
| | | auto feature = extractServer->faceExtract(image.cols, image.rows, faceExtractQueueTmp[i].facesPos[j], |
| | | sharedMemory->key().toStdString()); |
| | | // { |
| | | // //#todo |
| | |
| | | // cv::imwrite(string1, image); |
| | | // } |
| | | if (feature.empty()) { |
| | | INFO("No Face Find: " << getProperty("imgKey")); |
| | | // INFO("No Face Find: " << getProperty("imgKey")); |
| | | continue; |
| | | } |
| | | features.clear(); |
| | |
| | | std::string strImgUrlTmp = ""; |
| | | fdfsClient->fastFds->uploadFile(buffer, strImgUrlTmp, "jpg"); |
| | | // strImgUrl.append(fdfsClient->fastFds->getIp() + "/" + strImgUrlTmp); |
| | | DBG("strImgUrlTmp=" << strImgUrlTmp); |
| | | // DBG("strImgUrlTmp=" << strImgUrlTmp); |
| | | strImgUrl.clear(); |
| | | strImgUrl = strImgUrlTmp; |
| | | // strImgUrl.append("/").append(strImgUrlTmp); |
| | |
| | | //#todo 使用策略模式?发送端多个指令累积后发送? |
| | | if (itor_json->isString() && reader.parse(itor_json->asString(), cfg_val)) { |
| | | if (itor_json.name() == "cam_edit" || itor_json.name() == "editSdkRule") { |
| | | string cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | string cam_idx = ""; |
| | | if(itor_json.name() == "cam_edit"){ |
| | | if (pthis->m_GB28181_Enable){ |
| | | cam_idx = cfg_val["equipCode"].asString(); |
| | | }else{ |
| | | cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | } |
| | | } else { |
| | | cam_idx = cfg_val["strCamId"].asString(); |
| | | } |
| | | |
| | | if (pthis->controllers.find(cam_idx) != pthis->controllers.end()) { |
| | | if (pthis->m_GB28181_Enable) { |
| | | auto lst = pthis->m_lDBTool->searchCamDevTableByType(1); |
| | |
| | | } |
| | | } |
| | | } else if (itor_json.name() == "cam_del") { |
| | | string cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | // string cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | string cam_idx = ""; |
| | | if(cfg_val["equipCode"].asString().size()){ |
| | | cam_idx = cfg_val["equipCode"].asString(); |
| | | }else if(cfg_val["str_cam_dev_id"].asString().size()){ |
| | | cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | } |
| | | pthis->removeCamera(cam_idx); |
| | | } |
| | | } else { |
| | |
| | | } |
| | | } |
| | | } else if (itor_json.name() == "cam_edit") { |
| | | string cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | string cam_idx = ""; |
| | | if(pthis->m_GB28181_Enable){ |
| | | cam_idx = cfg_val["equipCode"].asString(); |
| | | }else{ |
| | | cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | } |
| | | |
| | | if (pthis->m_GB28181_Enable) { |
| | | if (pthis->m_controllers_videoCapElem.find(cam_idx) != |
| | | pthis->m_controllers_videoCapElem.end()) { |
| | |
| | | } |
| | | } |
| | | } else if (itor_json.name() == "cam_del") { |
| | | string cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | string cam_idx = ""; |
| | | if(pthis->m_GB28181_Enable){ |
| | | cam_idx = cfg_val["equipCode"].asString(); |
| | | }else{ |
| | | cam_idx = cfg_val["str_cam_dev_id"].asString(); |
| | | } |
| | | pthis->removeCamera(cam_idx); |
| | | } else if (itor_json.name() == "cam_startPublish") { |
| | | string cam_idx = cfg_val["id"].asString(); |
| | |
| | | } |
| | | } |
| | | |
| | | m_picCount++; |
| | | //几张选一张放入Redis |
| | | if (m_picCount % m_nPicsPickOne != 0) { |
| | | return; |
| | | } else { |
| | | m_picCount.store(0); |
| | | } |
| | | u_char *data; |
| | | int width = 0, height = 0, step = 0, cn = 0; |
| | | cv::Mat copyMat; |
| | | |
| | | { |
| | | u_char *data; |
| | | int width = 0, height = 0, step = 0, cn = 0; |
| | | m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn); |
| | | |
| | | cv::Mat img(height, width, CV_8UC3, data, step); |
| | | cv::Mat copyMat; |
| | | img.copyTo(copyMat); |
| | | std::string imageName = m_capture->GetImageName(); |
| | | m_pManager->SaveImageToRedis(m_camId, imageName, copyMat); |
| | | } |
| | | //#todo publish Video |
| | | //#publish Video |
| | | if (m_publishVideoRet) { |
| | | if (videoPublishElement == nullptr) { |
| | | string path = appConfig.getStringProperty("srsAddr") + "cam" + m_camId + ".flv"; |
| | | cv::Size size_(appConfig.getIntProperty("pulish.width"), appConfig.getIntProperty("pulish.height")); |
| | | int gupIdx = appPref.getIntData("gpu.index"); |
| | | videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx); |
| | | videoPublishElement->start(); |
| | | } else { |
| | | // DBG("videoPublishElement->setImage()"); |
| | | m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn); |
| | | cv::Mat img(height, width, CV_8UC3, data, step); |
| | | img.copyTo(copyMat); |
| | | |
| | | if (!copyMat.empty()) { |
| | | videoPublishElement->setImage(copyMat); |
| | | } else { |
| | | DBG("copyMat.empty()"); |
| | | } |
| | | } |
| | | } else { |
| | | if (videoPublishElement != nullptr) { |
| | | DBG("videoPublishElement->stop()"); |
| | | videoPublishElement->stop(); |
| | | videoPublishElement->wait(); |
| | | delete videoPublishElement; |
| | | videoPublishElement = nullptr; |
| | | } |
| | | } |
| | | |
| | | //几张选一张放入Redis |
| | | m_picCount++; |
| | | if (m_picCount % m_nPicsPickOne != 0) { |
| | | // return; |
| | | } else { |
| | | m_picCount.store(0); |
| | | |
| | | if (copyMat.empty()) { |
| | | // ERR("copyMat.empty()"); |
| | | m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn); |
| | | cv::Mat img(height, width, CV_8UC3, data, step); |
| | | img.copyTo(copyMat); |
| | | } |
| | | std::string imageName = m_capture->GetImageName(); |
| | | m_pManager->SaveImageToRedis(m_camId, imageName, copyMat); |
| | | } |
| | | |
| | | fireConnectors(); |
| | | } |
| | | |
| | |
| | | |
| | | if (colorIndex < 0 || colorIndex >= 9)continue; |
| | | if(colorIndex==4) DBG("detect a car, score =" << result.info[i].obj_score); |
| | | if(colorIndex==1) DBG("detect a bike, score =" << result.info[i].obj_score); |
| | | if(colorIndex==2) DBG("detect a moto, score =" << result.info[i].obj_score); |
| | | // sprintf(str_i, "%s:%.2f", type[colorIndex].c_str(), result.info[i].obj_score); |
| | | |
| | | // rectangle(process_image, |