| | |
| | | #add_subdirectory(VideoToImage) |
| | | add_subdirectory(UnitTest) |
| | | add_subdirectory(VideoToImageMulth) |
| | | add_subdirectory(GB28181DecoderModel) |
| | | #add_subdirectory(GB28181DecoderModel) |
| | | #add_subdirectory(FaceSearchDbWithImg) |
| | | |
| | |
| | | HCCore |
| | | hcnetsdk |
| | | pthread |
| | | # mysqlpp |
| | | mysqlpp |
| | | ) |
| | | |
| | | #add_executable(Apptest |
| | |
| | | // appConfig.getIntProperty("db_port") |
| | | // )) { |
| | | if (conn->connect( |
| | | "basic_business_table", |
| | | "EGEyesForVSS", |
| | | "127.0.0.1", |
| | | "root", |
| | | "root", |
| | | "123456", |
| | | 3306 |
| | | )) { |
| | | cout << "connect success" << endl; |
| | |
| | | ENABLEGLOG(GET_STR_CONFIG("logPath").c_str()); |
| | | auto ich = Ice::initialize(argc, argv); |
| | | |
| | | appPref.setLongData("gpu.index", 1); |
| | | appPref.setLongData("gpu.index", 0); |
| | | appPref.setLongData("thread.max", 32); |
| | | |
| | | IceRpcServer<FaceDetectServerI> server("faceServer", 10002, "tcp"); |
| | |
| | | ../../../BasicPlatForm/libs/Ice-3.7.0/lib64 |
| | | ../../../BasicPlatForm/libs/opencv/lib |
| | | ../../../BasicPlatForm/libs/ffmpeg/lib |
| | | ../../../BasicPlatForm/libs/Casia_Face/FaceSdk/lib/cpu |
| | | ../../../BasicPlatForm/libs/Casia_Face/FaceSdk/lib/gpu |
| | | ../../../BasicPlatForm/libs/crul/lib |
| | | ../../../BasicPlatForm/libs/jsoncpp/lib |
| | | ../../../BasicPlatForm/libs/libuuid/lib |
| | |
| | | |
| | | DBG("\n\n\nstart\n\n"); |
| | | |
| | | appPref.setLongData("thread.max", 32); |
| | | appPref.setLongData("thread.max", 16); |
| | | //#todo |
| | | |
| | | // appPref.setStringData("ipAdd", "192.168.1.185"); |
| | |
| | | #include <qt5/QtCore/QDateTime> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include "VideoCaptureElementWithRtp.h" |
| | | #include "RtspAnalysManager.h" |
| | | #include <VideoToImageMulth/RtspAnalysManager.h> |
| | | |
| | | //std::string BASICGB28181::VideoCaptureElementWithRtp::m_chanPubID; |
| | | //BASICGB28181::FFmpegDecoderJPG BASICGB28181::VideoCaptureElementWithRtp::m_fFmpegDecoderJPG; |
| | |
| | | int m_index; |
| | | std::string m_camId; |
| | | std::string m_folderPath; |
| | | Json::Value m_json; |
| | | Json::Value m_json_Record; |
| | | // Json::Value m_json; |
| | | // Json::Value m_json_Record; |
| | | // Json::FastWriter m_fastWriter; |
| | | |
| | | Json::FastWriter m_fastWriter; |
| | | FastFdsWithLock *fdfsClient; |
| | | |
| | | bool bRecordVideoEnable; |
| | |
| | | appPref.getIntData("faceSear.port"), "tcp"), |
| | | // faceSearchRpcClient("faceCmServer", "", 10004, "tcp") |
| | | m_sdkRule(rule), |
| | | m_rpcClient("RtspAnalysServer", "127.0.0.1",appPref.getIntData("RpcServerPort"),"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)) { |
| | | sharedMemory->attach(); |
| | |
| | | std::vector<FaceToExtract> faceExtractQueueTmp; |
| | | { |
| | | std::lock_guard<std::mutex> lg(imageQueueMutex); |
| | | if (faceExtractQueue.empty()) |
| | | { |
| | | if (faceExtractQueue.empty()) { |
| | | ERR("faceExtractQueue.empty "); |
| | | return; |
| | | } |
| | |
| | | |
| | | 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["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: 未知 |
| | | |
| | | |
| | |
| | | |
| | | try { |
| | | auto server = m_rpcClient.getServer(); |
| | | if (!server) |
| | | { |
| | | if (!server) { |
| | | ERR("server is null"); |
| | | //return; |
| | | } |
| | | INFO("Record Video "<<strImageKey); |
| | | server->recordVideo(strImageKey); |
| | | } |
| | | catch (std::exception &e) |
| | | { |
| | | } catch (std::exception &e) { |
| | | ERR("Record Video Err: "<<strImageKey <<" Message: "<<e.what()); |
| | | //return; |
| | | } |
| | |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | #include <QJsonDocument> |
| | | #include <QJsonObject> |
| | | |
| | | #define GETSCORE(IDENT) appPref.getFloatData(IDENT) == -1 ? 95 : appPref.getFloatData(IDENT); |
| | | |
| | | //************************************ |
| | |
| | | trackingTrigger(nullptr), |
| | | m_sdkRule(rule), |
| | | m_bIsMask(true), |
| | | m_bSetWH(false) |
| | | { |
| | | m_bSetWH(false) { |
| | | sharedMemory = new QSharedMemory(QString(shareMemoryName.c_str())); |
| | | if (!sharedMemory->create(4608 * 2592 * 4)) { |
| | | sharedMemory->attach(); |
| | |
| | | |
| | | // string t_camIdex = getProperty("dev_id"); |
| | | //#todo |
| | | string t_camIdex; |
| | | if (shareMemoryName.find("/")) { |
| | | string_replace(shareMemoryName, "//", "/"); |
| | | auto dev_pos = shareMemoryName.find("/cut/") + 5; |
| | | auto ch_pos = shareMemoryName.find("/", dev_pos) + 1; |
| | | auto str_device_id = shareMemoryName.substr(dev_pos, ch_pos - dev_pos - 1); |
| | | auto str_ch_id = shareMemoryName.substr(ch_pos, shareMemoryName.find("/", ch_pos) - ch_pos); |
| | | t_camIdex.append(str_device_id).append(str_ch_id); |
| | | } else { |
| | | t_camIdex = shareMemoryName.substr(0, shareMemoryName.rfind("faceRpc")); |
| | | } |
| | | // string t_camIdex; |
| | | // if (shareMemoryName.find("/")) { |
| | | // string_replace(shareMemoryName, "//", "/"); |
| | | // auto dev_pos = shareMemoryName.find("/cut/") + 5; |
| | | // auto ch_pos = shareMemoryName.find("/", dev_pos) + 1; |
| | | // auto str_device_id = shareMemoryName.substr(dev_pos, ch_pos - dev_pos - 1); |
| | | // auto str_ch_id = shareMemoryName.substr(ch_pos, shareMemoryName.find("/", ch_pos) - ch_pos); |
| | | // t_camIdex.append(str_device_id).append(str_ch_id); |
| | | // } else { |
| | | // t_camIdex = shareMemoryName.substr(0, shareMemoryName.rfind("faceRpc")); |
| | | // } |
| | | |
| | | float t_score = m_sdkRule.nQuality; |
| | | |
| | | DBG(" TESTCODE getValue" << t_camIdex << " " << t_score << " " << t_score / 100); |
| | | DBG(" TESTCODE getValue" << shareMemoryName << " " << t_score << " " << t_score / 100); |
| | | |
| | | t_score = t_score / 100; |
| | | |
| | |
| | | // string string1(AppUtil::getTimeString() + "-ff2" + getProperty("time") + ".jpg"); |
| | | // cv::imwrite(string1, image); |
| | | // } |
| | | if(!isInWeek(m_sdkRule.weekRuleVec)) |
| | | { |
| | | if (!isInWeek(m_sdkRule.weekRuleVec)) { |
| | | ERR("In Week"); |
| | | return; |
| | | } |
| | |
| | | int h = face.rcFace.bottom - face.rcFace.top; |
| | | QRect re(x,y,w,h); |
| | | QPoint center = re.center(); |
| | | if(m_bIsMask && !mPolygon.containsPoint(center,Qt::OddEvenFill)) |
| | | { |
| | | if (m_bIsMask && !mPolygon.containsPoint(center, Qt::OddEvenFill)) { |
| | | ERR("m_bIsMask :"<<m_bIsMask) |
| | | return; |
| | | } |
| | |
| | | // DBG("trackingTrigger->triggerOnce(scoredRect) is false "); |
| | | } |
| | | } |
| | | if(faces.empty()) |
| | | { |
| | | if (faces.empty()) { |
| | | INFO("No Face Find: "<<getProperty("imgKey")); |
| | | } |
| | | trackingTrigger->triggerLine(); |
| | |
| | | image = cv::Mat(value.rows, value.cols, CV_8UC3, sharedMemory->data()); |
| | | } |
| | | value.copyTo(image); |
| | | if(!m_bSetWH) |
| | | { |
| | | if (!m_bSetWH) { |
| | | setMask(m_sdkRule.strAreas.toStdString()); |
| | | m_bSetWH=true; |
| | | } |
| | |
| | | bool FaceRpcElement::getTriggerState() const { |
| | | return m_triggerElement.getTriggerState(); |
| | | } |
| | | void FaceRpcElement::setMask(std::string mask) |
| | | { |
| | | |
| | | void FaceRpcElement::setMask(std::string mask) { |
| | | QJsonArray arrayAreas = getJsonArrayFromQString(QString::fromStdString(mask)); |
| | | if(arrayAreas.isEmpty()) |
| | | { |
| | | if (arrayAreas.isEmpty()) { |
| | | m_bIsMask=false; |
| | | return;//do not detect |
| | | } |
| | | float sizeW=(float)appPref.getIntData(m_sdkRule.strCamId.toStdString()+"width")/480; |
| | | float sizeH=(float)appPref.getIntData(m_sdkRule.strCamId.toStdString()+"height")/270; |
| | | for(int i = 0;i < arrayAreas.size();++i) |
| | | { |
| | | for (int i = 0; i < arrayAreas.size(); ++i) { |
| | | QJsonValue jsonValue = arrayAreas[i]; |
| | | QJsonObject obj = jsonValue.toObject(); |
| | | int x = obj.value("x").toDouble() *sizeW ; |
| | |
| | | |
| | | } |
| | | } |
| | | QJsonArray FaceRpcElement::getJsonArrayFromQString(const QString& strJson) |
| | | { |
| | | |
| | | QJsonArray FaceRpcElement::getJsonArrayFromQString(const QString &strJson) { |
| | | QJsonDocument jsonDocument = QJsonDocument::fromJson(strJson.toLocal8Bit()); |
| | | if( jsonDocument.isNull() ){ |
| | | DBG("please check the string"<< strJson.toStdString()); |
| | |
| | | QJsonArray jsonArray = jsonDocument.array(); |
| | | return jsonArray; |
| | | } |
| | | bool FaceRpcElement::isInWeek(const std::vector<LActRuleWeekRecord>& ruleWeek) |
| | | { |
| | | |
| | | bool FaceRpcElement::isInWeek(const std::vector<LActRuleWeekRecord> &ruleWeek) { |
| | | |
| | | int nWeek = QDate::currentDate().dayOfWeek(); |
| | | for(int i = 0;i < ruleWeek.size();++i) |
| | | { |
| | | if(ruleWeek[i].m_nType == nWeek) |
| | | { |
| | | for (int i = 0; i < ruleWeek.size(); ++i) { |
| | | if (ruleWeek[i].m_nType == nWeek) { |
| | | QString strCurrent = QDateTime::currentDateTime().toString("hh:mm"); |
| | | if(strCurrent >= ruleWeek[i].m_strBegin && strCurrent <= ruleWeek[i].m_strEnd) |
| | | { |
| | | if (strCurrent >= ruleWeek[i].m_strBegin && strCurrent <= ruleWeek[i].m_strEnd) { |
| | | return true; |
| | | } |
| | | } |
| | |
| | | using TASK_FUNCTION = std::function<void(std::shared_ptr<finishSdkHdlManage> &, int)>; |
| | | public: |
| | | BaiscSDKAnalysVideo(TASK_FUNCTION task_f = nullptr) : m_task_function(task_f) { |
| | | resetFdfs(); |
| | | { |
| | | std::thread httpServer([&]() { |
| | | HttpSrvRetRecieve httpSrvRetRecieve("0.0.0.0", 9090, 1); |
| | | httpSrvRetRecieve.setInfo("^/resetFdfs$", "POST", std::bind(&BaiscSDKAnalysVideo::resetFdfs, this, |
| | | std::placeholders::_1, |
| | | std::placeholders::_2, |
| | | std::placeholders::_3)); |
| | | httpSrvRetRecieve.start(); |
| | | httpSrvRetRecieve.waitForShutDown(); |
| | | }); |
| | | httpServer.detach(); |
| | | } |
| | | // resetFdfs(); |
| | | // { |
| | | // std::thread httpServer([&]() { |
| | | // HttpSrvRetRecieve httpSrvRetRecieve("0.0.0.0", 9090, 1); |
| | | // httpSrvRetRecieve.setInfo("^/resetFdfs$", "POST", std::bind(&BaiscSDKAnalysVideo::resetFdfs, this, |
| | | // std::placeholders::_1, |
| | | // std::placeholders::_2, |
| | | // std::placeholders::_3)); |
| | | // httpSrvRetRecieve.start(); |
| | | // httpSrvRetRecieve.waitForShutDown(); |
| | | // }); |
| | | // httpServer.detach(); |
| | | // } |
| | | } |
| | | |
| | | ~BaiscSDKAnalysVideo() { |
| | | } |
| | | |
| | | std::string resetFdfs(std::string ip = "", unsigned int port = 0, std::string content = "") { |
| | | |
| | | std::thread reset([&]() { |
| | | fdfsClient.rwLock.rdlock(); |
| | | if (fdfsClient.fastFds != nullptr) { |
| | | delete fdfsClient.fastFds; |
| | | } |
| | | fdfsClient.fastFds = new FastFds("fastDfsClient.conf"); |
| | | fdfsClient.rwLock.unlock(); |
| | | }); |
| | | reset.detach(); |
| | | |
| | | return ""; |
| | | } |
| | | // std::string resetFdfs(std::string ip = "", unsigned int port = 0, std::string content = "") { |
| | | // |
| | | // std::thread reset([&]() { |
| | | // fdfsClient.rwLock.rdlock(); |
| | | // if (fdfsClient.fastFds != nullptr) { |
| | | // delete fdfsClient.fastFds; |
| | | // } |
| | | // fdfsClient.fastFds = new FastFds("fastDfsClient.conf"); |
| | | // fdfsClient.rwLock.unlock(); |
| | | // }); |
| | | // reset.detach(); |
| | | // |
| | | // return ""; |
| | | // } |
| | | |
| | | private: |
| | | virtual void doFunc(std::shared_ptr<getsdkHdlManage> spPacket) { |
| | |
| | | set(CMAKE_BUILD_TYPE debug) |
| | | add_compile_options(-fPIC) |
| | | add_definitions(-DGLOG) |
| | | add_definitions(-DGB28181) |
| | | add_definitions(-DDEBUG_ERR -DDEBUG_INFO -fpermissive) |
| | | SET(SOURCES |
| | | |
| | |
| | | # cudart |
| | | # cublas |
| | | opencv_world |
| | | jsoncpp |
| | | # jsoncpp |
| | | curl |
| | | uuid |
| | | pthread |
| | |
| | | |
| | | //RtspAnalysElement::RtspAnalysElement() {} |
| | | |
| | | std::string RtspAnalysElement::resetFdfs(std::string ip, unsigned int port, std::string content) { |
| | | |
| | | std::thread reset([&]() { |
| | | fdfsClient.rwLock.rdlock(); |
| | | if (fdfsClient.fastFds != nullptr) { |
| | | delete fdfsClient.fastFds; |
| | | } |
| | | fdfsClient.fastFds = new FastFds("fastDfsClient.conf"); |
| | | fdfsClient.rwLock.unlock(); |
| | | }); |
| | | reset.detach(); |
| | | |
| | | return ""; |
| | | } |
| | | //std::string RtspAnalysElement::resetFdfs(std::string ip, unsigned int port, std::string content) { |
| | | // |
| | | // std::thread reset([&]() { |
| | | // fdfsClient.rwLock.rdlock(); |
| | | // if (fdfsClient.fastFds != nullptr) { |
| | | // delete fdfsClient.fastFds; |
| | | // } |
| | | // fdfsClient.fastFds = new FastFds("fastDfsClient.conf"); |
| | | // fdfsClient.rwLock.unlock(); |
| | | // }); |
| | | // reset.detach(); |
| | | // |
| | | // return ""; |
| | | //} |
| | | |
| | | RtspAnalysElement::RtspAnalysElement(LDBTool *_dbTool) : m_lDBTool(_dbTool), maxCount(50), currentCount(0) { |
| | | init(); |
| | | resetFdfs(); |
| | | // resetFdfs(); |
| | | { |
| | | // std::thread httpServer([&]() { |
| | | // //#todo port |
| | |
| | | } |
| | | |
| | | void RtspAnalysElement::init() { |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | #ifndef GB28181 |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | |
| | | appPref.setIntData("n_cut_max_duration", lst_dev.n_cut_max_duration); |
| | | appPref.setIntData("n_cut_min_duration", lst_dev.n_cut_min_duration); |
| | |
| | | int CamCount = appPref.getIntData("CamStep"); |
| | | auto itor = lst.begin(); |
| | | |
| | | if(startCamNO >= lst.size()) |
| | | { |
| | | if (startCamNO >= lst.size()) { |
| | | ERR("startCamNO > lst.size()"); |
| | | return; |
| | | } |
| | |
| | | } |
| | | |
| | | for (int i = 0; i < CamCount; i++) { |
| | | if (itor == lst.end()) |
| | | { |
| | | if (itor == lst.end()) { |
| | | ERR("itor == lst.end()"); |
| | | return; |
| | | } |
| | |
| | | rule.second.strAddr = itor->str_addr; |
| | | rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(itor->str_cam_dev_id, rule.first); |
| | | |
| | | if(rule.second.nSdkType == PerStaticSdk) |
| | | { |
| | | if (rule.second.nSdkType == PerStaticSdk) { |
| | | float temp=1-(float)(rule.second.nThreshold)/100; |
| | | rule.second.fSensitivity=(75+25*temp)/100; |
| | | |
| | | } |
| | | else if(rule.second.nSdkType != FaceSdk) |
| | | { |
| | | } else if (rule.second.nSdkType != FaceSdk) { |
| | | float temp=1-(float)(rule.second.nThreshold)/100; |
| | | rule.second.fSensitivity=(5+90*temp)/100; |
| | | } |
| | |
| | | addCamera(t_camIdex, ruleMap); |
| | | itor++; |
| | | } |
| | | |
| | | // for (auto item : lst) { |
| | | // std::string t_camIdex = item.str_cam_dev_id.toStdString(); |
| | | // std::string rtsp_url = rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(), |
| | |
| | | ERR("searchCamDevTableAll size is 0"); |
| | | } |
| | | |
| | | #else |
| | | auto lst = m_lDBTool->searchCamDevTableByType(1); |
| | | |
| | | 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) { |
| | | // Json::Value json; |
| | | |
| | | for (auto &item : lst) { |
| | | std::string t_camIdex = item.str_cam_dev_id.toStdString(); |
| | | std::string rtsp_url = "GB28181"; |
| | | // rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(), |
| | | // item.str_password.toStdString(), item.str_brand.toStdString()); |
| | | SdkRuleMap ruleMap = m_lDBTool->searchSdkRuleByCamId(item.str_cam_dev_id); |
| | | for (auto &rule:ruleMap) { |
| | | |
| | | rule.second.strAddr = item.str_addr; |
| | | rule.second.weekRuleVec = m_lDBTool->searchCameraWeekRuleByCamId(item.str_cam_dev_id, rule.first); |
| | | |
| | | if (rule.second.nSdkType == PerStaticSdk) { |
| | | float temp = 1 - (float) (rule.second.nThreshold) / 100; |
| | | rule.second.fSensitivity = (75 + 25 * temp) / 100; |
| | | |
| | | } else if (rule.second.nSdkType != FaceSdk) { |
| | | float temp = 1 - (float) (rule.second.nThreshold) / 100; |
| | | rule.second.fSensitivity = (5 + 90 * temp) / 100; |
| | | } |
| | | DBG("fSensitivity" << rule.second.fSensitivity); |
| | | } |
| | | appPref.setStringData(t_camIdex + "rtsp", rtsp_url); |
| | | // appPref.setStringData(t_camIdex+"addr", item.str_addr.toStdString()); |
| | | // json["rtsp"] = rtsp_url; |
| | | // json["addr"] = item.str_addr.toStdString(); |
| | | |
| | | INFO("cam add is " << item.str_addr.toStdString()); |
| | | |
| | | addCamera(t_camIdex, ruleMap); |
| | | } |
| | | } else { |
| | | ERR("searchCamDevTableAll size is 0"); |
| | | } |
| | | |
| | | #endif |
| | | } |
| | | |
| | | RtspAnalysElement::~RtspAnalysElement() { |
| | |
| | | private: |
| | | void init(); |
| | | |
| | | std::string resetFdfs(std::string ip = "", unsigned int port = 0, std::string content = ""); |
| | | // std::string resetFdfs(std::string ip = "", unsigned int port = 0, std::string content = ""); |
| | | |
| | | static std::vector<int> chnString2Vec(std::string str_list); |
| | | |
| | | void setDataByType(Json::Value& json,const SdkRule& rule); |
| | | // void setDataByType(Json::Value& json,const SdkRule& rule); |
| | | |
| | | private: |
| | | LDBTool *m_lDBTool; |
| | |
| | | ENABLEGLOG(GET_STR_CONFIG("logPath").c_str()); |
| | | #endif |
| | | |
| | | #ifndef GB28181 |
| | | DBG("no GB28181"); |
| | | #else |
| | | DBG("hava GB28181"); |
| | | #endif |
| | | |
| | | appPref.setLongData("gpu.index", 0); |
| | | appPref.setIntData("show.image", 0); |
| | | |
| | |
| | | #include <QDateTime> |
| | | #include <QVector> |
| | | #include <map> |
| | | struct Record_Storage_Dev |
| | | { |
| | | Record_Storage_Dev() |
| | | { |
| | | |
| | | struct Record_Storage_Dev { |
| | | Record_Storage_Dev() { |
| | | n_id = 0; |
| | | str_storage_dev_id = ""; |
| | | str_dev_name = ""; |
| | |
| | | QString str_reserved;//截图地址 |
| | | }; |
| | | |
| | | struct Record_Cam_Dev |
| | | { |
| | | Record_Cam_Dev() |
| | | { |
| | | struct Record_Cam_Dev { |
| | | Record_Cam_Dev() { |
| | | n_id = 0; |
| | | str_name = ""; |
| | | str_addr = ""; |
| | |
| | | str_password = ""; |
| | | str_brand = ""; |
| | | str_reserved = ""; |
| | | n_type = -1; |
| | | } |
| | | |
| | | int n_id;//自增id |
| | |
| | | QString str_password;//摄像机密码 |
| | | QString str_brand;//摄像机品牌 |
| | | QString str_reserved;//预留 |
| | | int n_type;//预留 |
| | | }; |
| | | |
| | | struct Record_Cam_Chn |
| | | { |
| | | struct Record_Cam_Chn { |
| | | |
| | | Record_Cam_Chn() |
| | | { |
| | | Record_Cam_Chn() { |
| | | n_id = 0; |
| | | str_storage_dev_id = ""; |
| | | n_chn = 0; |
| | |
| | | QString str_reserved;//预留 |
| | | }; |
| | | |
| | | struct Record_Load_File_info |
| | | { |
| | | struct Record_Load_File_info { |
| | | |
| | | // Record_Load_File_info() |
| | | // { |
| | |
| | | QString str_reserved;//预留 |
| | | }; |
| | | |
| | | struct Record_Cut_Video_info |
| | | { |
| | | struct Record_Cut_Video_info { |
| | | |
| | | // Record_Cut_Video_info() |
| | | // { |
| | |
| | | QString str_reserved;//预留 |
| | | }; |
| | | |
| | | struct Record_Sdk_Hdl_info |
| | | { |
| | | struct Record_Sdk_Hdl_info { |
| | | |
| | | // Record_Sdk_Hdl_info() |
| | | // { |
| | |
| | | QString str_reserved;//预留 |
| | | }; |
| | | |
| | | struct Record_Chn_Sdk |
| | | { |
| | | struct Record_Chn_Sdk { |
| | | |
| | | Record_Chn_Sdk() |
| | | { |
| | | Record_Chn_Sdk() { |
| | | n_id = 0; |
| | | str_storage_dev_id = ""; |
| | | n_chn = 0; |
| | |
| | | QString str_reserved;//预留 |
| | | }; |
| | | |
| | | struct Record_Cam_Sdk |
| | | { |
| | | struct Record_Cam_Sdk { |
| | | |
| | | Record_Cam_Sdk() |
| | | { |
| | | Record_Cam_Sdk() { |
| | | n_id = 0; |
| | | str_cam_dev_id = ""; |
| | | str_sdks = ""; |
| | |
| | | QString str_reserved;//预留 |
| | | }; |
| | | |
| | | struct Record_Config |
| | | { |
| | | Record_Config() |
| | | { |
| | | struct Record_Config { |
| | | Record_Config() { |
| | | str_alarm_ip = ""; |
| | | n_alarm_port = 0; |
| | | str_web_pic_ip = ""; |
| | |
| | | QString dev_name; |
| | | }; |
| | | |
| | | struct LActRuleWeekRecord |
| | | { |
| | | LActRuleWeekRecord() |
| | | { |
| | | struct LActRuleWeekRecord { |
| | | LActRuleWeekRecord() { |
| | | m_strCamId=""; |
| | | m_nSdkType=0; |
| | | m_nType = 0; |
| | | m_strBegin = ""; |
| | | m_strEnd = ""; |
| | | } |
| | | |
| | | QString m_strCamId; |
| | | int m_nSdkType; |
| | | int m_nType; //周几 |
| | |
| | | }; |
| | | |
| | | |
| | | struct SdkRule |
| | | { |
| | | SdkRule() |
| | | { |
| | | struct SdkRule { |
| | | SdkRule() { |
| | | nIsRun=0; |
| | | nSdkType = 0 ; |
| | | strCamId = ""; |
| | |
| | | strLine=""; |
| | | strAddr=""; |
| | | } |
| | | |
| | | int nSdkType; |
| | | QString strCamId; |
| | | QString strAreas; //监测区域 |
| | |
| | | |
| | | std::vector<LActRuleWeekRecord> weekRuleVec; |
| | | }; |
| | | |
| | | typedef std::map<int,SdkRule> SdkRuleMap; |
| | | enum SdkType |
| | | { |
| | | enum SdkType { |
| | | SdkTypeStart=0, |
| | | FaceSdk, |
| | | CarSdk, |
| | |
| | | return false; |
| | | } |
| | | } |
| | | bool LDBTool::updateCamDevSnapshot(const QString& strIp,const QString& imgUrl) |
| | | { |
| | | |
| | | bool LDBTool::updateCamDevSnapshot(const QString &strIp, const QString &imgUrl) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("cam_dev"); |
| | |
| | | rec.setValue("reserved", imgUrl); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount > 0) |
| | | { |
| | | if (rowCount > 0) { |
| | | pModel.setRecord(0, rec);//TODO |
| | | } |
| | | |
| | | m_db.transaction();//开始事务操作 |
| | | |
| | | if (pModel.submitAll()) |
| | | { |
| | | if (pModel.submitAll()) { |
| | | m_db.commit();//提交 |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | } 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"); |
| | |
| | | |
| | | return lst; |
| | | } |
| | | bool LDBTool::searchCamDevByCamId(QString strCamId) |
| | | { |
| | | |
| | | bool LDBTool::searchCamDevByCamId(QString strCamId) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | std::list<Record_Cam_Dev> lst; |
| | | QSqlTableModel pModel(NULL, m_db); |
| | |
| | | lRec.dev_name = rec.value("dev_name").toString(); |
| | | } |
| | | lRec.dev_id = QString::fromStdString(appConfig.getStringProperty("DEV_ID")); |
| | | if(lRec.n_cut_max_duration == 0) |
| | | { |
| | | if (lRec.n_cut_max_duration == 0) { |
| | | lRec.n_cut_max_duration = 20; |
| | | } |
| | | if(lRec.n_cut_min_duration == 0) |
| | | { |
| | | if (lRec.n_cut_min_duration == 0) { |
| | | lRec.n_cut_min_duration = 4; |
| | | } |
| | | return lRec; |
| | | } |
| | | |
| | | |
| | | |
| | | bool LDBTool::insertRecordVedioPath(QString pathKey, QString filePath) { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | bool LDBTool::updateCameraWeekRule(const LActRuleWeekRecord& weekRule) |
| | | { |
| | | bool LDBTool::updateCameraWeekRule(const LActRuleWeekRecord &weekRule) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("rule_week"); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' and type='%2' and sdk_type='%3'").arg(weekRule.m_strCamId).arg(weekRule.m_nType).arg(weekRule.m_nSdkType)); |
| | | pModel.setFilter(QObject::tr("camera_id = '%1' and type='%2' and sdk_type='%3'").arg(weekRule.m_strCamId).arg( |
| | | weekRule.m_nType).arg(weekRule.m_nSdkType)); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | QSqlRecord rec = pModel.record(0); |
| | |
| | | rec.setValue("end_time",weekRule.m_strEnd); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount == 0) |
| | | { |
| | | if (rowCount == 0) { |
| | | pModel.insertRecord(-1, rec); |
| | | } |
| | | else if (rowCount > 0) |
| | | { |
| | | } else if (rowCount > 0) { |
| | | pModel.setRecord(0, rec);//TODO |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | } |
| | | std::vector<LActRuleWeekRecord> LDBTool::searchCameraWeekRuleByCamId(const QString& camId,const int& sdkType) |
| | | { |
| | | |
| | | std::vector<LActRuleWeekRecord> LDBTool::searchCameraWeekRuleByCamId(const QString &camId, const int &sdkType) { |
| | | std::vector<LActRuleWeekRecord> vecWeek; |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | |
| | | pModel.select(); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | for(int i = 0;i < rowCount;++i) |
| | | { |
| | | for (int i = 0; i < rowCount; ++i) { |
| | | LActRuleWeekRecord lActRuleWeekRec; |
| | | QSqlRecord rec = pModel.record(i); |
| | | lActRuleWeekRec.m_nSdkType = rec.value("sdk_type").toInt(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | bool LDBTool::updateSdkRule(const SdkRule& sdkRule) |
| | | { |
| | | bool LDBTool::updateSdkRule(const SdkRule &sdkRule) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("sdk_rule"); |
| | |
| | | rec.setValue("img_quality",sdkRule.nQuality); |
| | | |
| | | int rowCount = pModel.rowCount(); |
| | | if (rowCount == 0) |
| | | { |
| | | if (rowCount == 0) { |
| | | pModel.insertRecord(-1, rec); |
| | | } |
| | | else if (rowCount > 0) |
| | | { |
| | | } else if (rowCount > 0) { |
| | | pModel.setRecord(0, rec);//TODO |
| | | } |
| | | |
| | | m_db.transaction();//开始事务操作 |
| | | |
| | | if (pModel.submitAll()) |
| | | { |
| | | if (pModel.submitAll()) { |
| | | m_db.commit();//提交 |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | m_db.rollback();//回滚 |
| | | ERR("updateSdkRule ,pModel_load Error: " << pModel.lastError().text().toStdString()); |
| | | return false; |
| | | } |
| | | } |
| | | SdkRuleMap LDBTool::searchSdkRuleByCamId(const QString& camId) |
| | | { |
| | | |
| | | SdkRuleMap LDBTool::searchSdkRuleByCamId(const QString &camId) { |
| | | QMutexLocker mutexLocker(&m_mutexVisit);//TODO |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("sdk_rule"); |
| | |
| | | |
| | | //std::vector<SdkRule> ruleVec; |
| | | int rowCount = pModel.rowCount(); |
| | | for(int i=0;i<rowCount;++i) |
| | | { |
| | | for (int i = 0; i < rowCount; ++i) { |
| | | SdkRule rule; |
| | | QSqlRecord rec = pModel.record(i); |
| | | rule.strCamId=rec.value("cam_id").toString(); |
| | |
| | | std::list<Record_Cam_Dev> lst; |
| | | QSqlTableModel pModel(NULL, m_db); |
| | | pModel.setTable("cam_dev"); |
| | | pModel.setFilter(QObject::tr((string("cam_dev_id != '' and cam_dev_id is not null and type='")+to_string(type)+"'").c_str())); |
| | | pModel.setFilter(QObject::tr( |
| | | (string("cam_dev_id != '' and cam_dev_id is not null and type='") + to_string(type) + "'").c_str())); |
| | | pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange |
| | | pModel.select(); |
| | | |
| | |
| | | lChannelRec.str_password = rec.value("password").toString(); |
| | | lChannelRec.str_brand = rec.value("brand").toString(); |
| | | lChannelRec.str_reserved = rec.value("reserved").toString(); |
| | | lChannelRec.n_type = rec.value("type").toInt(); |
| | | lst.push_back(lChannelRec); |
| | | } |
| | | } |
| | |
| | | Ice |
| | | |
| | | crypto |
| | | |
| | | mysqlpp |
| | | |
| | | #ffmpeg |
| | | avformat |
| | |
| | | ../../BasicPlatForm/libs/hiredis-master/include |
| | | ../../../BasicPlatForm/basic/timer_counter/ |
| | | ../../../BasicPlatForm/libs/GB28181/include |
| | | |
| | | ../../../BasicPlatForm/libs/mysqlpp/include |
| | | ../../../BasicPlatForm/libs/mysql/include/mysql/ |
| | | ) |
| | | |
| | | link_directories( |
| | |
| | | ../../../BasicPlatForm/libs/Ice-3.7.0/lib64 |
| | | |
| | | ../../../BasicPlatForm/libs/hiredis-master/lib |
| | | ../../../BasicPlatForm/libs/mysqlpp/lib |
| | | ) |
| | | |
| | | add_executable(${PROJECT_NAME} |
| | |
| | | //初始化函数 |
| | | void RtspAnalysManager::init() { |
| | | INFO("MYH DEBUG HERE") |
| | | //#todo GB28181 |
| | | #ifndef GB28181 |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | |
| | |
| | | } else { |
| | | ERR("searchCamDevTableAll size is 0"); |
| | | } |
| | | #else |
| | | auto lst = m_lDBTool->searchCamDevTableByType(1); |
| | | 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()) { |
| | | // ERR("startCamNO > lst.size()"); |
| | | // return; |
| | | // } |
| | | // 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++; |
| | | // } |
| | | // |
| | | // for (int i = 0; i < CamCount; i++) { |
| | | // if (itor == lst.end()) { |
| | | // ERR("itor == lst.end()"); |
| | | // return; |
| | | // } |
| | | // 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("cam add is " << itor->str_addr.toStdString()); |
| | | // |
| | | // addCamera(t_camIdex, rtsp_url); |
| | | // itor++; |
| | | // } |
| | | |
| | | for (auto item : lst) { |
| | | std::string t_camIdex = item.str_cam_dev_id.toStdString(); |
| | | std::string rtsp_url = "GB28181"; |
| | | // rtspAddrBuild(item.str_ip.toStdString(), 554, item.str_username.toStdString(), |
| | | // item.str_password.toStdString(), item.str_brand.toStdString()); |
| | | INFO("cam add is " << item.str_addr.toStdString()); |
| | | |
| | | addCamera(t_camIdex, rtsp_url); |
| | | |
| | | } |
| | | } else { |
| | | ERR("searchCamDevTableAll size is 0"); |
| | | } |
| | | |
| | | |
| | | #endif |
| | | } |
| | | |
| | | RtspAnalysManager::~RtspAnalysManager() { |
| | |
| | | */ |
| | | int RtspAnalysManager::addCamera(const std::string &index, const std::string &rtsp) { |
| | | #ifndef GB28181 |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | // why search lst ? |
| | | // auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | if (m_controllers.find(index) == m_controllers.end()) { |
| | | INFO("MYH DEBUG HERE"); |
| | |
| | | m_imgRedisControllers[index]->start(); |
| | | |
| | | m_controllers[index] = new RtspCaptureElement(rtsp, index, 25, 3000, 0, this); |
| | | m_controllers[index]->start(); |
| | | m_controllers[index]->SetVideoMinMaxSeconds(lst_dev.n_cut_min_duration, lst_dev.n_cut_max_duration); |
| | | m_controllers[index]->start(); |
| | | m_currentCount++; |
| | | return 0; |
| | | |
| | |
| | | } |
| | | #else |
| | | //#todo |
| | | auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | // why search lst ? |
| | | // auto lst = m_lDBTool->searchCamDevTableAll(); |
| | | Record_Config lst_dev = m_lDBTool->searchConfigTableWithinServerInfo(); |
| | | |
| | | //#todo end |
| | |
| | | //VideoCaptureElementWithRtp(std::string &chanPubID, int fps, int streamTransType, int gpuIdx = -1) |
| | | m_controllers_videoCapElem[index] = new BASICGB28181::VideoCaptureElementWithRtp(const_cast<string &>(index), |
| | | 25, 1, 0); |
| | | m_controllers_videoCapElem[index]->start(); |
| | | m_controllers_videoCapElem[index]->SetVideoMinMaxSeconds(lst_dev.n_cut_min_duration, |
| | | lst_dev.n_cut_max_duration); |
| | | m_controllers_videoCapElem[index]->start(); |
| | | m_currentCount++; |
| | | return 0; |
| | | |
| | |
| | | #include <map> |
| | | #include "RtspCaptureElement.h" |
| | | #include "RtspImageRedis.h" |
| | | #include <VideoCaptureElementWithRtp.h> |
| | | #include "../GB28181DecoderModel/VideoCaptureElementWithRtp.h" |
| | | //#include <VideoCaptureElementWithRtp.h> |
| | | #include <QiaoJia/DB/LDBTool.h> |
| | | #include <basic/util/app/AppPreference.hpp> |
| | | #include "RtspAnalysServer.h" |
| | |
| | | |
| | | #include <GB28181Server.h> |
| | | #include <basic/util/net_config/net_config.h> |
| | | #include <DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h> |
| | | |
| | | static void startManager(LDBTool *_dbTool) { |
| | | RtspAnalysManager rtspAnalysManager(_dbTool); |
| | |
| | | mysqlDBServerCfg.DBName = "EGEyesForVSS"; |
| | | mysqlDBServerCfg.DBConnCount = 5; |
| | | |
| | | LDBTool ldbTool; |
| | | BaseSqliteDao::setLDBTool(&ldbTool); |
| | | |
| | | //#todo search from db |
| | | Json::Value t_value; |
| | | { |
| | | LDBTool ldbTool; |
| | | BaseSqliteDao::setLDBTool(&ldbTool); |
| | | t_value = VssLocalSettingTblSqliteDao::instance()->findAllVssLocalSettingTblList(); |
| | | } |
| | | if (t_value.size() == 1 && t_value["data"].size() > 1) { |
| | | assert("t_value.size()"); |
| | | } |
| | | DBG(t_value["data"].begin()->toStyledString()); |
| | | auto &t_cfg = *t_value["data"].begin(); |
| | | GBServerCfg gbServerCfg; |
| | | gbServerCfg.SvrIp = getLocalIp(); // 国标服务的ip地址 (本机的ip地址) |
| | | gbServerCfg.SvrPort = 7060; // 国标服务监听的端口 |
| | | gbServerCfg.SvrPubID = "44120000002000000001"; // 国标服务器的ID |
| | | gbServerCfg.SvrIp = t_cfg["ServerIp"].asString(); // 国标服务的ip地址 (本机的ip地址) |
| | | gbServerCfg.SvrPort = atoi(t_cfg["ServerPort"].asString().c_str());// 7060; // 国标服务监听的端口 |
| | | gbServerCfg.SvrPubID = t_cfg["ServerId"].asString();// "44120000002000000001"; // 国标服务器的ID |
| | | gbServerCfg.bMD5Auth = false; // 是否需要MD5加密 |
| | | gbServerCfg.UserName = "44120100002000000002"; // 国标服务的用户名 (下级设备注册的用户名) |
| | | gbServerCfg.Passwd = "123456"; // 国标服务的密码 (下级设备注册的密码) |
| | | gbServerCfg.UserName = t_cfg["UserAuthId"].asString();// "44120100002000000002"; // 国标服务的用户名 (下级设备注册的用户名) |
| | | gbServerCfg.Passwd = t_cfg["Password"].asString();// "123456"; // 国标服务的密码 (下级设备注册的密码) |
| | | gbServerCfg.SubScribeTime = 3600; // 订阅时间 如果为0 表示不订阅 |
| | | |
| | | SpinLock spinLock; |