Release RecognizeFood.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
2021-02-01 Version: patch
|
||||
- Release RecognizeFood.
|
||||
|
||||
2021-02-01 Version: patch
|
||||
- Release UnderstandVideoContent.
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ set(imagerecog_public_header_model
|
||||
include/alibabacloud/imagerecog/model/DetectImageElementsResult.h
|
||||
include/alibabacloud/imagerecog/model/EvaluateCertificateQualityRequest.h
|
||||
include/alibabacloud/imagerecog/model/EvaluateCertificateQualityResult.h
|
||||
include/alibabacloud/imagerecog/model/RecognizeFoodRequest.h
|
||||
include/alibabacloud/imagerecog/model/RecognizeFoodResult.h
|
||||
include/alibabacloud/imagerecog/model/RecognizeImageColorRequest.h
|
||||
include/alibabacloud/imagerecog/model/RecognizeImageColorResult.h
|
||||
include/alibabacloud/imagerecog/model/RecognizeImageStyleRequest.h
|
||||
@@ -52,6 +54,8 @@ set(imagerecog_src
|
||||
src/model/DetectImageElementsResult.cc
|
||||
src/model/EvaluateCertificateQualityRequest.cc
|
||||
src/model/EvaluateCertificateQualityResult.cc
|
||||
src/model/RecognizeFoodRequest.cc
|
||||
src/model/RecognizeFoodResult.cc
|
||||
src/model/RecognizeImageColorRequest.cc
|
||||
src/model/RecognizeImageColorResult.cc
|
||||
src/model/RecognizeImageStyleRequest.cc
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "model/DetectImageElementsResult.h"
|
||||
#include "model/EvaluateCertificateQualityRequest.h"
|
||||
#include "model/EvaluateCertificateQualityResult.h"
|
||||
#include "model/RecognizeFoodRequest.h"
|
||||
#include "model/RecognizeFoodResult.h"
|
||||
#include "model/RecognizeImageColorRequest.h"
|
||||
#include "model/RecognizeImageColorResult.h"
|
||||
#include "model/RecognizeImageStyleRequest.h"
|
||||
@@ -63,6 +65,9 @@ namespace AlibabaCloud
|
||||
typedef Outcome<Error, Model::EvaluateCertificateQualityResult> EvaluateCertificateQualityOutcome;
|
||||
typedef std::future<EvaluateCertificateQualityOutcome> EvaluateCertificateQualityOutcomeCallable;
|
||||
typedef std::function<void(const ImagerecogClient*, const Model::EvaluateCertificateQualityRequest&, const EvaluateCertificateQualityOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> EvaluateCertificateQualityAsyncHandler;
|
||||
typedef Outcome<Error, Model::RecognizeFoodResult> RecognizeFoodOutcome;
|
||||
typedef std::future<RecognizeFoodOutcome> RecognizeFoodOutcomeCallable;
|
||||
typedef std::function<void(const ImagerecogClient*, const Model::RecognizeFoodRequest&, const RecognizeFoodOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RecognizeFoodAsyncHandler;
|
||||
typedef Outcome<Error, Model::RecognizeImageColorResult> RecognizeImageColorOutcome;
|
||||
typedef std::future<RecognizeImageColorOutcome> RecognizeImageColorOutcomeCallable;
|
||||
typedef std::function<void(const ImagerecogClient*, const Model::RecognizeImageColorRequest&, const RecognizeImageColorOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RecognizeImageColorAsyncHandler;
|
||||
@@ -98,6 +103,9 @@ namespace AlibabaCloud
|
||||
EvaluateCertificateQualityOutcome evaluateCertificateQuality(const Model::EvaluateCertificateQualityRequest &request)const;
|
||||
void evaluateCertificateQualityAsync(const Model::EvaluateCertificateQualityRequest& request, const EvaluateCertificateQualityAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
EvaluateCertificateQualityOutcomeCallable evaluateCertificateQualityCallable(const Model::EvaluateCertificateQualityRequest& request) const;
|
||||
RecognizeFoodOutcome recognizeFood(const Model::RecognizeFoodRequest &request)const;
|
||||
void recognizeFoodAsync(const Model::RecognizeFoodRequest& request, const RecognizeFoodAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
RecognizeFoodOutcomeCallable recognizeFoodCallable(const Model::RecognizeFoodRequest& request) const;
|
||||
RecognizeImageColorOutcome recognizeImageColor(const Model::RecognizeImageColorRequest &request)const;
|
||||
void recognizeImageColorAsync(const Model::RecognizeImageColorRequest& request, const RecognizeImageColorAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
RecognizeImageColorOutcomeCallable recognizeImageColorCallable(const Model::RecognizeImageColorRequest& request) const;
|
||||
|
||||
@@ -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_IMAGERECOG_MODEL_RECOGNIZEFOODREQUEST_H_
|
||||
#define ALIBABACLOUD_IMAGERECOG_MODEL_RECOGNIZEFOODREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <alibabacloud/imagerecog/ImagerecogExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Imagerecog
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_IMAGERECOG_EXPORT RecognizeFoodRequest : public RpcServiceRequest
|
||||
{
|
||||
|
||||
public:
|
||||
RecognizeFoodRequest();
|
||||
~RecognizeFoodRequest();
|
||||
|
||||
std::string getImageURL()const;
|
||||
void setImageURL(const std::string& imageURL);
|
||||
|
||||
private:
|
||||
std::string imageURL_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_IMAGERECOG_MODEL_RECOGNIZEFOODREQUEST_H_
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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_RECOGNIZEFOODRESULT_H_
|
||||
#define ALIBABACLOUD_IMAGERECOG_MODEL_RECOGNIZEFOODRESULT_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <alibabacloud/core/ServiceResult.h>
|
||||
#include <alibabacloud/imagerecog/ImagerecogExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Imagerecog
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_IMAGERECOG_EXPORT RecognizeFoodResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
struct TopFivesItem
|
||||
{
|
||||
std::string calorie;
|
||||
float score;
|
||||
std::string category;
|
||||
};
|
||||
std::vector<TopFivesItem> topFives;
|
||||
};
|
||||
|
||||
|
||||
RecognizeFoodResult();
|
||||
explicit RecognizeFoodResult(const std::string &payload);
|
||||
~RecognizeFoodResult();
|
||||
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_RECOGNIZEFOODRESULT_H_
|
||||
@@ -195,6 +195,42 @@ ImagerecogClient::EvaluateCertificateQualityOutcomeCallable ImagerecogClient::ev
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
ImagerecogClient::RecognizeFoodOutcome ImagerecogClient::recognizeFood(const RecognizeFoodRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return RecognizeFoodOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return RecognizeFoodOutcome(RecognizeFoodResult(outcome.result()));
|
||||
else
|
||||
return RecognizeFoodOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void ImagerecogClient::recognizeFoodAsync(const RecognizeFoodRequest& request, const RecognizeFoodAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, recognizeFood(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
ImagerecogClient::RecognizeFoodOutcomeCallable ImagerecogClient::recognizeFoodCallable(const RecognizeFoodRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<RecognizeFoodOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->recognizeFood(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
ImagerecogClient::RecognizeImageColorOutcome ImagerecogClient::recognizeImageColor(const RecognizeImageColorRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
|
||||
40
imagerecog/src/model/RecognizeFoodRequest.cc
Normal file
40
imagerecog/src/model/RecognizeFoodRequest.cc
Normal 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/imagerecog/model/RecognizeFoodRequest.h>
|
||||
|
||||
using AlibabaCloud::Imagerecog::Model::RecognizeFoodRequest;
|
||||
|
||||
RecognizeFoodRequest::RecognizeFoodRequest() :
|
||||
RpcServiceRequest("imagerecog", "2019-09-30", "RecognizeFood")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
RecognizeFoodRequest::~RecognizeFoodRequest()
|
||||
{}
|
||||
|
||||
std::string RecognizeFoodRequest::getImageURL()const
|
||||
{
|
||||
return imageURL_;
|
||||
}
|
||||
|
||||
void RecognizeFoodRequest::setImageURL(const std::string& imageURL)
|
||||
{
|
||||
imageURL_ = imageURL;
|
||||
setBodyParameter("ImageURL", imageURL);
|
||||
}
|
||||
|
||||
76
imagerecog/src/model/RecognizeFoodResult.cc
Normal file
76
imagerecog/src/model/RecognizeFoodResult.cc
Normal file
@@ -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.
|
||||
*/
|
||||
|
||||
#include <alibabacloud/imagerecog/model/RecognizeFoodResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Imagerecog;
|
||||
using namespace AlibabaCloud::Imagerecog::Model;
|
||||
|
||||
RecognizeFoodResult::RecognizeFoodResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
RecognizeFoodResult::RecognizeFoodResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
RecognizeFoodResult::~RecognizeFoodResult()
|
||||
{}
|
||||
|
||||
void RecognizeFoodResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto dataNode = value["Data"];
|
||||
auto allTopFivesNode = dataNode["TopFives"]["TopFivesItem"];
|
||||
for (auto dataNodeTopFivesTopFivesItem : allTopFivesNode)
|
||||
{
|
||||
Data::TopFivesItem topFivesItemObject;
|
||||
if(!dataNodeTopFivesTopFivesItem["Calorie"].isNull())
|
||||
topFivesItemObject.calorie = dataNodeTopFivesTopFivesItem["Calorie"].asString();
|
||||
if(!dataNodeTopFivesTopFivesItem["Score"].isNull())
|
||||
topFivesItemObject.score = std::stof(dataNodeTopFivesTopFivesItem["Score"].asString());
|
||||
if(!dataNodeTopFivesTopFivesItem["Category"].isNull())
|
||||
topFivesItemObject.category = dataNodeTopFivesTopFivesItem["Category"].asString();
|
||||
data_.topFives.push_back(topFivesItemObject);
|
||||
}
|
||||
if(!value["Message"].isNull())
|
||||
message_ = value["Message"].asString();
|
||||
if(!value["Code"].isNull())
|
||||
code_ = value["Code"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string RecognizeFoodResult::getMessage()const
|
||||
{
|
||||
return message_;
|
||||
}
|
||||
|
||||
RecognizeFoodResult::Data RecognizeFoodResult::getData()const
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
std::string RecognizeFoodResult::getCode()const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user