Add new Api SegmentBody.

This commit is contained in:
sdk-team
2020-03-11 15:49:39 +08:00
parent dacb2ef983
commit 61c44f91cc
18 changed files with 309 additions and 29 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/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);
}

View File

@@ -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_;
}

View File

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