Update Imageaudit.
This commit is contained in:
125
imageaudit/src/ImageauditClient.cc
Normal file
125
imageaudit/src/ImageauditClient.cc
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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/imageaudit/ImageauditClient.h>
|
||||
#include <alibabacloud/core/SimpleCredentialsProvider.h>
|
||||
|
||||
using namespace AlibabaCloud;
|
||||
using namespace AlibabaCloud::Location;
|
||||
using namespace AlibabaCloud::Imageaudit;
|
||||
using namespace AlibabaCloud::Imageaudit::Model;
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string SERVICE_NAME = "imageaudit";
|
||||
}
|
||||
|
||||
ImageauditClient::ImageauditClient(const Credentials &credentials, const ClientConfiguration &configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(credentials), configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(credentials, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imageaudit");
|
||||
}
|
||||
|
||||
ImageauditClient::ImageauditClient(const std::shared_ptr<CredentialsProvider>& credentialsProvider, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(credentialsProvider, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imageaudit");
|
||||
}
|
||||
|
||||
ImageauditClient::ImageauditClient(const std::string & accessKeyId, const std::string & accessKeySecret, const ClientConfiguration & configuration) :
|
||||
RpcServiceClient(SERVICE_NAME, std::make_shared<SimpleCredentialsProvider>(accessKeyId, accessKeySecret), configuration)
|
||||
{
|
||||
auto locationClient = std::make_shared<LocationClient>(accessKeyId, accessKeySecret, configuration);
|
||||
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "imageaudit");
|
||||
}
|
||||
|
||||
ImageauditClient::~ImageauditClient()
|
||||
{}
|
||||
|
||||
ImageauditClient::ScanImageOutcome ImageauditClient::scanImage(const ScanImageRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return ScanImageOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return ScanImageOutcome(ScanImageResult(outcome.result()));
|
||||
else
|
||||
return ScanImageOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void ImageauditClient::scanImageAsync(const ScanImageRequest& request, const ScanImageAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, scanImage(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
ImageauditClient::ScanImageOutcomeCallable ImageauditClient::scanImageCallable(const ScanImageRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<ScanImageOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->scanImage(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
ImageauditClient::ScanTextOutcome ImageauditClient::scanText(const ScanTextRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return ScanTextOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return ScanTextOutcome(ScanTextResult(outcome.result()));
|
||||
else
|
||||
return ScanTextOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void ImageauditClient::scanTextAsync(const ScanTextRequest& request, const ScanTextAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, scanText(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
ImageauditClient::ScanTextOutcomeCallable ImageauditClient::scanTextCallable(const ScanTextRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<ScanTextOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->scanText(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
61
imageaudit/src/model/ScanImageRequest.cc
Normal file
61
imageaudit/src/model/ScanImageRequest.cc
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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/imageaudit/model/ScanImageRequest.h>
|
||||
|
||||
using AlibabaCloud::Imageaudit::Model::ScanImageRequest;
|
||||
|
||||
ScanImageRequest::ScanImageRequest() :
|
||||
RpcServiceRequest("imageaudit", "2019-12-30", "ScanImage")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
ScanImageRequest::~ScanImageRequest()
|
||||
{}
|
||||
|
||||
std::vector<std::string> ScanImageRequest::getScene()const
|
||||
{
|
||||
return scene_;
|
||||
}
|
||||
|
||||
void ScanImageRequest::setScene(const std::vector<std::string>& scene)
|
||||
{
|
||||
scene_ = scene;
|
||||
for(int dep1 = 0; dep1!= scene.size(); dep1++) {
|
||||
setBodyParameter("Scene."+ std::to_string(dep1), scene.at(dep1));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ScanImageRequest::Task> ScanImageRequest::getTask()const
|
||||
{
|
||||
return task_;
|
||||
}
|
||||
|
||||
void ScanImageRequest::setTask(const std::vector<Task>& task)
|
||||
{
|
||||
task_ = task;
|
||||
for(int dep1 = 0; dep1!= task.size(); dep1++) {
|
||||
auto taskObj = task.at(dep1);
|
||||
std::string taskObjStr = "Task." + std::to_string(dep1 + 1);
|
||||
setParameter(taskObjStr + ".DataId", taskObj.dataId);
|
||||
setParameter(taskObjStr + ".ImageURL", taskObj.imageURL);
|
||||
setParameter(taskObjStr + ".MaxFrames", std::to_string(taskObj.maxFrames));
|
||||
setParameter(taskObjStr + ".Interval", std::to_string(taskObj.interval));
|
||||
setParameter(taskObjStr + ".ImageTimeMillisecond", std::to_string(taskObj.imageTimeMillisecond));
|
||||
}
|
||||
}
|
||||
|
||||
155
imageaudit/src/model/ScanImageResult.cc
Normal file
155
imageaudit/src/model/ScanImageResult.cc
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 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/imageaudit/model/ScanImageResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Imageaudit;
|
||||
using namespace AlibabaCloud::Imageaudit::Model;
|
||||
|
||||
ScanImageResult::ScanImageResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ScanImageResult::ScanImageResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ScanImageResult::~ScanImageResult()
|
||||
{}
|
||||
|
||||
void ScanImageResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
auto allResultsNode = dataNode["Results"]["Result"];
|
||||
for (auto dataNodeResultsResult : allResultsNode)
|
||||
{
|
||||
Data::Result resultObject;
|
||||
if(!dataNodeResultsResult["DataId"].isNull())
|
||||
resultObject.dataId = dataNodeResultsResult["DataId"].asString();
|
||||
if(!dataNodeResultsResult["TaskId"].isNull())
|
||||
resultObject.taskId = dataNodeResultsResult["TaskId"].asString();
|
||||
if(!dataNodeResultsResult["ImageURL"].isNull())
|
||||
resultObject.imageURL = dataNodeResultsResult["ImageURL"].asString();
|
||||
auto allSubResultsNode = dataNodeResultsResult["SubResults"]["SubResult"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResult : allSubResultsNode)
|
||||
{
|
||||
Data::Result::SubResult subResultsObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResult["Label"].isNull())
|
||||
subResultsObject.label = dataNodeResultsResultSubResultsSubResult["Label"].asString();
|
||||
if(!dataNodeResultsResultSubResultsSubResult["Suggestion"].isNull())
|
||||
subResultsObject.suggestion = dataNodeResultsResultSubResultsSubResult["Suggestion"].asString();
|
||||
if(!dataNodeResultsResultSubResultsSubResult["Rate"].isNull())
|
||||
subResultsObject.rate = std::stof(dataNodeResultsResultSubResultsSubResult["Rate"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResult["Scene"].isNull())
|
||||
subResultsObject.scene = dataNodeResultsResultSubResultsSubResult["Scene"].asString();
|
||||
auto allFramesNode = dataNodeResultsResultSubResultsSubResult["Frames"]["Frame"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResultFramesFrame : allFramesNode)
|
||||
{
|
||||
Data::Result::SubResult::Frame framesObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResultFramesFrame["Rate"].isNull())
|
||||
framesObject.rate = std::stof(dataNodeResultsResultSubResultsSubResultFramesFrame["Rate"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultFramesFrame["URL"].isNull())
|
||||
framesObject.uRL = dataNodeResultsResultSubResultsSubResultFramesFrame["URL"].asString();
|
||||
subResultsObject.frames.push_back(framesObject);
|
||||
}
|
||||
auto allHintWordsInfoListNode = dataNodeResultsResultSubResultsSubResult["HintWordsInfoList"]["HintWordsInfo"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResultHintWordsInfoListHintWordsInfo : allHintWordsInfoListNode)
|
||||
{
|
||||
Data::Result::SubResult::HintWordsInfo hintWordsInfoListObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResultHintWordsInfoListHintWordsInfo["Context"].isNull())
|
||||
hintWordsInfoListObject.context = dataNodeResultsResultSubResultsSubResultHintWordsInfoListHintWordsInfo["Context"].asString();
|
||||
subResultsObject.hintWordsInfoList.push_back(hintWordsInfoListObject);
|
||||
}
|
||||
auto allProgramCodeDataListNode = dataNodeResultsResultSubResultsSubResult["ProgramCodeDataList"]["ProgramCodeData"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData : allProgramCodeDataListNode)
|
||||
{
|
||||
Data::Result::SubResult::ProgramCodeData programCodeDataListObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["X"].isNull())
|
||||
programCodeDataListObject.x = std::stof(dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["X"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["Y"].isNull())
|
||||
programCodeDataListObject.y = std::stof(dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["Y"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["Width"].isNull())
|
||||
programCodeDataListObject.width = std::stof(dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["Width"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["Height"].isNull())
|
||||
programCodeDataListObject.height = std::stof(dataNodeResultsResultSubResultsSubResultProgramCodeDataListProgramCodeData["Height"].asString());
|
||||
subResultsObject.programCodeDataList.push_back(programCodeDataListObject);
|
||||
}
|
||||
auto allLogoDataListNode = dataNodeResultsResultSubResultsSubResult["LogoDataList"]["LogoData"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResultLogoDataListLogoData : allLogoDataListNode)
|
||||
{
|
||||
Data::Result::SubResult::LogoData logoDataListObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Type"].isNull())
|
||||
logoDataListObject.type = dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Type"].asString();
|
||||
if(!dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Name"].isNull())
|
||||
logoDataListObject.name = dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Name"].asString();
|
||||
if(!dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["X"].isNull())
|
||||
logoDataListObject.x = std::stof(dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["X"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Y"].isNull())
|
||||
logoDataListObject.y = std::stof(dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Y"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Width"].isNull())
|
||||
logoDataListObject.width = std::stof(dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Width"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Height"].isNull())
|
||||
logoDataListObject.height = std::stof(dataNodeResultsResultSubResultsSubResultLogoDataListLogoData["Height"].asString());
|
||||
subResultsObject.logoDataList.push_back(logoDataListObject);
|
||||
}
|
||||
auto allSfaceDataListNode = dataNodeResultsResultSubResultsSubResult["SfaceDataList"]["SfaceData"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData : allSfaceDataListNode)
|
||||
{
|
||||
Data::Result::SubResult::SfaceData sfaceDataListObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["X"].isNull())
|
||||
sfaceDataListObject.x = std::stof(dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["X"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Y"].isNull())
|
||||
sfaceDataListObject.y = std::stof(dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Y"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Width"].isNull())
|
||||
sfaceDataListObject.width = std::stof(dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Width"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Height"].isNull())
|
||||
sfaceDataListObject.height = std::stof(dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Height"].asString());
|
||||
auto allFacesNode = dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceData["Faces"]["Face"];
|
||||
for (auto dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace : allFacesNode)
|
||||
{
|
||||
Data::Result::SubResult::SfaceData::Face facesObject;
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace["Name"].isNull())
|
||||
facesObject.name = dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace["Name"].asString();
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace["Rate"].isNull())
|
||||
facesObject.rate = std::stof(dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace["Rate"].asString());
|
||||
if(!dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace["Id"].isNull())
|
||||
facesObject.id = dataNodeResultsResultSubResultsSubResultSfaceDataListSfaceDataFacesFace["Id"].asString();
|
||||
sfaceDataListObject.faces.push_back(facesObject);
|
||||
}
|
||||
subResultsObject.sfaceDataList.push_back(sfaceDataListObject);
|
||||
}
|
||||
auto allOCRDataList = value["OCRDataList"]["OCRData"];
|
||||
for (auto value : allOCRDataList)
|
||||
subResultsObject.oCRDataList.push_back(value.asString());
|
||||
resultObject.subResults.push_back(subResultsObject);
|
||||
}
|
||||
data_.results.push_back(resultObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScanImageResult::Data ScanImageResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
59
imageaudit/src/model/ScanTextRequest.cc
Normal file
59
imageaudit/src/model/ScanTextRequest.cc
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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/imageaudit/model/ScanTextRequest.h>
|
||||
|
||||
using AlibabaCloud::Imageaudit::Model::ScanTextRequest;
|
||||
|
||||
ScanTextRequest::ScanTextRequest() :
|
||||
RpcServiceRequest("imageaudit", "2019-12-30", "ScanText")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
ScanTextRequest::~ScanTextRequest()
|
||||
{}
|
||||
|
||||
std::vector<ScanTextRequest::Labels> ScanTextRequest::getLabels()const
|
||||
{
|
||||
return labels_;
|
||||
}
|
||||
|
||||
void ScanTextRequest::setLabels(const std::vector<Labels>& labels)
|
||||
{
|
||||
labels_ = labels;
|
||||
for(int dep1 = 0; dep1!= labels.size(); dep1++) {
|
||||
auto labelsObj = labels.at(dep1);
|
||||
std::string labelsObjStr = "Labels." + std::to_string(dep1 + 1);
|
||||
setParameter(labelsObjStr + ".Label", labelsObj.label);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ScanTextRequest::Tasks> ScanTextRequest::getTasks()const
|
||||
{
|
||||
return tasks_;
|
||||
}
|
||||
|
||||
void ScanTextRequest::setTasks(const std::vector<Tasks>& tasks)
|
||||
{
|
||||
tasks_ = tasks;
|
||||
for(int dep1 = 0; dep1!= tasks.size(); dep1++) {
|
||||
auto tasksObj = tasks.at(dep1);
|
||||
std::string tasksObjStr = "Tasks." + std::to_string(dep1 + 1);
|
||||
setParameter(tasksObjStr + ".Content", tasksObj.content);
|
||||
}
|
||||
}
|
||||
|
||||
86
imageaudit/src/model/ScanTextResult.cc
Normal file
86
imageaudit/src/model/ScanTextResult.cc
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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/imageaudit/model/ScanTextResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Imageaudit;
|
||||
using namespace AlibabaCloud::Imageaudit::Model;
|
||||
|
||||
ScanTextResult::ScanTextResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ScanTextResult::ScanTextResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ScanTextResult::~ScanTextResult()
|
||||
{}
|
||||
|
||||
void ScanTextResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
auto allElementsNode = dataNode["Elements"]["Element"];
|
||||
for (auto dataNodeElementsElement : allElementsNode)
|
||||
{
|
||||
Data::Element elementObject;
|
||||
if(!dataNodeElementsElement["TaskId"].isNull())
|
||||
elementObject.taskId = dataNodeElementsElement["TaskId"].asString();
|
||||
auto allResultsNode = dataNodeElementsElement["Results"]["Result"];
|
||||
for (auto dataNodeElementsElementResultsResult : allResultsNode)
|
||||
{
|
||||
Data::Element::Result resultsObject;
|
||||
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 allDetailsNode = dataNodeElementsElementResultsResult["Details"]["Detail"];
|
||||
for (auto dataNodeElementsElementResultsResultDetailsDetail : allDetailsNode)
|
||||
{
|
||||
Data::Element::Result::Detail detailsObject;
|
||||
if(!dataNodeElementsElementResultsResultDetailsDetail["Label"].isNull())
|
||||
detailsObject.label = dataNodeElementsElementResultsResultDetailsDetail["Label"].asString();
|
||||
auto allContextsNode = dataNodeElementsElementResultsResultDetailsDetail["Contexts"]["Context"];
|
||||
for (auto dataNodeElementsElementResultsResultDetailsDetailContextsContext : allContextsNode)
|
||||
{
|
||||
Data::Element::Result::Detail::Context contextsObject;
|
||||
if(!dataNodeElementsElementResultsResultDetailsDetailContextsContext["Context"].isNull())
|
||||
contextsObject.context = dataNodeElementsElementResultsResultDetailsDetailContextsContext["Context"].asString();
|
||||
detailsObject.contexts.push_back(contextsObject);
|
||||
}
|
||||
resultsObject.details.push_back(detailsObject);
|
||||
}
|
||||
elementObject.results.push_back(resultsObject);
|
||||
}
|
||||
data_.elements.push_back(elementObject);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScanTextResult::Data ScanTextResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user