Release RecognizeFood.
This commit is contained in:
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