From 34a37c33b2cf68208a353432645ffb672a5a93d8 Mon Sep 17 00:00:00 2001 From: sdk-team Date: Wed, 4 Aug 2021 09:42:42 +0000 Subject: [PATCH] Release TaggingAdImage. --- CHANGELOG | 3 + VERSION | 2 +- imagerecog/CMakeLists.txt | 4 + .../imagerecog/ImagerecogClient.h | 8 ++ .../imagerecog/model/TaggingAdImageRequest.h | 54 ++++++++++++++ .../imagerecog/model/TaggingAdImageResult.h | 64 ++++++++++++++++ imagerecog/src/ImagerecogClient.cc | 36 +++++++++ imagerecog/src/model/TaggingAdImageRequest.cc | 62 ++++++++++++++++ imagerecog/src/model/TaggingAdImageResult.cc | 74 +++++++++++++++++++ 9 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageRequest.h create mode 100644 imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageResult.h create mode 100644 imagerecog/src/model/TaggingAdImageRequest.cc create mode 100644 imagerecog/src/model/TaggingAdImageResult.cc diff --git a/CHANGELOG b/CHANGELOG index 86fd54e78..d1fe18011 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2021-08-04 Version: 1.36.840 +- Release TaggingAdImage. + 2021-08-04 Version: 1.36.839 - Create Lindorm Open api. diff --git a/VERSION b/VERSION index 26c572e52..cf145ded8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.36.839 \ No newline at end of file +1.36.840 \ No newline at end of file diff --git a/imagerecog/CMakeLists.txt b/imagerecog/CMakeLists.txt index a7fbb65f9..c7a0c86cf 100644 --- a/imagerecog/CMakeLists.txt +++ b/imagerecog/CMakeLists.txt @@ -43,6 +43,8 @@ set(imagerecog_public_header_model include/alibabacloud/imagerecog/model/RecognizeSceneResult.h include/alibabacloud/imagerecog/model/RecognizeVehicleTypeRequest.h include/alibabacloud/imagerecog/model/RecognizeVehicleTypeResult.h + include/alibabacloud/imagerecog/model/TaggingAdImageRequest.h + include/alibabacloud/imagerecog/model/TaggingAdImageResult.h include/alibabacloud/imagerecog/model/TaggingImageRequest.h include/alibabacloud/imagerecog/model/TaggingImageResult.h ) @@ -70,6 +72,8 @@ set(imagerecog_src src/model/RecognizeSceneResult.cc src/model/RecognizeVehicleTypeRequest.cc src/model/RecognizeVehicleTypeResult.cc + src/model/TaggingAdImageRequest.cc + src/model/TaggingAdImageResult.cc src/model/TaggingImageRequest.cc src/model/TaggingImageResult.cc ) diff --git a/imagerecog/include/alibabacloud/imagerecog/ImagerecogClient.h b/imagerecog/include/alibabacloud/imagerecog/ImagerecogClient.h index eb39c6418..ad0da83bf 100644 --- a/imagerecog/include/alibabacloud/imagerecog/ImagerecogClient.h +++ b/imagerecog/include/alibabacloud/imagerecog/ImagerecogClient.h @@ -44,6 +44,8 @@ #include "model/RecognizeSceneResult.h" #include "model/RecognizeVehicleTypeRequest.h" #include "model/RecognizeVehicleTypeResult.h" +#include "model/TaggingAdImageRequest.h" +#include "model/TaggingAdImageResult.h" #include "model/TaggingImageRequest.h" #include "model/TaggingImageResult.h" @@ -88,6 +90,9 @@ namespace AlibabaCloud typedef Outcome RecognizeVehicleTypeOutcome; typedef std::future RecognizeVehicleTypeOutcomeCallable; typedef std::function&)> RecognizeVehicleTypeAsyncHandler; + typedef Outcome TaggingAdImageOutcome; + typedef std::future TaggingAdImageOutcomeCallable; + typedef std::function&)> TaggingAdImageAsyncHandler; typedef Outcome TaggingImageOutcome; typedef std::future TaggingImageOutcomeCallable; typedef std::function&)> TaggingImageAsyncHandler; @@ -129,6 +134,9 @@ namespace AlibabaCloud RecognizeVehicleTypeOutcome recognizeVehicleType(const Model::RecognizeVehicleTypeRequest &request)const; void recognizeVehicleTypeAsync(const Model::RecognizeVehicleTypeRequest& request, const RecognizeVehicleTypeAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; RecognizeVehicleTypeOutcomeCallable recognizeVehicleTypeCallable(const Model::RecognizeVehicleTypeRequest& request) const; + TaggingAdImageOutcome taggingAdImage(const Model::TaggingAdImageRequest &request)const; + void taggingAdImageAsync(const Model::TaggingAdImageRequest& request, const TaggingAdImageAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; + TaggingAdImageOutcomeCallable taggingAdImageCallable(const Model::TaggingAdImageRequest& request) const; TaggingImageOutcome taggingImage(const Model::TaggingImageRequest &request)const; void taggingImageAsync(const Model::TaggingImageRequest& request, const TaggingImageAsyncHandler& handler, const std::shared_ptr& context = nullptr) const; TaggingImageOutcomeCallable taggingImageCallable(const Model::TaggingImageRequest& request) const; diff --git a/imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageRequest.h b/imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageRequest.h new file mode 100644 index 000000000..6f3014001 --- /dev/null +++ b/imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageRequest.h @@ -0,0 +1,54 @@ +/* + * 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_IMAGERECOG_MODEL_TAGGINGADIMAGEREQUEST_H_ +#define ALIBABACLOUD_IMAGERECOG_MODEL_TAGGINGADIMAGEREQUEST_H_ + +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Imagerecog + { + namespace Model + { + class ALIBABACLOUD_IMAGERECOG_EXPORT TaggingAdImageRequest : public RpcServiceRequest + { + + public: + TaggingAdImageRequest(); + ~TaggingAdImageRequest(); + + int getImageType()const; + void setImageType(int imageType); + bool getAsync()const; + void setAsync(bool async); + std::string getImageURL()const; + void setImageURL(const std::string& imageURL); + + private: + int imageType_; + bool async_; + std::string imageURL_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IMAGERECOG_MODEL_TAGGINGADIMAGEREQUEST_H_ \ No newline at end of file diff --git a/imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageResult.h b/imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageResult.h new file mode 100644 index 000000000..a5e43e1c0 --- /dev/null +++ b/imagerecog/include/alibabacloud/imagerecog/model/TaggingAdImageResult.h @@ -0,0 +1,64 @@ +/* + * 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_IMAGERECOG_MODEL_TAGGINGADIMAGERESULT_H_ +#define ALIBABACLOUD_IMAGERECOG_MODEL_TAGGINGADIMAGERESULT_H_ + +#include +#include +#include +#include +#include + +namespace AlibabaCloud +{ + namespace Imagerecog + { + namespace Model + { + class ALIBABACLOUD_IMAGERECOG_EXPORT TaggingAdImageResult : public ServiceResult + { + public: + struct Data + { + struct Tag + { + float confidence; + std::string value; + }; + std::vector tags; + }; + + + TaggingAdImageResult(); + explicit TaggingAdImageResult(const std::string &payload); + ~TaggingAdImageResult(); + std::string getMessage()const; + Data getData()const; + std::string getCode()const; + + protected: + void parse(const std::string &payload); + private: + std::string message_; + Data data_; + std::string code_; + + }; + } + } +} +#endif // !ALIBABACLOUD_IMAGERECOG_MODEL_TAGGINGADIMAGERESULT_H_ \ No newline at end of file diff --git a/imagerecog/src/ImagerecogClient.cc b/imagerecog/src/ImagerecogClient.cc index 01a934bb7..780e089cc 100644 --- a/imagerecog/src/ImagerecogClient.cc +++ b/imagerecog/src/ImagerecogClient.cc @@ -447,6 +447,42 @@ ImagerecogClient::RecognizeVehicleTypeOutcomeCallable ImagerecogClient::recogniz return task->get_future(); } +ImagerecogClient::TaggingAdImageOutcome ImagerecogClient::taggingAdImage(const TaggingAdImageRequest &request) const +{ + auto endpointOutcome = endpointProvider_->getEndpoint(); + if (!endpointOutcome.isSuccess()) + return TaggingAdImageOutcome(endpointOutcome.error()); + + auto outcome = makeRequest(endpointOutcome.result(), request); + + if (outcome.isSuccess()) + return TaggingAdImageOutcome(TaggingAdImageResult(outcome.result())); + else + return TaggingAdImageOutcome(outcome.error()); +} + +void ImagerecogClient::taggingAdImageAsync(const TaggingAdImageRequest& request, const TaggingAdImageAsyncHandler& handler, const std::shared_ptr& context) const +{ + auto fn = [this, request, handler, context]() + { + handler(this, request, taggingAdImage(request), context); + }; + + asyncExecute(new Runnable(fn)); +} + +ImagerecogClient::TaggingAdImageOutcomeCallable ImagerecogClient::taggingAdImageCallable(const TaggingAdImageRequest &request) const +{ + auto task = std::make_shared>( + [this, request]() + { + return this->taggingAdImage(request); + }); + + asyncExecute(new Runnable([task]() { (*task)(); })); + return task->get_future(); +} + ImagerecogClient::TaggingImageOutcome ImagerecogClient::taggingImage(const TaggingImageRequest &request) const { auto endpointOutcome = endpointProvider_->getEndpoint(); diff --git a/imagerecog/src/model/TaggingAdImageRequest.cc b/imagerecog/src/model/TaggingAdImageRequest.cc new file mode 100644 index 000000000..b7da8ee47 --- /dev/null +++ b/imagerecog/src/model/TaggingAdImageRequest.cc @@ -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 + +using AlibabaCloud::Imagerecog::Model::TaggingAdImageRequest; + +TaggingAdImageRequest::TaggingAdImageRequest() : + RpcServiceRequest("imagerecog", "2019-09-30", "TaggingAdImage") +{ + setMethod(HttpRequest::Method::Post); +} + +TaggingAdImageRequest::~TaggingAdImageRequest() +{} + +int TaggingAdImageRequest::getImageType()const +{ + return imageType_; +} + +void TaggingAdImageRequest::setImageType(int imageType) +{ + imageType_ = imageType; + setBodyParameter("ImageType", std::to_string(imageType)); +} + +bool TaggingAdImageRequest::getAsync()const +{ + return async_; +} + +void TaggingAdImageRequest::setAsync(bool async) +{ + async_ = async; + setBodyParameter("Async", async ? "true" : "false"); +} + +std::string TaggingAdImageRequest::getImageURL()const +{ + return imageURL_; +} + +void TaggingAdImageRequest::setImageURL(const std::string& imageURL) +{ + imageURL_ = imageURL; + setBodyParameter("ImageURL", imageURL); +} + diff --git a/imagerecog/src/model/TaggingAdImageResult.cc b/imagerecog/src/model/TaggingAdImageResult.cc new file mode 100644 index 000000000..8d6d5f32c --- /dev/null +++ b/imagerecog/src/model/TaggingAdImageResult.cc @@ -0,0 +1,74 @@ +/* + * 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::Imagerecog; +using namespace AlibabaCloud::Imagerecog::Model; + +TaggingAdImageResult::TaggingAdImageResult() : + ServiceResult() +{} + +TaggingAdImageResult::TaggingAdImageResult(const std::string &payload) : + ServiceResult() +{ + parse(payload); +} + +TaggingAdImageResult::~TaggingAdImageResult() +{} + +void TaggingAdImageResult::parse(const std::string &payload) +{ + Json::Reader reader; + Json::Value value; + reader.parse(payload, value); + setRequestId(value["RequestId"].asString()); + auto dataNode = value["Data"]; + auto allTagsNode = dataNode["Tags"]["Tag"]; + for (auto dataNodeTagsTag : allTagsNode) + { + Data::Tag tagObject; + if(!dataNodeTagsTag["Value"].isNull()) + tagObject.value = dataNodeTagsTag["Value"].asString(); + if(!dataNodeTagsTag["Confidence"].isNull()) + tagObject.confidence = std::stof(dataNodeTagsTag["Confidence"].asString()); + data_.tags.push_back(tagObject); + } + if(!value["Code"].isNull()) + code_ = value["Code"].asString(); + if(!value["Message"].isNull()) + message_ = value["Message"].asString(); + +} + +std::string TaggingAdImageResult::getMessage()const +{ + return message_; +} + +TaggingAdImageResult::Data TaggingAdImageResult::getData()const +{ + return data_; +} + +std::string TaggingAdImageResult::getCode()const +{ + return code_; +} +