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

@@ -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());