Release DetectCardScreenshot RecognizePoiName.

This commit is contained in:
sdk-team
2020-11-13 06:21:27 +00:00
parent 67d6a5f9d4
commit 02122aa7ea
18 changed files with 591 additions and 36 deletions

View File

@@ -21,6 +21,8 @@ set(ocr_public_header
include/alibabacloud/ocr/OcrExport.h )
set(ocr_public_header_model
include/alibabacloud/ocr/model/DetectCardScreenshotRequest.h
include/alibabacloud/ocr/model/DetectCardScreenshotResult.h
include/alibabacloud/ocr/model/GetAsyncJobResultRequest.h
include/alibabacloud/ocr/model/GetAsyncJobResultResult.h
include/alibabacloud/ocr/model/RecognizeAccountPageRequest.h
@@ -45,6 +47,8 @@ set(ocr_public_header_model
include/alibabacloud/ocr/model/RecognizeLicensePlateResult.h
include/alibabacloud/ocr/model/RecognizePassportMRZRequest.h
include/alibabacloud/ocr/model/RecognizePassportMRZResult.h
include/alibabacloud/ocr/model/RecognizePoiNameRequest.h
include/alibabacloud/ocr/model/RecognizePoiNameResult.h
include/alibabacloud/ocr/model/RecognizeQrCodeRequest.h
include/alibabacloud/ocr/model/RecognizeQrCodeResult.h
include/alibabacloud/ocr/model/RecognizeStampRequest.h
@@ -68,6 +72,8 @@ set(ocr_public_header_model
set(ocr_src
src/OcrClient.cc
src/model/DetectCardScreenshotRequest.cc
src/model/DetectCardScreenshotResult.cc
src/model/GetAsyncJobResultRequest.cc
src/model/GetAsyncJobResultResult.cc
src/model/RecognizeAccountPageRequest.cc
@@ -92,6 +98,8 @@ set(ocr_src
src/model/RecognizeLicensePlateResult.cc
src/model/RecognizePassportMRZRequest.cc
src/model/RecognizePassportMRZResult.cc
src/model/RecognizePoiNameRequest.cc
src/model/RecognizePoiNameResult.cc
src/model/RecognizeQrCodeRequest.cc
src/model/RecognizeQrCodeResult.cc
src/model/RecognizeStampRequest.cc

View File

@@ -22,6 +22,8 @@
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RpcServiceClient.h>
#include "OcrExport.h"
#include "model/DetectCardScreenshotRequest.h"
#include "model/DetectCardScreenshotResult.h"
#include "model/GetAsyncJobResultRequest.h"
#include "model/GetAsyncJobResultResult.h"
#include "model/RecognizeAccountPageRequest.h"
@@ -46,6 +48,8 @@
#include "model/RecognizeLicensePlateResult.h"
#include "model/RecognizePassportMRZRequest.h"
#include "model/RecognizePassportMRZResult.h"
#include "model/RecognizePoiNameRequest.h"
#include "model/RecognizePoiNameResult.h"
#include "model/RecognizeQrCodeRequest.h"
#include "model/RecognizeQrCodeResult.h"
#include "model/RecognizeStampRequest.h"
@@ -75,6 +79,9 @@ namespace AlibabaCloud
class ALIBABACLOUD_OCR_EXPORT OcrClient : public RpcServiceClient
{
public:
typedef Outcome<Error, Model::DetectCardScreenshotResult> DetectCardScreenshotOutcome;
typedef std::future<DetectCardScreenshotOutcome> DetectCardScreenshotOutcomeCallable;
typedef std::function<void(const OcrClient*, const Model::DetectCardScreenshotRequest&, const DetectCardScreenshotOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> DetectCardScreenshotAsyncHandler;
typedef Outcome<Error, Model::GetAsyncJobResultResult> GetAsyncJobResultOutcome;
typedef std::future<GetAsyncJobResultOutcome> GetAsyncJobResultOutcomeCallable;
typedef std::function<void(const OcrClient*, const Model::GetAsyncJobResultRequest&, const GetAsyncJobResultOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetAsyncJobResultAsyncHandler;
@@ -111,6 +118,9 @@ namespace AlibabaCloud
typedef Outcome<Error, Model::RecognizePassportMRZResult> RecognizePassportMRZOutcome;
typedef std::future<RecognizePassportMRZOutcome> RecognizePassportMRZOutcomeCallable;
typedef std::function<void(const OcrClient*, const Model::RecognizePassportMRZRequest&, const RecognizePassportMRZOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RecognizePassportMRZAsyncHandler;
typedef Outcome<Error, Model::RecognizePoiNameResult> RecognizePoiNameOutcome;
typedef std::future<RecognizePoiNameOutcome> RecognizePoiNameOutcomeCallable;
typedef std::function<void(const OcrClient*, const Model::RecognizePoiNameRequest&, const RecognizePoiNameOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RecognizePoiNameAsyncHandler;
typedef Outcome<Error, Model::RecognizeQrCodeResult> RecognizeQrCodeOutcome;
typedef std::future<RecognizeQrCodeOutcome> RecognizeQrCodeOutcomeCallable;
typedef std::function<void(const OcrClient*, const Model::RecognizeQrCodeRequest&, const RecognizeQrCodeOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RecognizeQrCodeAsyncHandler;
@@ -146,6 +156,9 @@ namespace AlibabaCloud
OcrClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
OcrClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~OcrClient();
DetectCardScreenshotOutcome detectCardScreenshot(const Model::DetectCardScreenshotRequest &request)const;
void detectCardScreenshotAsync(const Model::DetectCardScreenshotRequest& request, const DetectCardScreenshotAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DetectCardScreenshotOutcomeCallable detectCardScreenshotCallable(const Model::DetectCardScreenshotRequest& request) const;
GetAsyncJobResultOutcome getAsyncJobResult(const Model::GetAsyncJobResultRequest &request)const;
void getAsyncJobResultAsync(const Model::GetAsyncJobResultRequest& request, const GetAsyncJobResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetAsyncJobResultOutcomeCallable getAsyncJobResultCallable(const Model::GetAsyncJobResultRequest& request) const;
@@ -182,6 +195,9 @@ namespace AlibabaCloud
RecognizePassportMRZOutcome recognizePassportMRZ(const Model::RecognizePassportMRZRequest &request)const;
void recognizePassportMRZAsync(const Model::RecognizePassportMRZRequest& request, const RecognizePassportMRZAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
RecognizePassportMRZOutcomeCallable recognizePassportMRZCallable(const Model::RecognizePassportMRZRequest& request) const;
RecognizePoiNameOutcome recognizePoiName(const Model::RecognizePoiNameRequest &request)const;
void recognizePoiNameAsync(const Model::RecognizePoiNameRequest& request, const RecognizePoiNameAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
RecognizePoiNameOutcomeCallable recognizePoiNameCallable(const Model::RecognizePoiNameRequest& request) const;
RecognizeQrCodeOutcome recognizeQrCode(const Model::RecognizeQrCodeRequest &request)const;
void recognizeQrCodeAsync(const Model::RecognizeQrCodeRequest& request, const RecognizeQrCodeAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
RecognizeQrCodeOutcomeCallable recognizeQrCodeCallable(const Model::RecognizeQrCodeRequest& request) const;

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_OCR_MODEL_DETECTCARDSCREENSHOTREQUEST_H_
#define ALIBABACLOUD_OCR_MODEL_DETECTCARDSCREENSHOTREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/ocr/OcrExport.h>
namespace AlibabaCloud
{
namespace Ocr
{
namespace Model
{
class ALIBABACLOUD_OCR_EXPORT DetectCardScreenshotRequest : public RpcServiceRequest
{
public:
DetectCardScreenshotRequest();
~DetectCardScreenshotRequest();
std::string getImageURL()const;
void setImageURL(const std::string& imageURL);
private:
std::string imageURL_;
};
}
}
}
#endif // !ALIBABACLOUD_OCR_MODEL_DETECTCARDSCREENSHOTREQUEST_H_

View File

@@ -0,0 +1,67 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_OCR_MODEL_DETECTCARDSCREENSHOTRESULT_H_
#define ALIBABACLOUD_OCR_MODEL_DETECTCARDSCREENSHOTRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/ocr/OcrExport.h>
namespace AlibabaCloud
{
namespace Ocr
{
namespace Model
{
class ALIBABACLOUD_OCR_EXPORT DetectCardScreenshotResult : public ServiceResult
{
public:
struct Data
{
struct SpoofResult
{
struct ResultMap
{
float screenScore;
float screenThreshold;
};
ResultMap resultMap;
bool isSpoof;
};
SpoofResult spoofResult;
bool isBlur;
bool isCard;
};
DetectCardScreenshotResult();
explicit DetectCardScreenshotResult(const std::string &payload);
~DetectCardScreenshotResult();
Data getData()const;
protected:
void parse(const std::string &payload);
private:
Data data_;
};
}
}
}
#endif // !ALIBABACLOUD_OCR_MODEL_DETECTCARDSCREENSHOTRESULT_H_

View File

@@ -73,7 +73,7 @@ namespace AlibabaCloud
std::string registerNumber;
QRCode qRCode;
std::string type;
std::string angle;
float angle;
Emblem emblem;
std::string business;
};

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_OCR_MODEL_RECOGNIZEPOINAMEREQUEST_H_
#define ALIBABACLOUD_OCR_MODEL_RECOGNIZEPOINAMEREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/ocr/OcrExport.h>
namespace AlibabaCloud
{
namespace Ocr
{
namespace Model
{
class ALIBABACLOUD_OCR_EXPORT RecognizePoiNameRequest : public RpcServiceRequest
{
public:
RecognizePoiNameRequest();
~RecognizePoiNameRequest();
std::string getImageURL()const;
void setImageURL(const std::string& imageURL);
private:
std::string imageURL_;
};
}
}
}
#endif // !ALIBABACLOUD_OCR_MODEL_RECOGNIZEPOINAMEREQUEST_H_

View File

@@ -0,0 +1,73 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ALIBABACLOUD_OCR_MODEL_RECOGNIZEPOINAMERESULT_H_
#define ALIBABACLOUD_OCR_MODEL_RECOGNIZEPOINAMERESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/ocr/OcrExport.h>
namespace AlibabaCloud
{
namespace Ocr
{
namespace Model
{
class ALIBABACLOUD_OCR_EXPORT RecognizePoiNameResult : public ServiceResult
{
public:
struct Data
{
struct Summary
{
std::string brand;
float score;
};
struct SignboardsItem
{
struct TextsItem
{
float score;
std::string type;
std::vector<std::string> points;
std::string label;
std::string tag;
};
std::vector<SignboardsItem::TextsItem> texts;
};
std::vector<SignboardsItem> signboards;
Summary summary;
};
RecognizePoiNameResult();
explicit RecognizePoiNameResult(const std::string &payload);
~RecognizePoiNameResult();
Data getData()const;
protected:
void parse(const std::string &payload);
private:
Data data_;
};
}
}
}
#endif // !ALIBABACLOUD_OCR_MODEL_RECOGNIZEPOINAMERESULT_H_

View File

@@ -51,6 +51,42 @@ OcrClient::OcrClient(const std::string & accessKeyId, const std::string & access
OcrClient::~OcrClient()
{}
OcrClient::DetectCardScreenshotOutcome OcrClient::detectCardScreenshot(const DetectCardScreenshotRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return DetectCardScreenshotOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DetectCardScreenshotOutcome(DetectCardScreenshotResult(outcome.result()));
else
return DetectCardScreenshotOutcome(outcome.error());
}
void OcrClient::detectCardScreenshotAsync(const DetectCardScreenshotRequest& request, const DetectCardScreenshotAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, detectCardScreenshot(request), context);
};
asyncExecute(new Runnable(fn));
}
OcrClient::DetectCardScreenshotOutcomeCallable OcrClient::detectCardScreenshotCallable(const DetectCardScreenshotRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DetectCardScreenshotOutcome()>>(
[this, request]()
{
return this->detectCardScreenshot(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
OcrClient::GetAsyncJobResultOutcome OcrClient::getAsyncJobResult(const GetAsyncJobResultRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
@@ -483,6 +519,42 @@ OcrClient::RecognizePassportMRZOutcomeCallable OcrClient::recognizePassportMRZCa
return task->get_future();
}
OcrClient::RecognizePoiNameOutcome OcrClient::recognizePoiName(const RecognizePoiNameRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return RecognizePoiNameOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return RecognizePoiNameOutcome(RecognizePoiNameResult(outcome.result()));
else
return RecognizePoiNameOutcome(outcome.error());
}
void OcrClient::recognizePoiNameAsync(const RecognizePoiNameRequest& request, const RecognizePoiNameAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, recognizePoiName(request), context);
};
asyncExecute(new Runnable(fn));
}
OcrClient::RecognizePoiNameOutcomeCallable OcrClient::recognizePoiNameCallable(const RecognizePoiNameRequest &request) const
{
auto task = std::make_shared<std::packaged_task<RecognizePoiNameOutcome()>>(
[this, request]()
{
return this->recognizePoiName(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
OcrClient::RecognizeQrCodeOutcome OcrClient::recognizeQrCode(const RecognizeQrCodeRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/ocr/model/DetectCardScreenshotRequest.h>
using AlibabaCloud::Ocr::Model::DetectCardScreenshotRequest;
DetectCardScreenshotRequest::DetectCardScreenshotRequest() :
RpcServiceRequest("ocr", "2019-12-30", "DetectCardScreenshot")
{
setMethod(HttpRequest::Method::Post);
}
DetectCardScreenshotRequest::~DetectCardScreenshotRequest()
{}
std::string DetectCardScreenshotRequest::getImageURL()const
{
return imageURL_;
}
void DetectCardScreenshotRequest::setImageURL(const std::string& imageURL)
{
imageURL_ = imageURL;
setBodyParameter("ImageURL", imageURL);
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/ocr/model/DetectCardScreenshotResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Ocr;
using namespace AlibabaCloud::Ocr::Model;
DetectCardScreenshotResult::DetectCardScreenshotResult() :
ServiceResult()
{}
DetectCardScreenshotResult::DetectCardScreenshotResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DetectCardScreenshotResult::~DetectCardScreenshotResult()
{}
void DetectCardScreenshotResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto dataNode = value["Data"];
if(!dataNode["IsCard"].isNull())
data_.isCard = dataNode["IsCard"].asString() == "true";
if(!dataNode["IsBlur"].isNull())
data_.isBlur = dataNode["IsBlur"].asString() == "true";
auto spoofResultNode = dataNode["SpoofResult"];
if(!spoofResultNode["IsSpoof"].isNull())
data_.spoofResult.isSpoof = spoofResultNode["IsSpoof"].asString() == "true";
auto resultMapNode = spoofResultNode["ResultMap"];
if(!resultMapNode["ScreenScore"].isNull())
data_.spoofResult.resultMap.screenScore = std::stof(resultMapNode["ScreenScore"].asString());
if(!resultMapNode["ScreenThreshold"].isNull())
data_.spoofResult.resultMap.screenThreshold = std::stof(resultMapNode["ScreenThreshold"].asString());
}
DetectCardScreenshotResult::Data DetectCardScreenshotResult::getData()const
{
return data_;
}

View File

@@ -41,7 +41,7 @@ void RecognizeBusinessLicenseResult::parse(const std::string &payload)
setRequestId(value["RequestId"].asString());
auto dataNode = value["Data"];
if(!dataNode["Angle"].isNull())
data_.angle = dataNode["Angle"].asString();
data_.angle = std::stof(dataNode["Angle"].asString());
if(!dataNode["RegisterNumber"].isNull())
data_.registerNumber = dataNode["RegisterNumber"].asString();
if(!dataNode["Name"].isNull())

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/ocr/model/RecognizePoiNameRequest.h>
using AlibabaCloud::Ocr::Model::RecognizePoiNameRequest;
RecognizePoiNameRequest::RecognizePoiNameRequest() :
RpcServiceRequest("ocr", "2019-12-30", "RecognizePoiName")
{
setMethod(HttpRequest::Method::Post);
}
RecognizePoiNameRequest::~RecognizePoiNameRequest()
{}
std::string RecognizePoiNameRequest::getImageURL()const
{
return imageURL_;
}
void RecognizePoiNameRequest::setImageURL(const std::string& imageURL)
{
imageURL_ = imageURL;
setBodyParameter("ImageURL", imageURL);
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/ocr/model/RecognizePoiNameResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Ocr;
using namespace AlibabaCloud::Ocr::Model;
RecognizePoiNameResult::RecognizePoiNameResult() :
ServiceResult()
{}
RecognizePoiNameResult::RecognizePoiNameResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
RecognizePoiNameResult::~RecognizePoiNameResult()
{}
void RecognizePoiNameResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto dataNode = value["Data"];
auto allSignboardsNode = dataNode["Signboards"]["SignboardsItem"];
for (auto dataNodeSignboardsSignboardsItem : allSignboardsNode)
{
Data::SignboardsItem signboardsItemObject;
auto allTextsNode = dataNodeSignboardsSignboardsItem["Texts"]["TextsItem"];
for (auto dataNodeSignboardsSignboardsItemTextsTextsItem : allTextsNode)
{
Data::SignboardsItem::TextsItem textsObject;
if(!dataNodeSignboardsSignboardsItemTextsTextsItem["Label"].isNull())
textsObject.label = dataNodeSignboardsSignboardsItemTextsTextsItem["Label"].asString();
if(!dataNodeSignboardsSignboardsItemTextsTextsItem["Score"].isNull())
textsObject.score = std::stof(dataNodeSignboardsSignboardsItemTextsTextsItem["Score"].asString());
if(!dataNodeSignboardsSignboardsItemTextsTextsItem["Tag"].isNull())
textsObject.tag = dataNodeSignboardsSignboardsItemTextsTextsItem["Tag"].asString();
if(!dataNodeSignboardsSignboardsItemTextsTextsItem["Type"].isNull())
textsObject.type = dataNodeSignboardsSignboardsItemTextsTextsItem["Type"].asString();
auto allPoints = value["Points"]["Points"];
for (auto value : allPoints)
textsObject.points.push_back(value.asString());
signboardsItemObject.texts.push_back(textsObject);
}
data_.signboards.push_back(signboardsItemObject);
}
auto summaryNode = dataNode["Summary"];
if(!summaryNode["Brand"].isNull())
data_.summary.brand = summaryNode["Brand"].asString();
if(!summaryNode["Score"].isNull())
data_.summary.score = std::stof(summaryNode["Score"].asString());
}
RecognizePoiNameResult::Data RecognizePoiNameResult::getData()const
{
return data_;
}

View File

@@ -48,16 +48,16 @@ void RecognizeQrCodeResult::parse(const std::string &payload)
elementObject.taskId = dataNodeElementsElement["TaskId"].asString();
if(!dataNodeElementsElement["ImageURL"].isNull())
elementObject.imageURL = dataNodeElementsElement["ImageURL"].asString();
auto allResultsNode = allElementsNode["Results"]["Result"];
for (auto allElementsNodeResultsResult : allResultsNode)
auto allResultsNode = dataNodeElementsElement["Results"]["Result"];
for (auto dataNodeElementsElementResultsResult : allResultsNode)
{
Data::Element::Result resultsObject;
if(!allElementsNodeResultsResult["Label"].isNull())
resultsObject.label = allElementsNodeResultsResult["Label"].asString();
if(!allElementsNodeResultsResult["Suggestion"].isNull())
resultsObject.suggestion = allElementsNodeResultsResult["Suggestion"].asString();
if(!allElementsNodeResultsResult["Rate"].isNull())
resultsObject.rate = std::stof(allElementsNodeResultsResult["Rate"].asString());
if(!dataNodeElementsElementResultsResult["Label"].isNull())
resultsObject.label = dataNodeElementsElementResultsResult["Label"].asString();
if(!dataNodeElementsElementResultsResult["Suggestion"].isNull())
resultsObject.suggestion = dataNodeElementsElementResultsResult["Suggestion"].asString();
if(!dataNodeElementsElementResultsResult["Rate"].isNull())
resultsObject.rate = std::stof(dataNodeElementsElementResultsResult["Rate"].asString());
auto allQrCodesData = value["QrCodesData"]["QrCodeData"];
for (auto value : allQrCodesData)
resultsObject.qrCodesData.push_back(value.asString());

View File

@@ -44,14 +44,14 @@ void RecognizeStampResult::parse(const std::string &payload)
for (auto dataNodeResultsResultsItem : allResultsNode)
{
Data::ResultsItem resultsItemObject;
auto allGeneralTextNode = allResultsNode["GeneralText"]["GeneralTextItem"];
for (auto allResultsNodeGeneralTextGeneralTextItem : allGeneralTextNode)
auto allGeneralTextNode = dataNodeResultsResultsItem["GeneralText"]["GeneralTextItem"];
for (auto dataNodeResultsResultsItemGeneralTextGeneralTextItem : allGeneralTextNode)
{
Data::ResultsItem::GeneralTextItem generalTextObject;
if(!allResultsNodeGeneralTextGeneralTextItem["Content"].isNull())
generalTextObject.content = allResultsNodeGeneralTextGeneralTextItem["Content"].asString();
if(!allResultsNodeGeneralTextGeneralTextItem["Confidence"].isNull())
generalTextObject.confidence = std::stof(allResultsNodeGeneralTextGeneralTextItem["Confidence"].asString());
if(!dataNodeResultsResultsItemGeneralTextGeneralTextItem["Content"].isNull())
generalTextObject.content = dataNodeResultsResultsItemGeneralTextGeneralTextItem["Content"].asString();
if(!dataNodeResultsResultsItemGeneralTextGeneralTextItem["Confidence"].isNull())
generalTextObject.confidence = std::stof(dataNodeResultsResultsItemGeneralTextGeneralTextItem["Confidence"].asString());
resultsItemObject.generalText.push_back(generalTextObject);
}
auto roiNode = value["Roi"];

View File

@@ -46,26 +46,26 @@ void RecognizeTableResult::parse(const std::string &payload)
for (auto dataNodeTablesTable : allTablesNode)
{
Data::Table tableObject;
auto allTableRowsNode = allTablesNode["TableRows"]["TableRow"];
for (auto allTablesNodeTableRowsTableRow : allTableRowsNode)
auto allTableRowsNode = dataNodeTablesTable["TableRows"]["TableRow"];
for (auto dataNodeTablesTableTableRowsTableRow : allTableRowsNode)
{
Data::Table::TableRow tableRowsObject;
auto allTableColumnsNode = allTableRowsNode["TableColumns"]["TableColumn"];
for (auto allTableRowsNodeTableColumnsTableColumn : allTableColumnsNode)
auto allTableColumnsNode = dataNodeTablesTableTableRowsTableRow["TableColumns"]["TableColumn"];
for (auto dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn : allTableColumnsNode)
{
Data::Table::TableRow::TableColumn tableColumnsObject;
if(!allTableRowsNodeTableColumnsTableColumn["StartColumn"].isNull())
tableColumnsObject.startColumn = std::stoi(allTableRowsNodeTableColumnsTableColumn["StartColumn"].asString());
if(!allTableRowsNodeTableColumnsTableColumn["StartRow"].isNull())
tableColumnsObject.startRow = std::stoi(allTableRowsNodeTableColumnsTableColumn["StartRow"].asString());
if(!allTableRowsNodeTableColumnsTableColumn["EndColumn"].isNull())
tableColumnsObject.endColumn = std::stoi(allTableRowsNodeTableColumnsTableColumn["EndColumn"].asString());
if(!allTableRowsNodeTableColumnsTableColumn["EndRow"].isNull())
tableColumnsObject.endRow = std::stoi(allTableRowsNodeTableColumnsTableColumn["EndRow"].asString());
if(!allTableRowsNodeTableColumnsTableColumn["Height"].isNull())
tableColumnsObject.height = std::stoi(allTableRowsNodeTableColumnsTableColumn["Height"].asString());
if(!allTableRowsNodeTableColumnsTableColumn["Width"].isNull())
tableColumnsObject.width = std::stoi(allTableRowsNodeTableColumnsTableColumn["Width"].asString());
if(!dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["StartColumn"].isNull())
tableColumnsObject.startColumn = std::stoi(dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["StartColumn"].asString());
if(!dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["StartRow"].isNull())
tableColumnsObject.startRow = std::stoi(dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["StartRow"].asString());
if(!dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["EndColumn"].isNull())
tableColumnsObject.endColumn = std::stoi(dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["EndColumn"].asString());
if(!dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["EndRow"].isNull())
tableColumnsObject.endRow = std::stoi(dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["EndRow"].asString());
if(!dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["Height"].isNull())
tableColumnsObject.height = std::stoi(dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["Height"].asString());
if(!dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["Width"].isNull())
tableColumnsObject.width = std::stoi(dataNodeTablesTableTableRowsTableRowTableColumnsTableColumn["Width"].asString());
auto allTexts = value["Texts"]["Text"];
for (auto value : allTexts)
tableColumnsObject.texts.push_back(value.asString());

View File

@@ -46,12 +46,12 @@ void RecognizeTaxiInvoiceResult::parse(const std::string &payload)
Data::Invoice invoiceObject;
if(!dataNodeInvoicesInvoice["RotateType"].isNull())
invoiceObject.rotateType = std::stoi(dataNodeInvoicesInvoice["RotateType"].asString());
auto allItemsNode = allInvoicesNode["Items"]["Item"];
for (auto allInvoicesNodeItemsItem : allItemsNode)
auto allItemsNode = dataNodeInvoicesInvoice["Items"]["Item"];
for (auto dataNodeInvoicesInvoiceItemsItem : allItemsNode)
{
Data::Invoice::Item itemsObject;
if(!allInvoicesNodeItemsItem["Text"].isNull())
itemsObject.text = allInvoicesNodeItemsItem["Text"].asString();
if(!dataNodeInvoicesInvoiceItemsItem["Text"].isNull())
itemsObject.text = dataNodeInvoicesInvoiceItemsItem["Text"].asString();
auto itemRoiNode = value["ItemRoi"];
if(!itemRoiNode["Angle"].isNull())
itemsObject.itemRoi.angle = std::stof(itemRoiNode["Angle"].asString());