From 2d9dc667196a7ee7e732a3ac8be6112a689a3672 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Fri, 13 Nov 2020 09:47:30 +0000 Subject: [PATCH] Update Imageaudit. --- CHANGELOG | 3 + imageaudit/CMakeLists.txt | 90 ++++++++++ .../imageaudit/ImageauditClient.h | 62 +++++++ .../imageaudit/ImageauditExport.h | 32 ++++ .../imageaudit/model/ScanImageRequest.h | 60 +++++++ .../imageaudit/model/ScanImageResult.h | 114 +++++++++++++ .../imageaudit/model/ScanTextRequest.h | 60 +++++++ .../imageaudit/model/ScanTextResult.h | 76 +++++++++ imageaudit/src/ImageauditClient.cc | 125 ++++++++++++++ imageaudit/src/model/ScanImageRequest.cc | 61 +++++++ imageaudit/src/model/ScanImageResult.cc | 155 ++++++++++++++++++ imageaudit/src/model/ScanTextRequest.cc | 59 +++++++ imageaudit/src/model/ScanTextResult.cc | 86 ++++++++++ 13 files changed, 983 insertions(+) create mode 100644 imageaudit/CMakeLists.txt create mode 100644 imageaudit/include/alibabacloud/imageaudit/ImageauditClient.h create mode 100644 imageaudit/include/alibabacloud/imageaudit/ImageauditExport.h create mode 100644 imageaudit/include/alibabacloud/imageaudit/model/ScanImageRequest.h create mode 100644 imageaudit/include/alibabacloud/imageaudit/model/ScanImageResult.h create mode 100644 imageaudit/include/alibabacloud/imageaudit/model/ScanTextRequest.h create mode 100644 imageaudit/include/alibabacloud/imageaudit/model/ScanTextResult.h create mode 100644 imageaudit/src/ImageauditClient.cc create mode 100644 imageaudit/src/model/ScanImageRequest.cc create mode 100644 imageaudit/src/model/ScanImageResult.cc create mode 100644 imageaudit/src/model/ScanTextRequest.cc create mode 100644 imageaudit/src/model/ScanTextResult.cc diff --git a/CHANGELOG b/CHANGELOG index 9cbc741e0..7c865d503 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2020-11-13 Version: patch +- Update Imageaudit. + 2020-11-13 Version: patch - Add DeccribeEngineVersion DescribeTasks DescribeInstanceConfig and more APIs. diff --git a/imageaudit/CMakeLists.txt b/imageaudit/CMakeLists.txt new file mode 100644 index 000000000..3f9dbd4c5 --- /dev/null +++ b/imageaudit/CMakeLists.txt @@ -0,0 +1,90 @@ +# +# 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. +# + +set(public_header_dir ${CMAKE_CURRENT_SOURCE_DIR}/../include) + +set(imageaudit_public_header + include/alibabacloud/imageaudit/ImageauditClient.h + include/alibabacloud/imageaudit/ImageauditExport.h ) + +set(imageaudit_public_header_model + include/alibabacloud/imageaudit/model/ScanImageRequest.h + include/alibabacloud/imageaudit/model/ScanImageResult.h + include/alibabacloud/imageaudit/model/ScanTextRequest.h + include/alibabacloud/imageaudit/model/ScanTextResult.h ) + +set(imageaudit_src + src/ImageauditClient.cc + src/model/ScanImageRequest.cc + src/model/ScanImageResult.cc + src/model/ScanTextRequest.cc + src/model/ScanTextResult.cc ) + +add_library(imageaudit ${LIB_TYPE} + ${imageaudit_public_header} + ${imageaudit_public_header_model} + ${imageaudit_src}) + +set_target_properties(imageaudit + PROPERTIES + LINKER_LANGUAGE CXX + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + OUTPUT_NAME ${TARGET_OUTPUT_NAME_PREFIX}imageaudit + ) + +if(${LIB_TYPE} STREQUAL "SHARED") + set_target_properties(imageaudit + PROPERTIES + DEFINE_SYMBOL ALIBABACLOUD_IMAGEAUDIT_LIBRARY) +endif() + +target_include_directories(imageaudit + PRIVATE include + ${CMAKE_SOURCE_DIR}/core/include + ) +target_link_libraries(imageaudit + core) + +if(CMAKE_HOST_WIN32) + ExternalProject_Get_Property(jsoncpp INSTALL_DIR) + set(jsoncpp_install_dir ${INSTALL_DIR}) + add_dependencies(imageaudit + jsoncpp) + target_include_directories(imageaudit + PRIVATE ${jsoncpp_install_dir}/include) + target_link_libraries(imageaudit + ${jsoncpp_install_dir}/lib/jsoncpp.lib) + set_target_properties(imageaudit + PROPERTIES + COMPILE_OPTIONS "/bigobj") +else() + target_include_directories(imageaudit + PRIVATE /usr/include/jsoncpp) + target_link_libraries(imageaudit + jsoncpp) +endif() + +install(FILES ${imageaudit_public_header} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/imageaudit) +install(FILES ${imageaudit_public_header_model} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/alibabacloud/imageaudit/model) +install(TARGETS imageaudit + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) \ No newline at end of file diff --git a/imageaudit/include/alibabacloud/imageaudit/ImageauditClient.h b/imageaudit/include/alibabacloud/imageaudit/ImageauditClient.h new file mode 100644 index 000000000..bc2d45448 --- /dev/null +++ b/imageaudit/include/alibabacloud/imageaudit/ImageauditClient.h @@ -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. + */ + +#ifndef ALIBABACLOUD_IMAGEAUDIT_IMAGEAUDITCLIENT_H_ +#define ALIBABACLOUD_IMAGEAUDIT_IMAGEAUDITCLIENT_H_ + +#include +#include +#include +#include +#include "ImageauditExport.h" +#include "model/ScanImageRequest.h" +#include "model/ScanImageResult.h" +#include "model/ScanTextRequest.h" +#include "model/ScanTextResult.h" + + +namespace AlibabaCloud +{ + namespace Imageaudit + { + class ALIBABACLOUD_IMAGEAUDIT_EXPORT ImageauditClient : public RpcServiceClient + { + public: + typedef Outcome ScanImageOutcome; + typedef std::future ScanImageOutcomeCallable; + typedef std::function&)> ScanImageAsyncHandler; + typedef Outcome ScanTextOutcome; + typedef std::future ScanTextOutcomeCallable; + typedef std::function&)> ScanTextAsyncHandler; + + ImageauditClient(const Credentials &credentials, const ClientConfiguration &configuration); + ImageauditClient(const std::shared_ptr &credentialsProvider, const ClientConfiguration &configuration); + ImageauditClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration); + ~ImageauditClient(); + ScanImageOutcome scanImage(const Model::ScanImageRequest &request)const; + void scanImageAsync(const Model::ScanImageRequest& request, const ScanImageAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + ScanImageOutcomeCallable scanImageCallable(const Model::ScanImageRequest& request) const; + ScanTextOutcome scanText(const Model::ScanTextRequest &request)const; + void scanTextAsync(const Model::ScanTextRequest& request, const ScanTextAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + ScanTextOutcomeCallable scanTextCallable(const Model::ScanTextRequest& request) const; + + private: + std::shared_ptr endpointProvider_; + }; + } +} + +#endif // !ALIBABACLOUD_IMAGEAUDIT_IMAGEAUDITCLIENT_H_ diff --git a/imageaudit/include/alibabacloud/imageaudit/ImageauditExport.h b/imageaudit/include/alibabacloud/imageaudit/ImageauditExport.h new file mode 100644 index 000000000..8cec4f3cf --- /dev/null +++ b/imageaudit/include/alibabacloud/imageaudit/ImageauditExport.h @@ -0,0 +1,32 @@ +/* + * 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_IMAGEAUDIT_IMAGEAUDITEXPORT_H_ +#define ALIBABACLOUD_IMAGEAUDIT_IMAGEAUDITEXPORT_H_ + +#include + +#if defined(ALIBABACLOUD_SHARED) +# if defined(ALIBABACLOUD_IMAGEAUDIT_LIBRARY) +# define ALIBABACLOUD_IMAGEAUDIT_EXPORT ALIBABACLOUD_DECL_EXPORT +# else +# define ALIBABACLOUD_IMAGEAUDIT_EXPORT ALIBABACLOUD_DECL_IMPORT +# endif +#else +# define ALIBABACLOUD_IMAGEAUDIT_EXPORT +#endif + +#endif // !ALIBABACLOUD_IMAGEAUDIT_IMAGEAUDITEXPORT_H_ \ No newline at end of file diff --git a/imageaudit/include/alibabacloud/imageaudit/model/ScanImageRequest.h b/imageaudit/include/alibabacloud/imageaudit/model/ScanImageRequest.h new file mode 100644 index 000000000..1ea329e09 --- /dev/null +++ b/imageaudit/include/alibabacloud/imageaudit/model/ScanImageRequest.h @@ -0,0 +1,60 @@ +/* + * 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_IMAGEAUDIT_MODEL_SCANIMAGEREQUEST_H_ +#define ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANIMAGEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Imageaudit + { + namespace Model + { + class ALIBABACLOUD_IMAGEAUDIT_EXPORT ScanImageRequest : public RpcServiceRequest + { + public: + struct Task + { + std::string dataId; + std::string imageURL; + int maxFrames; + int interval; + long imageTimeMillisecond; + }; + + public: + ScanImageRequest(); + ~ScanImageRequest(); + + std::vector getScene()const; + void setScene(const std::vector& scene); + std::vector getTask()const; + void setTask(const std::vector& task); + + private: + std::vector scene_; + std::vector task_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANIMAGEREQUEST_H_ \ No newline at end of file diff --git a/imageaudit/include/alibabacloud/imageaudit/model/ScanImageResult.h b/imageaudit/include/alibabacloud/imageaudit/model/ScanImageResult.h new file mode 100644 index 000000000..e72c267f9 --- /dev/null +++ b/imageaudit/include/alibabacloud/imageaudit/model/ScanImageResult.h @@ -0,0 +1,114 @@ +/* + * 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_IMAGEAUDIT_MODEL_SCANIMAGERESULT_H_ +#define ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANIMAGERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Imageaudit + { + namespace Model + { + class ALIBABACLOUD_IMAGEAUDIT_EXPORT ScanImageResult : public ServiceResult + { + public: + struct Data + { + struct Result + { + struct SubResult + { + struct Frame + { + float rate; + std::string uRL; + }; + struct HintWordsInfo + { + std::string context; + }; + struct ProgramCodeData + { + float x; + float y; + float height; + float width; + }; + struct LogoData + { + std::string type; + float x; + float y; + float height; + float width; + std::string name; + }; + struct SfaceData + { + struct Face + { + float rate; + std::string id; + std::string name; + }; + float x; + float y; + float height; + float width; + std::vector faces; + }; + std::vector frames; + std::string suggestion; + std::vector sfaceDataList; + float rate; + std::vector oCRDataList; + std::vector hintWordsInfoList; + std::string label; + std::vector logoDataList; + std::string scene; + std::vector programCodeDataList; + }; + std::string dataId; + std::string taskId; + std::string imageURL; + std::vector subResults; + }; + std::vector results; + }; + + + ScanImageResult(); + explicit ScanImageResult(const std::string &payload); + ~ScanImageResult(); + Data getData()const; + + protected: + void parse(const std::string &payload); + private: + Data data_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANIMAGERESULT_H_ \ No newline at end of file diff --git a/imageaudit/include/alibabacloud/imageaudit/model/ScanTextRequest.h b/imageaudit/include/alibabacloud/imageaudit/model/ScanTextRequest.h new file mode 100644 index 000000000..e3a65d22b --- /dev/null +++ b/imageaudit/include/alibabacloud/imageaudit/model/ScanTextRequest.h @@ -0,0 +1,60 @@ +/* + * 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_IMAGEAUDIT_MODEL_SCANTEXTREQUEST_H_ +#define ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANTEXTREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Imageaudit + { + namespace Model + { + class ALIBABACLOUD_IMAGEAUDIT_EXPORT ScanTextRequest : public RpcServiceRequest + { + public: + struct Labels + { + std::string label; + }; + struct Tasks + { + std::string content; + }; + + public: + ScanTextRequest(); + ~ScanTextRequest(); + + std::vector getLabels()const; + void setLabels(const std::vector& labels); + std::vector getTasks()const; + void setTasks(const std::vector& tasks); + + private: + std::vector labels_; + std::vector tasks_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANTEXTREQUEST_H_ \ No newline at end of file diff --git a/imageaudit/include/alibabacloud/imageaudit/model/ScanTextResult.h b/imageaudit/include/alibabacloud/imageaudit/model/ScanTextResult.h new file mode 100644 index 000000000..aa13280a0 --- /dev/null +++ b/imageaudit/include/alibabacloud/imageaudit/model/ScanTextResult.h @@ -0,0 +1,76 @@ +/* + * 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_IMAGEAUDIT_MODEL_SCANTEXTRESULT_H_ +#define ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANTEXTRESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Imageaudit + { + namespace Model + { + class ALIBABACLOUD_IMAGEAUDIT_EXPORT ScanTextResult : public ServiceResult + { + public: + struct Data + { + struct Element + { + struct Result + { + struct Detail + { + struct Context + { + std::string context; + }; + std::string label; + std::vector contexts; + }; + std::string suggestion; + std::vector details; + float rate; + std::string label; + }; + std::string taskId; + std::vector results; + }; + std::vector elements; + }; + + + ScanTextResult(); + explicit ScanTextResult(const std::string &payload); + ~ScanTextResult(); + Data getData()const; + + protected: + void parse(const std::string &payload); + private: + Data data_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IMAGEAUDIT_MODEL_SCANTEXTRESULT_H_ \ No newline at end of file diff --git a/imageaudit/src/ImageauditClient.cc b/imageaudit/src/ImageauditClient.cc new file mode 100644 index 000000000..d28cfde74 --- /dev/null +++ b/imageaudit/src/ImageauditClient.cc @@ -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 +#include + +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(credentials), configuration) +{ + auto locationClient = std::make_shared(credentials, configuration); + endpointProvider_ = std::make_shared(locationClient, configuration.regionId(), SERVICE_NAME, "imageaudit"); +} + +ImageauditClient::ImageauditClient(const std::shared_ptr& credentialsProvider, const ClientConfiguration & configuration) : + RpcServiceClient(SERVICE_NAME, credentialsProvider, configuration) +{ + auto locationClient = std::make_shared(credentialsProvider, configuration); + endpointProvider_ = std::make_shared(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(accessKeyId, accessKeySecret), configuration) +{ + auto locationClient = std::make_shared(accessKeyId, accessKeySecret, configuration); + endpointProvider_ = std::make_shared(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& 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>( + [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& 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>( + [this, request]() + { + return this->scanText(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + diff --git a/imageaudit/src/model/ScanImageRequest.cc b/imageaudit/src/model/ScanImageRequest.cc new file mode 100644 index 000000000..5c3b4d548 --- /dev/null +++ b/imageaudit/src/model/ScanImageRequest.cc @@ -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 + +using AlibabaCloud::Imageaudit::Model::ScanImageRequest; + +ScanImageRequest::ScanImageRequest() : + RpcServiceRequest("imageaudit", "2019-12-30", "ScanImage") +{ + setMethod(HttpRequest::Method::Post); +} + +ScanImageRequest::~ScanImageRequest() +{} + +std::vector ScanImageRequest::getScene()const +{ + return scene_; +} + +void ScanImageRequest::setScene(const std::vector& scene) +{ + scene_ = scene; + for(int dep1 = 0; dep1!= scene.size(); dep1++) { + setBodyParameter("Scene."+ std::to_string(dep1), scene.at(dep1)); + } +} + +std::vector ScanImageRequest::getTask()const +{ + return task_; +} + +void ScanImageRequest::setTask(const std::vector& 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)); + } +} + diff --git a/imageaudit/src/model/ScanImageResult.cc b/imageaudit/src/model/ScanImageResult.cc new file mode 100644 index 000000000..f02d2a753 --- /dev/null +++ b/imageaudit/src/model/ScanImageResult.cc @@ -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 +#include + +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_; +} + diff --git a/imageaudit/src/model/ScanTextRequest.cc b/imageaudit/src/model/ScanTextRequest.cc new file mode 100644 index 000000000..614746bb0 --- /dev/null +++ b/imageaudit/src/model/ScanTextRequest.cc @@ -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 + +using AlibabaCloud::Imageaudit::Model::ScanTextRequest; + +ScanTextRequest::ScanTextRequest() : + RpcServiceRequest("imageaudit", "2019-12-30", "ScanText") +{ + setMethod(HttpRequest::Method::Post); +} + +ScanTextRequest::~ScanTextRequest() +{} + +std::vector ScanTextRequest::getLabels()const +{ + return labels_; +} + +void ScanTextRequest::setLabels(const std::vector& 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::getTasks()const +{ + return tasks_; +} + +void ScanTextRequest::setTasks(const std::vector& 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); + } +} + diff --git a/imageaudit/src/model/ScanTextResult.cc b/imageaudit/src/model/ScanTextResult.cc new file mode 100644 index 000000000..d2e532743 --- /dev/null +++ b/imageaudit/src/model/ScanTextResult.cc @@ -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 +#include + +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_; +} +