ExtractPedestrianFeatureAttributeResult.cc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/facebody/model/ExtractPedestrianFeatureAttributeResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Facebody;
  19. using namespace AlibabaCloud::Facebody::Model;
  20. ExtractPedestrianFeatureAttributeResult::ExtractPedestrianFeatureAttributeResult() :
  21. ServiceResult()
  22. {}
  23. ExtractPedestrianFeatureAttributeResult::ExtractPedestrianFeatureAttributeResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. ExtractPedestrianFeatureAttributeResult::~ExtractPedestrianFeatureAttributeResult()
  29. {}
  30. void ExtractPedestrianFeatureAttributeResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto dataNode = value["Data"];
  37. if(!dataNode["ObjType"].isNull())
  38. data_.objType = dataNode["ObjType"].asString();
  39. if(!dataNode["ObjTypeScore"].isNull())
  40. data_.objTypeScore = std::stof(dataNode["ObjTypeScore"].asString());
  41. if(!dataNode["Feature"].isNull())
  42. data_.feature = dataNode["Feature"].asString();
  43. if(!dataNode["QualityScore"].isNull())
  44. data_.qualityScore = std::stof(dataNode["QualityScore"].asString());
  45. if(!dataNode["UpperColor"].isNull())
  46. data_.upperColor = dataNode["UpperColor"].asString();
  47. if(!dataNode["UpperColorScore"].isNull())
  48. data_.upperColorScore = std::stof(dataNode["UpperColorScore"].asString());
  49. if(!dataNode["UpperType"].isNull())
  50. data_.upperType = dataNode["UpperType"].asString();
  51. if(!dataNode["UpperTypeScore"].isNull())
  52. data_.upperTypeScore = std::stof(dataNode["UpperTypeScore"].asString());
  53. if(!dataNode["LowerColor"].isNull())
  54. data_.lowerColor = dataNode["LowerColor"].asString();
  55. if(!dataNode["LowerColorScore"].isNull())
  56. data_.lowerColorScore = std::stof(dataNode["LowerColorScore"].asString());
  57. if(!dataNode["LowerType"].isNull())
  58. data_.lowerType = dataNode["LowerType"].asString();
  59. if(!dataNode["LowerTypeScore"].isNull())
  60. data_.lowerTypeScore = std::stof(dataNode["LowerTypeScore"].asString());
  61. if(!dataNode["Gender"].isNull())
  62. data_.gender = dataNode["Gender"].asString();
  63. if(!dataNode["GenderScore"].isNull())
  64. data_.genderScore = std::stof(dataNode["GenderScore"].asString());
  65. if(!dataNode["Hair"].isNull())
  66. data_.hair = dataNode["Hair"].asString();
  67. if(!dataNode["HairScore"].isNull())
  68. data_.hairScore = std::stof(dataNode["HairScore"].asString());
  69. if(!dataNode["Age"].isNull())
  70. data_.age = dataNode["Age"].asString();
  71. if(!dataNode["AgeScore"].isNull())
  72. data_.ageScore = std::stof(dataNode["AgeScore"].asString());
  73. auto allElementsNode = dataNode["Elements"]["Element"];
  74. for (auto dataNodeElementsElement : allElementsNode)
  75. {
  76. Data::Element elementObject;
  77. if(!dataNodeElementsElement["ObjType"].isNull())
  78. elementObject.objType = dataNodeElementsElement["ObjType"].asString();
  79. if(!dataNodeElementsElement["ObjTypeScore"].isNull())
  80. elementObject.objTypeScore = std::stof(dataNodeElementsElement["ObjTypeScore"].asString());
  81. if(!dataNodeElementsElement["Feature"].isNull())
  82. elementObject.feature = dataNodeElementsElement["Feature"].asString();
  83. if(!dataNodeElementsElement["QualityScore"].isNull())
  84. elementObject.qualityScore = std::stof(dataNodeElementsElement["QualityScore"].asString());
  85. if(!dataNodeElementsElement["UpperColor"].isNull())
  86. elementObject.upperColor = dataNodeElementsElement["UpperColor"].asString();
  87. if(!dataNodeElementsElement["UpperColorScore"].isNull())
  88. elementObject.upperColorScore = std::stof(dataNodeElementsElement["UpperColorScore"].asString());
  89. if(!dataNodeElementsElement["UpperType"].isNull())
  90. elementObject.upperType = dataNodeElementsElement["UpperType"].asString();
  91. if(!dataNodeElementsElement["UpperTypeScore"].isNull())
  92. elementObject.upperTypeScore = std::stof(dataNodeElementsElement["UpperTypeScore"].asString());
  93. if(!dataNodeElementsElement["LowerColor"].isNull())
  94. elementObject.lowerColor = dataNodeElementsElement["LowerColor"].asString();
  95. if(!dataNodeElementsElement["LowerColorScore"].isNull())
  96. elementObject.lowerColorScore = std::stof(dataNodeElementsElement["LowerColorScore"].asString());
  97. if(!dataNodeElementsElement["LowerType"].isNull())
  98. elementObject.lowerType = dataNodeElementsElement["LowerType"].asString();
  99. if(!dataNodeElementsElement["LowerTypeScore"].isNull())
  100. elementObject.lowerTypeScore = std::stof(dataNodeElementsElement["LowerTypeScore"].asString());
  101. if(!dataNodeElementsElement["Gender"].isNull())
  102. elementObject.gender = dataNodeElementsElement["Gender"].asString();
  103. if(!dataNodeElementsElement["GenderScore"].isNull())
  104. elementObject.genderScore = std::stof(dataNodeElementsElement["GenderScore"].asString());
  105. if(!dataNodeElementsElement["Hair"].isNull())
  106. elementObject.hair = dataNodeElementsElement["Hair"].asString();
  107. if(!dataNodeElementsElement["HairScore"].isNull())
  108. elementObject.hairScore = std::stof(dataNodeElementsElement["HairScore"].asString());
  109. if(!dataNodeElementsElement["Age"].isNull())
  110. elementObject.age = dataNodeElementsElement["Age"].asString();
  111. if(!dataNodeElementsElement["AgeScore"].isNull())
  112. elementObject.ageScore = std::stof(dataNodeElementsElement["AgeScore"].asString());
  113. data_.elements.push_back(elementObject);
  114. }
  115. }
  116. ExtractPedestrianFeatureAttributeResult::Data ExtractPedestrianFeatureAttributeResult::getData()const
  117. {
  118. return data_;
  119. }