コード例 #1
0
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;
}
コード例 #2
0
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;
}