int vzsdk::VzRecognition::GetImage(int image_id, char* image_data, int& image_size) { Json::Value req_json; commandanalysis::GeneratGetImageByIdCmd(image_id, req_json); Message::Ptr _msg = SyncProcessReqTask(req_json); if (!_msg || _msg->phandler == NULL) { return REQ_FAILED; } //解析图片 ResponseData *response = static_cast<ResponseData *>(_msg->pdata.get()); Json::Value result = response->res_json(); RECORD_RESPONSE responese; commandanalysis::ParseRecordResponse(result, &responese); if (responese.id != image_id) return REQ_FAILED; int len = strlen(response->res_data().c_str()); const char* res_data = response->res_data().c_str(); const char* get_image_data = res_data + len + 1; image_size = responese.size; memcpy(image_data, get_image_data, responese.size); return REQ_SUCCEED; }
bool ReqTask::HandleResponse(Message *msg) { ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); const std::string res_cmd = response->res_json()[JSON_REQ_CMD].asString(); if(res_cmd == req_cmd_) { task_thread_->Post(this, task_id_, msg->pdata); return true; } return false; }
int vzsdk::VzRecognition::GetMaxRecordID(){ Json::Value req_json; commandanalysis::GeneraGetMaxRecordID(req_json); Message::Ptr _msg = SyncProcessReqTask(req_json); if (!_msg || _msg->phandler == NULL) { return REQ_FAILED; } ResponseData *response = static_cast<ResponseData *>(_msg->pdata.get()); Json::Value result = response->res_json(); MAX_REC_RESPONSE max_rec; commandanalysis::ParseMaxRecResponse(result, max_rec); return max_rec.max_id; }
bool PushManagerTask::HandleResponse(Message *msg) { if (task_thread_ == NULL) { return false; } CritScope cs(&crit_); ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); const std::string res_cmd = response->res_json()[JSON_REQ_CMD].asString(); PushHandleKeys::iterator iter = push_handle_keys_.find(res_cmd); if(iter != push_handle_keys_.end()) { task_thread_->Post(this, task_id_, msg->pdata); return true; } return false; }
bool ReqRecordTask::HandleResponse(Message *msg) { if (task_thread_ == NULL) { return false; } //»ñÈ¡¼Ç¼ ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); const std::string res_cmd = response->res_json()[JSON_REQ_CMD].asString(); if (res_cmd == "ivs_result" && req_cmd_ == "get_record") { task_thread_->Post(this, task_id_, msg->pdata); return true; } return false; }
int VzIODev::SetOfflineCheck() { Json::Value req_json; commandanalysis::GeneratOfflineCheckCmd(2, req_json); Message::Ptr msg = SyncProcessReqTask(req_json); if (!msg || msg->phandler == NULL) { return REQ_FAILED; } int ret = REQ_FAILED; ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); if (response != NULL) { Json::Value res_value = response->res_json(); OFFLINE_RESPONSE offline = { 0 }; commandanalysis::ParseOfflineResponse(res_value, &offline); if (strcmp(offline.response, "ok") == 0) { ret = REQ_SUCCEED; } } return ret; }
int VzIODev::GetGPIOValue(int gpioIn, int *value) { int ret = REQ_FAILED; Json::Value req_json; commandanalysis::GeneratGetGPIOValueCmd(gpioIn, req_json); Message::Ptr msg = SyncProcessReqTask(req_json); if (!msg || msg->phandler == NULL) { return REQ_FAILED; } ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); if (response != NULL) { Json::Value res_value = response->res_json(); GPIO_RESPONSE gpio = { 0 }; commandanalysis::ParseGPIOResponse(res_value, &gpio); *value = gpio.val; ret = REQ_SUCCEED; } return ret; }
int vzsdk::VzRecognition::GetRecord(int record_id, bool need_image , TH_PlateResult& plate_result , int& full_size, void* fullimage , int& clip_size, void* clipimage) { Json::Value req_json; int session_id = sdk_service_->GetSessionID(); commandanalysis::GeneratGetRecordByIdCmd(record_id, need_image, req_json); std::string result; if (session_id == 0) { LOG(LS_WARNING) << "The session is is zero, is not a right session"; return SESSION_ID_INVALUE; } Task::Ptr req_task(new ReqRecordTask(sdk_service_->GetQueueLayer().get(), DEFAULT_TIMEOUT, session_id, req_json)); Message::Ptr msg = req_task->SyncProcessTask(); if (!msg || msg->phandler == NULL) { return REQ_FAILED; } //解析车牌 ResponseData *response = static_cast<ResponseData *>(msg->pdata.get()); Json::Value value = response->res_json(); commandanalysis::ParsePlateResultResponse(value, plate_result, full_size, clip_size); int len = strlen(response->res_data().c_str()); if (fullimage != NULL) memcpy(fullimage, response->res_data().c_str() + len + 1, full_size); if (clipimage != NULL) memcpy(clipimage, response->res_data().c_str() + len + full_size + 1, clip_size); return REQ_SUCCEED; }