1 /* 2 * Copyright 2009-2017 Alibaba Cloud All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <alibabacloud/ocr/model/RecognizeLicensePlateResult.h> 18 #include <json/json.h> 19 20 using namespace AlibabaCloud::Ocr; 21 using namespace AlibabaCloud::Ocr::Model; 22 RecognizeLicensePlateResult()23RecognizeLicensePlateResult::RecognizeLicensePlateResult() : 24 ServiceResult() 25 {} 26 RecognizeLicensePlateResult(const std::string & payload)27RecognizeLicensePlateResult::RecognizeLicensePlateResult(const std::string &payload) : 28 ServiceResult() 29 { 30 parse(payload); 31 } 32 ~RecognizeLicensePlateResult()33RecognizeLicensePlateResult::~RecognizeLicensePlateResult() 34 {} 35 parse(const std::string & payload)36void RecognizeLicensePlateResult::parse(const std::string &payload) 37 { 38 Json::Reader reader; 39 Json::Value value; 40 reader.parse(payload, value); 41 setRequestId(value["RequestId"].asString()); 42 auto dataNode = value["Data"]; 43 auto allPlatesNode = dataNode["Plates"]["Plate"]; 44 for (auto dataNodePlatesPlate : allPlatesNode) 45 { 46 Data::Plate plateObject; 47 if(!dataNodePlatesPlate["Confidence"].isNull()) 48 plateObject.confidence = std::stof(dataNodePlatesPlate["Confidence"].asString()); 49 if(!dataNodePlatesPlate["PlateNumber"].isNull()) 50 plateObject.plateNumber = dataNodePlatesPlate["PlateNumber"].asString(); 51 if(!dataNodePlatesPlate["PlateType"].isNull()) 52 plateObject.plateType = dataNodePlatesPlate["PlateType"].asString(); 53 if(!dataNodePlatesPlate["PlateTypeConfidence"].isNull()) 54 plateObject.plateTypeConfidence = std::stof(dataNodePlatesPlate["PlateTypeConfidence"].asString()); 55 auto roiNode = value["Roi"]; 56 if(!roiNode["H"].isNull()) 57 plateObject.roi.h = std::stoi(roiNode["H"].asString()); 58 if(!roiNode["W"].isNull()) 59 plateObject.roi.w = std::stoi(roiNode["W"].asString()); 60 if(!roiNode["X"].isNull()) 61 plateObject.roi.x = std::stoi(roiNode["X"].asString()); 62 if(!roiNode["Y"].isNull()) 63 plateObject.roi.y = std::stoi(roiNode["Y"].asString()); 64 data_.plates.push_back(plateObject); 65 } 66 67 } 68 getData() const69RecognizeLicensePlateResult::Data RecognizeLicensePlateResult::getData()const 70 { 71 return data_; 72 } 73 74