Supported Api DetectIPCPedestrian.

This commit is contained in:
sdk-team
2020-08-14 16:04:45 +08:00
parent 08e11e9bb0
commit 4836dfddfc
13 changed files with 593 additions and 4 deletions

View File

@@ -31,21 +31,21 @@ FacebodyClient::FacebodyClient(const Credentials &credentials, const ClientConfi
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, "facebody");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
FacebodyClient::FacebodyClient(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, "facebody");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
FacebodyClient::FacebodyClient(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, "facebody");
endpointProvider_ = std::make_shared<EndpointProvider>(locationClient, configuration.regionId(), SERVICE_NAME, "");
}
FacebodyClient::~FacebodyClient()
@@ -123,6 +123,42 @@ FacebodyClient::AddFaceEntityOutcomeCallable FacebodyClient::addFaceEntityCallab
return task->get_future();
}
FacebodyClient::BlurFaceOutcome FacebodyClient::blurFace(const BlurFaceRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return BlurFaceOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return BlurFaceOutcome(BlurFaceResult(outcome.result()));
else
return BlurFaceOutcome(outcome.error());
}
void FacebodyClient::blurFaceAsync(const BlurFaceRequest& request, const BlurFaceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, blurFace(request), context);
};
asyncExecute(new Runnable(fn));
}
FacebodyClient::BlurFaceOutcomeCallable FacebodyClient::blurFaceCallable(const BlurFaceRequest &request) const
{
auto task = std::make_shared<std::packaged_task<BlurFaceOutcome()>>(
[this, request]()
{
return this->blurFace(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
FacebodyClient::BodyPostureOutcome FacebodyClient::bodyPosture(const BodyPostureRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
@@ -447,6 +483,42 @@ FacebodyClient::DetectFaceOutcomeCallable FacebodyClient::detectFaceCallable(con
return task->get_future();
}
FacebodyClient::DetectIPCPedestrianOutcome FacebodyClient::detectIPCPedestrian(const DetectIPCPedestrianRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();
if (!endpointOutcome.isSuccess())
return DetectIPCPedestrianOutcome(endpointOutcome.error());
auto outcome = makeRequest(endpointOutcome.result(), request);
if (outcome.isSuccess())
return DetectIPCPedestrianOutcome(DetectIPCPedestrianResult(outcome.result()));
else
return DetectIPCPedestrianOutcome(outcome.error());
}
void FacebodyClient::detectIPCPedestrianAsync(const DetectIPCPedestrianRequest& request, const DetectIPCPedestrianAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
{
auto fn = [this, request, handler, context]()
{
handler(this, request, detectIPCPedestrian(request), context);
};
asyncExecute(new Runnable(fn));
}
FacebodyClient::DetectIPCPedestrianOutcomeCallable FacebodyClient::detectIPCPedestrianCallable(const DetectIPCPedestrianRequest &request) const
{
auto task = std::make_shared<std::packaged_task<DetectIPCPedestrianOutcome()>>(
[this, request]()
{
return this->detectIPCPedestrian(request);
});
asyncExecute(new Runnable([task]() { (*task)(); }));
return task->get_future();
}
FacebodyClient::DetectLivingFaceOutcome FacebodyClient::detectLivingFace(const DetectLivingFaceRequest &request) const
{
auto endpointOutcome = endpointProvider_->getEndpoint();

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/facebody/model/BlurFaceRequest.h>
using AlibabaCloud::Facebody::Model::BlurFaceRequest;
BlurFaceRequest::BlurFaceRequest() :
RpcServiceRequest("facebody", "2019-12-30", "BlurFace")
{
setMethod(HttpRequest::Method::Post);
}
BlurFaceRequest::~BlurFaceRequest()
{}
std::string BlurFaceRequest::getImageURL()const
{
return imageURL_;
}
void BlurFaceRequest::setImageURL(const std::string& imageURL)
{
imageURL_ = imageURL;
setBodyParameter("ImageURL", imageURL);
}

View File

@@ -0,0 +1,52 @@
/*
* 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/facebody/model/BlurFaceResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Facebody;
using namespace AlibabaCloud::Facebody::Model;
BlurFaceResult::BlurFaceResult() :
ServiceResult()
{}
BlurFaceResult::BlurFaceResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
BlurFaceResult::~BlurFaceResult()
{}
void BlurFaceResult::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();
}
BlurFaceResult::Data BlurFaceResult::getData()const
{
return data_;
}

View File

@@ -0,0 +1,89 @@
/*
* 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/facebody/model/DetectIPCPedestrianRequest.h>
using AlibabaCloud::Facebody::Model::DetectIPCPedestrianRequest;
DetectIPCPedestrianRequest::DetectIPCPedestrianRequest() :
RpcServiceRequest("facebody", "2019-12-30", "DetectIPCPedestrian")
{
setMethod(HttpRequest::Method::Post);
}
DetectIPCPedestrianRequest::~DetectIPCPedestrianRequest()
{}
std::string DetectIPCPedestrianRequest::getImageData()const
{
return imageData_;
}
void DetectIPCPedestrianRequest::setImageData(const std::string& imageData)
{
imageData_ = imageData;
setBodyParameter("ImageData", imageData);
}
std::vector<DetectIPCPedestrianRequest::URLList> DetectIPCPedestrianRequest::getURLList()const
{
return uRLList_;
}
void DetectIPCPedestrianRequest::setURLList(const std::vector<URLList>& uRLList)
{
uRLList_ = uRLList;
for(int dep1 = 0; dep1!= uRLList.size(); dep1++) {
auto uRLListObj = uRLList.at(dep1);
std::string uRLListObjStr = "URLList." + std::to_string(dep1 + 1);
setParameter(uRLListObjStr + ".DataId", uRLListObj.dataId);
setParameter(uRLListObjStr + ".ImageURL", uRLListObj.imageURL);
}
}
bool DetectIPCPedestrianRequest::getContinueOnError()const
{
return continueOnError_;
}
void DetectIPCPedestrianRequest::setContinueOnError(bool continueOnError)
{
continueOnError_ = continueOnError;
setBodyParameter("ContinueOnError", continueOnError ? "true" : "false");
}
int DetectIPCPedestrianRequest::getWidth()const
{
return width_;
}
void DetectIPCPedestrianRequest::setWidth(int width)
{
width_ = width;
setBodyParameter("Width", std::to_string(width));
}
int DetectIPCPedestrianRequest::getHeight()const
{
return height_;
}
void DetectIPCPedestrianRequest::setHeight(int height)
{
height_ = height;
setBodyParameter("Height", std::to_string(height));
}

View File

@@ -0,0 +1,73 @@
/*
* 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/facebody/model/DetectIPCPedestrianResult.h>
#include <json/json.h>
using namespace AlibabaCloud::Facebody;
using namespace AlibabaCloud::Facebody::Model;
DetectIPCPedestrianResult::DetectIPCPedestrianResult() :
ServiceResult()
{}
DetectIPCPedestrianResult::DetectIPCPedestrianResult(const std::string &payload) :
ServiceResult()
{
parse(payload);
}
DetectIPCPedestrianResult::~DetectIPCPedestrianResult()
{}
void DetectIPCPedestrianResult::parse(const std::string &payload)
{
Json::Reader reader;
Json::Value value;
reader.parse(payload, value);
setRequestId(value["RequestId"].asString());
auto dataNode = value["Data"];
auto allImageInfoListNode = dataNode["ImageInfoList"]["ImageInfoListItem"];
for (auto dataNodeImageInfoListImageInfoListItem : allImageInfoListNode)
{
Data::ImageInfoListItem imageInfoListItemObject;
if(!dataNodeImageInfoListImageInfoListItem["ErrorCode"].isNull())
imageInfoListItemObject.errorCode = dataNodeImageInfoListImageInfoListItem["ErrorCode"].asString();
if(!dataNodeImageInfoListImageInfoListItem["ErrorMessage"].isNull())
imageInfoListItemObject.errorMessage = dataNodeImageInfoListImageInfoListItem["ErrorMessage"].asString();
if(!dataNodeImageInfoListImageInfoListItem["DataId"].isNull())
imageInfoListItemObject.dataId = dataNodeImageInfoListImageInfoListItem["DataId"].asString();
auto allElementsNode = allImageInfoListNode["Elements"]["Element"];
for (auto allImageInfoListNodeElementsElement : allElementsNode)
{
Data::ImageInfoListItem::Element elementsObject;
if(!allImageInfoListNodeElementsElement["Score"].isNull())
elementsObject.score = std::stof(allImageInfoListNodeElementsElement["Score"].asString());
auto allBoxes = value["Boxes"]["Box"];
for (auto value : allBoxes)
elementsObject.boxes.push_back(value.asString());
imageInfoListItemObject.elements.push_back(elementsObject);
}
data_.imageInfoList.push_back(imageInfoListItemObject);
}
}
DetectIPCPedestrianResult::Data DetectIPCPedestrianResult::getData()const
{
return data_;
}