| | |
| | | /*sdk login*/ |
| | | ulRet = IMOS_MW_Login(username, passwd, ip, 0, szUserID); |
| | | if (ERR_COMMON_SUCCEED != ulRet) { |
| | | (VOID) IMOS_MW_Cleanup(); |
| | | printf("Login error ulRet[%lu]", ulRet); |
| | | return false; |
| | | } |
| | |
| | | pstBasicInfo = (IMOS_MW_BASIC_DEVICE_INFO_S *) malloc(sizeof(IMOS_MW_BASIC_DEVICE_INFO_S)); |
| | | ulRet = IMOS_MW_GetDeviceStatus(szUserID, 0, IMOS_MW_STATUS_BASIC_INFO, (void *) pstBasicInfo); |
| | | if (ERR_COMMON_SUCCEED != ulRet) { |
| | | (VOID) IMOS_MW_Logout(szUserID); |
| | | (VOID) IMOS_MW_Cleanup(); |
| | | printf("GetDeviceStatus Error[%lu]\n", ulRet); |
| | | return false; |
| | | } |
| | |
| | | { |
| | | if(is_exist) |
| | | { |
| | | return "{\"ret_status\": \"内容有误,请检查!\"}"; |
| | | return "{\"ret_status\": \"请勿重复添加!\"}"; |
| | | } |
| | | else |
| | | { |
| | |
| | | std::string img_base64 = value["img_base64"].asString(); |
| | | std::string idcard = value["idcard"].asString(); |
| | | std::string strUUID = value["uuid"].asString(); |
| | | // if (strUUID.size() > 0) { |
| | | // bool ret_addPerson = false; |
| | | // if (TableName.find("lt_") == 0) { |
| | | // FieldValues fieldValues; |
| | | // AddFaceData addFaceData; |
| | | // //#todo update table |
| | | // addFaceData.uuid = strUUID; |
| | | // addFaceData.faceUrl = img_url; |
| | | // |
| | | // fieldValues.insert(std::make_pair("uuid", strUUID)); |
| | | // fieldValues.insert(std::make_pair("idCard", idcard)); |
| | | // m_SqliteFaceEncap.updateFace(TableName, addFaceData, fieldValues); |
| | | // } else { |
| | | // ret_addPerson = erlangDbTool->addPerson(strUUID, TableName, feature_base64, img_url, idcard); |
| | | // } |
| | | // } |
| | | |
| | | cv::Mat image; |
| | | if (img_url.size() > 0) { |
| | | |
| | | if (img_url.find("ManCarAnaly") != string::npos && img_url.find("group") != string::npos) { |
| | | auto pos = img_url.find("group"); |
| | | auto img_tmp = img_url.substr(pos); |
| | | std::string img_str = "http://"; |
| | | if (fdfsClient.fastFds != nullptr) { |
| | | img_str.append(fdfsClient.fastFds->getIp() + "/").append(img_tmp); |
| | | img_url.swap(img_str); |
| | | } |
| | | } |
| | | |
| | | auto t_results = m_curlDownloadImg.download_jpeg(const_cast<char *>(img_url.c_str())); |
| | | DBG(img_url << "t_results size is " << t_results.all << " : " << t_results.buffer.size()); |
| | | cvutil.buffer2CvMat(t_results.buffer, image); |
| | | } else if (img_base64.size() > 0) { |
| | | auto str_img = base64.Decode(img_base64.c_str(), img_base64.size()); |
| | |
| | | |
| | | if (faceResults.size() <= 0) { |
| | | response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\"not found face\"}"); |
| | | // string str_path = "./img/"; |
| | | // str_path.append(AppUtil::getTimeString() + ".jpg"); |
| | | // cv::imwrite(str_path, image); |
| | | system("mkdir -p img"); |
| | | string str_path = "./img/"; |
| | | str_path.append(AppUtil::getTimeString() + ".jpg"); |
| | | cv::imwrite(str_path, image); |
| | | return ""; |
| | | // return "{\"error\":\"not found face\"}"; |
| | | } else if (faceResults.size() > 1) { |
| | |
| | | } |
| | | } |
| | | fdfsClient.rwLock.unlock(); |
| | | |
| | | } |
| | | auto size = feature_base64.size(); |
| | | // std::string uuid = ""; |
| | |
| | | std::string str_tmpTime = AppUtil::getCmdResult(cmd_getVideoFileTime); |
| | | |
| | | |
| | | |
| | | if (str_time > str_tmpTime) { |
| | | |
| | | //str_time = str_tmpTime.size() > 0 ? str_tmpTime : str_time; |
| | | qint64 v_time=getVideoTime(str_tmpTime)-1000; |
| | | int haomiao = (v_time % 1000) > 50 ? ((v_time % 1000) - 50) : 0; |
| | | v_time /= 1000; |
| | | int m = v_time; |
| | | int shi, fen, miao; |
| | | char ch_time[128]; |
| | | if (m / 3600 < 24) { |
| | | shi = m / 3600; |
| | | fen = m / 60 % 60; |
| | | miao = m % 60; |
| | | sprintf(ch_time, "%02d:%02d:%02d.%02d", shi, fen, miao, haomiao / 10); |
| | | qint64 v_time = getVideoTime(str_tmpTime) - 1000; |
| | | int haomiao = (v_time % 1000) > 50 ? ((v_time % 1000) - 50) : 0; |
| | | v_time /= 1000; |
| | | int m = v_time; |
| | | int shi, fen, miao; |
| | | char ch_time[128]; |
| | | if (m / 3600 < 24) { |
| | | shi = m / 3600; |
| | | fen = m / 60 % 60; |
| | | miao = m % 60; |
| | | sprintf(ch_time, "%02d:%02d:%02d.%02d", shi, fen, miao, haomiao / 10); |
| | | |
| | | } else printf("输入数值太大"); |
| | | } else printf("输入数值太大"); |
| | | |
| | | str_time=ch_time; |
| | | ERR("{\"error\":\"Time error\"}" << str_time << " str_tmpTime " << str_tmpTime<<" ch_time="<<ch_time); |
| | | str_time = ch_time; |
| | | ERR("{\"error\":\"Time error\"}" << str_time << " str_tmpTime " << str_tmpTime << " ch_time=" |
| | | << ch_time); |
| | | // return "{\"error\":\"Time error\"}"; |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | qint64 devHttpServer_c::getVideoTime(/*const std::string &videoPath,*/std::string& str_tmpTime) { |
| | | qint64 devHttpServer_c::getVideoTime(/*const std::string &videoPath,*/std::string &str_tmpTime) { |
| | | // std::string cmd_getVideoFileTime( |
| | | // " ffmpeg -i '" + videoPath + "' 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//"); |
| | | |
| | |
| | | std::string pass = value["str_password"].asString(); |
| | | std::string brand = value["str_brand"].asString(); |
| | | std::string rtsp_url = rtspAddrBuild(ip, port, username, pass, brand); |
| | | if (rtsp_url.empty()) { |
| | | if (rtsp_url.empty() ) |
| | | { |
| | | return "{\"ret_status\":\"内容有误,请检查!\"}"; |
| | | } |
| | | // unsigned char serialnumber[SERIALNO_LEN] = {0}; |
| | | // int ret = getDevSerialNumber(ip.c_str(), port,username.c_str(),pass.c_str(),brand.c_str(),serialnumber); |
| | | |
| | | |
| | | // if ((!ret) || (serialnumber[0] == 0)) |
| | | // { |
| | | // return "{\"ret_status\": \"内容有误,请检查!\"}"; |
| | | // } |
| | | |
| | | // std::string str_cam_dev_id = std::string((char *) serialnumber);//摄像机id cam_mac |
| | | |
| | | std::string str_imgName = appConfig.getStringProperty("cutPath"); |
| | | if (str_imgName.back() != '/') { |
| | | str_imgName.push_back('/'); |
| | | } |
| | | str_imgName +=ip; |
| | | 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); |