Browse Source

Add new Api SegmentBody.

sdk-team 6 years ago
parent
commit
61c44f91cc

+ 3 - 0
CHANGELOG

@@ -1,3 +1,6 @@
+2020-03-11 Version: 1.36.315
+- Add new Api SegmentBody.
+
 2020-03-11 Version: 1.36.314
 - Support certificate translate.
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.36.314
+1.36.315

+ 4 - 0
ivpd/CMakeLists.txt

@@ -35,6 +35,8 @@ set(ivpd_public_header_model
 	include/alibabacloud/ivpd/model/RecognizeImageStyleResult.h
 	include/alibabacloud/ivpd/model/RecolorImageRequest.h
 	include/alibabacloud/ivpd/model/RecolorImageResult.h
+	include/alibabacloud/ivpd/model/SegmentBodyRequest.h
+	include/alibabacloud/ivpd/model/SegmentBodyResult.h
 	include/alibabacloud/ivpd/model/SegmentImageRequest.h
 	include/alibabacloud/ivpd/model/SegmentImageResult.h )
 
@@ -54,6 +56,8 @@ set(ivpd_src
 	src/model/RecognizeImageStyleResult.cc
 	src/model/RecolorImageRequest.cc
 	src/model/RecolorImageResult.cc
+	src/model/SegmentBodyRequest.cc
+	src/model/SegmentBodyResult.cc
 	src/model/SegmentImageRequest.cc
 	src/model/SegmentImageResult.cc )
 

+ 8 - 0
ivpd/include/alibabacloud/ivpd/IvpdClient.h

@@ -36,6 +36,8 @@
 #include "model/RecognizeImageStyleResult.h"
 #include "model/RecolorImageRequest.h"
 #include "model/RecolorImageResult.h"
+#include "model/SegmentBodyRequest.h"
+#include "model/SegmentBodyResult.h"
 #include "model/SegmentImageRequest.h"
 #include "model/SegmentImageResult.h"
 
@@ -68,6 +70,9 @@ namespace AlibabaCloud
 			typedef Outcome<Error, Model::RecolorImageResult> RecolorImageOutcome;
 			typedef std::future<RecolorImageOutcome> RecolorImageOutcomeCallable;
 			typedef std::function<void(const IvpdClient*, const Model::RecolorImageRequest&, const RecolorImageOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RecolorImageAsyncHandler;
+			typedef Outcome<Error, Model::SegmentBodyResult> SegmentBodyOutcome;
+			typedef std::future<SegmentBodyOutcome> SegmentBodyOutcomeCallable;
+			typedef std::function<void(const IvpdClient*, const Model::SegmentBodyRequest&, const SegmentBodyOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SegmentBodyAsyncHandler;
 			typedef Outcome<Error, Model::SegmentImageResult> SegmentImageOutcome;
 			typedef std::future<SegmentImageOutcome> SegmentImageOutcomeCallable;
 			typedef std::function<void(const IvpdClient*, const Model::SegmentImageRequest&, const SegmentImageOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> SegmentImageAsyncHandler;
@@ -97,6 +102,9 @@ namespace AlibabaCloud
 			RecolorImageOutcome recolorImage(const Model::RecolorImageRequest &request)const;
 			void recolorImageAsync(const Model::RecolorImageRequest& request, const RecolorImageAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
 			RecolorImageOutcomeCallable recolorImageCallable(const Model::RecolorImageRequest& request) const;
+			SegmentBodyOutcome segmentBody(const Model::SegmentBodyRequest &request)const;
+			void segmentBodyAsync(const Model::SegmentBodyRequest& request, const SegmentBodyAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
+			SegmentBodyOutcomeCallable segmentBodyCallable(const Model::SegmentBodyRequest& request) const;
 			SegmentImageOutcome segmentImage(const Model::SegmentImageRequest &request)const;
 			void segmentImageAsync(const Model::SegmentImageRequest& request, const SegmentImageAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
 			SegmentImageOutcomeCallable segmentImageCallable(const Model::SegmentImageRequest& request) const;

+ 1 - 0
ivpd/include/alibabacloud/ivpd/model/RecolorImageRequest.h

@@ -30,6 +30,7 @@ namespace AlibabaCloud
 		{
 			class ALIBABACLOUD_IVPD_EXPORT RecolorImageRequest : public RpcServiceRequest
 			{
+			public:
 				struct ColorTemplate
 				{
 					std::string color;

+ 48 - 0
ivpd/include/alibabacloud/ivpd/model/SegmentBodyRequest.h

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

+ 59 - 0
ivpd/include/alibabacloud/ivpd/model/SegmentBodyResult.h

@@ -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.
+ */
+
+#ifndef ALIBABACLOUD_IVPD_MODEL_SEGMENTBODYRESULT_H_
+#define ALIBABACLOUD_IVPD_MODEL_SEGMENTBODYRESULT_H_
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <alibabacloud/core/ServiceResult.h>
+#include <alibabacloud/ivpd/IvpdExport.h>
+
+namespace AlibabaCloud
+{
+	namespace Ivpd
+	{
+		namespace Model
+		{
+			class ALIBABACLOUD_IVPD_EXPORT SegmentBodyResult : public ServiceResult
+			{
+			public:
+				struct Data
+				{
+					std::string imageUrl;
+				};
+
+
+				SegmentBodyResult();
+				explicit SegmentBodyResult(const std::string &payload);
+				~SegmentBodyResult();
+				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_IVPD_MODEL_SEGMENTBODYRESULT_H_

+ 36 - 0
ivpd/src/IvpdClient.cc

@@ -303,6 +303,42 @@ IvpdClient::RecolorImageOutcomeCallable IvpdClient::recolorImageCallable(const R
 	return task->get_future();
 }
 
+IvpdClient::SegmentBodyOutcome IvpdClient::segmentBody(const SegmentBodyRequest &request) const
+{
+	auto endpointOutcome = endpointProvider_->getEndpoint();
+	if (!endpointOutcome.isSuccess())
+		return SegmentBodyOutcome(endpointOutcome.error());
+
+	auto outcome = makeRequest(endpointOutcome.result(), request);
+
+	if (outcome.isSuccess())
+		return SegmentBodyOutcome(SegmentBodyResult(outcome.result()));
+	else
+		return SegmentBodyOutcome(outcome.error());
+}
+
+void IvpdClient::segmentBodyAsync(const SegmentBodyRequest& request, const SegmentBodyAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
+{
+	auto fn = [this, request, handler, context]()
+	{
+		handler(this, request, segmentBody(request), context);
+	};
+
+	asyncExecute(new Runnable(fn));
+}
+
+IvpdClient::SegmentBodyOutcomeCallable IvpdClient::segmentBodyCallable(const SegmentBodyRequest &request) const
+{
+	auto task = std::make_shared<std::packaged_task<SegmentBodyOutcome()>>(
+			[this, request]()
+			{
+			return this->segmentBody(request);
+			});
+
+	asyncExecute(new Runnable([task]() { (*task)(); }));
+	return task->get_future();
+}
+
 IvpdClient::SegmentImageOutcome IvpdClient::segmentImage(const SegmentImageRequest &request) const
 {
 	auto endpointOutcome = endpointProvider_->getEndpoint();

+ 6 - 4
ivpd/src/model/ChangeImageSizeRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::ChangeImageSizeRequest;
 
 ChangeImageSizeRequest::ChangeImageSizeRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "ChangeImageSize")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 ChangeImageSizeRequest::~ChangeImageSizeRequest()
 {}
@@ -33,7 +35,7 @@ std::string ChangeImageSizeRequest::getUrl()const
 void ChangeImageSizeRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }
 
 int ChangeImageSizeRequest::getWidth()const
@@ -44,7 +46,7 @@ int ChangeImageSizeRequest::getWidth()const
 void ChangeImageSizeRequest::setWidth(int width)
 {
 	width_ = width;
-	setCoreParameter("Width", std::to_string(width));
+	setBodyParameter("Width", std::to_string(width));
 }
 
 int ChangeImageSizeRequest::getHeight()const
@@ -55,6 +57,6 @@ int ChangeImageSizeRequest::getHeight()const
 void ChangeImageSizeRequest::setHeight(int height)
 {
 	height_ = height;
-	setCoreParameter("Height", std::to_string(height));
+	setBodyParameter("Height", std::to_string(height));
 }
 

+ 4 - 2
ivpd/src/model/DetectImageElementsRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::DetectImageElementsRequest;
 
 DetectImageElementsRequest::DetectImageElementsRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "DetectImageElements")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 DetectImageElementsRequest::~DetectImageElementsRequest()
 {}
@@ -33,6 +35,6 @@ std::string DetectImageElementsRequest::getUrl()const
 void DetectImageElementsRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }
 

+ 5 - 3
ivpd/src/model/ExtendImageStyleRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::ExtendImageStyleRequest;
 
 ExtendImageStyleRequest::ExtendImageStyleRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "ExtendImageStyle")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 ExtendImageStyleRequest::~ExtendImageStyleRequest()
 {}
@@ -33,7 +35,7 @@ std::string ExtendImageStyleRequest::getMajorUrl()const
 void ExtendImageStyleRequest::setMajorUrl(const std::string& majorUrl)
 {
 	majorUrl_ = majorUrl;
-	setCoreParameter("MajorUrl", majorUrl);
+	setBodyParameter("MajorUrl", majorUrl);
 }
 
 std::string ExtendImageStyleRequest::getStyleUrl()const
@@ -44,6 +46,6 @@ std::string ExtendImageStyleRequest::getStyleUrl()const
 void ExtendImageStyleRequest::setStyleUrl(const std::string& styleUrl)
 {
 	styleUrl_ = styleUrl;
-	setCoreParameter("StyleUrl", styleUrl);
+	setBodyParameter("StyleUrl", styleUrl);
 }
 

+ 4 - 2
ivpd/src/model/MakeSuperResolutionImageRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::MakeSuperResolutionImageRequest;
 
 MakeSuperResolutionImageRequest::MakeSuperResolutionImageRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "MakeSuperResolutionImage")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 MakeSuperResolutionImageRequest::~MakeSuperResolutionImageRequest()
 {}
@@ -33,6 +35,6 @@ std::string MakeSuperResolutionImageRequest::getUrl()const
 void MakeSuperResolutionImageRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }
 

+ 5 - 3
ivpd/src/model/RecognizeImageColorRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::RecognizeImageColorRequest;
 
 RecognizeImageColorRequest::RecognizeImageColorRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "RecognizeImageColor")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 RecognizeImageColorRequest::~RecognizeImageColorRequest()
 {}
@@ -33,7 +35,7 @@ std::string RecognizeImageColorRequest::getUrl()const
 void RecognizeImageColorRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }
 
 std::string RecognizeImageColorRequest::getColorCount()const
@@ -44,6 +46,6 @@ std::string RecognizeImageColorRequest::getColorCount()const
 void RecognizeImageColorRequest::setColorCount(const std::string& colorCount)
 {
 	colorCount_ = colorCount;
-	setCoreParameter("ColorCount", colorCount);
+	setBodyParameter("ColorCount", colorCount);
 }
 

+ 4 - 2
ivpd/src/model/RecognizeImageStyleRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::RecognizeImageStyleRequest;
 
 RecognizeImageStyleRequest::RecognizeImageStyleRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "RecognizeImageStyle")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 RecognizeImageStyleRequest::~RecognizeImageStyleRequest()
 {}
@@ -33,6 +35,6 @@ std::string RecognizeImageStyleRequest::getUrl()const
 void RecognizeImageStyleRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }
 

+ 11 - 10
ivpd/src/model/RecolorImageRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::RecolorImageRequest;
 
 RecolorImageRequest::RecolorImageRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "RecolorImage")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 RecolorImageRequest::~RecolorImageRequest()
 {}
@@ -33,11 +35,10 @@ std::vector<RecolorImageRequest::ColorTemplate> RecolorImageRequest::getColorTem
 void RecolorImageRequest::setColorTemplate(const std::vector<ColorTemplate>& colorTemplate)
 {
 	colorTemplate_ = colorTemplate;
-	int i = 0;
-	for(int i = 0; i!= colorTemplate.size(); i++)	{
-		auto obj = colorTemplate.at(i);
-		std::string str ="ColorTemplate."+ std::to_string(i);
-		setCoreParameter(str + ".Color", obj.color);
+	for(int dep1 = 0; dep1!= colorTemplate.size(); dep1++) {
+		auto colorTemplateObj = colorTemplate.at(dep1);
+		std::string colorTemplateObjStr = "ColorTemplate." + std::to_string(dep1 + 1);
+		setParameter(colorTemplateObjStr + ".Color", colorTemplateObj.color);
 	}
 }
 
@@ -49,7 +50,7 @@ std::string RecolorImageRequest::getUrl()const
 void RecolorImageRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }
 
 std::string RecolorImageRequest::getMode()const
@@ -60,7 +61,7 @@ std::string RecolorImageRequest::getMode()const
 void RecolorImageRequest::setMode(const std::string& mode)
 {
 	mode_ = mode;
-	setCoreParameter("Mode", mode);
+	setBodyParameter("Mode", mode);
 }
 
 int RecolorImageRequest::getColorCount()const
@@ -71,7 +72,7 @@ int RecolorImageRequest::getColorCount()const
 void RecolorImageRequest::setColorCount(int colorCount)
 {
 	colorCount_ = colorCount;
-	setCoreParameter("ColorCount", std::to_string(colorCount));
+	setBodyParameter("ColorCount", std::to_string(colorCount));
 }
 
 std::string RecolorImageRequest::getRefUrl()const
@@ -82,6 +83,6 @@ std::string RecolorImageRequest::getRefUrl()const
 void RecolorImageRequest::setRefUrl(const std::string& refUrl)
 {
 	refUrl_ = refUrl;
-	setCoreParameter("RefUrl", refUrl);
+	setBodyParameter("RefUrl", refUrl);
 }
 

+ 40 - 0
ivpd/src/model/SegmentBodyRequest.cc

@@ -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/ivpd/model/SegmentBodyRequest.h>
+
+using AlibabaCloud::Ivpd::Model::SegmentBodyRequest;
+
+SegmentBodyRequest::SegmentBodyRequest() :
+	RpcServiceRequest("ivpd", "2019-06-25", "SegmentBody")
+{
+	setMethod(HttpRequest::Method::Post);
+}
+
+SegmentBodyRequest::~SegmentBodyRequest()
+{}
+
+std::string SegmentBodyRequest::getImageUrl()const
+{
+	return imageUrl_;
+}
+
+void SegmentBodyRequest::setImageUrl(const std::string& imageUrl)
+{
+	imageUrl_ = imageUrl;
+	setBodyParameter("ImageUrl", imageUrl);
+}
+

+ 66 - 0
ivpd/src/model/SegmentBodyResult.cc

@@ -0,0 +1,66 @@
+/*
+ * 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/ivpd/model/SegmentBodyResult.h>
+#include <json/json.h>
+
+using namespace AlibabaCloud::Ivpd;
+using namespace AlibabaCloud::Ivpd::Model;
+
+SegmentBodyResult::SegmentBodyResult() :
+	ServiceResult()
+{}
+
+SegmentBodyResult::SegmentBodyResult(const std::string &payload) :
+	ServiceResult()
+{
+	parse(payload);
+}
+
+SegmentBodyResult::~SegmentBodyResult()
+{}
+
+void SegmentBodyResult::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["ImageUrl"].isNull())
+		data_.imageUrl = dataNode["ImageUrl"].asString();
+	if(!value["Code"].isNull())
+		code_ = value["Code"].asString();
+	if(!value["Message"].isNull())
+		message_ = value["Message"].asString();
+
+}
+
+std::string SegmentBodyResult::getMessage()const
+{
+	return message_;
+}
+
+SegmentBodyResult::Data SegmentBodyResult::getData()const
+{
+	return data_;
+}
+
+std::string SegmentBodyResult::getCode()const
+{
+	return code_;
+}
+

+ 4 - 2
ivpd/src/model/SegmentImageRequest.cc

@@ -20,7 +20,9 @@ using AlibabaCloud::Ivpd::Model::SegmentImageRequest;
 
 SegmentImageRequest::SegmentImageRequest() :
 	RpcServiceRequest("ivpd", "2019-06-25", "SegmentImage")
-{}
+{
+	setMethod(HttpRequest::Method::Post);
+}
 
 SegmentImageRequest::~SegmentImageRequest()
 {}
@@ -33,6 +35,6 @@ std::string SegmentImageRequest::getUrl()const
 void SegmentImageRequest::setUrl(const std::string& url)
 {
 	url_ = url;
-	setCoreParameter("Url", url);
+	setBodyParameter("Url", url);
 }