需要使用开源软件:
https://github.com/nlohmann/json
只需要包含头文件json.hpp就行了。
#include <string>
#include "json.hpp"
void ReadKeypointDatabase()
{
using json = nlohmann::json;
std::ifstream ifile("F:\\DataBase\\ai_challenger\\keypoint\\ai_challenger_keypoint_validation_20170911\\keypoint_validation_annotations_20170911.json");
json DBjson;
ifile >> DBjson;
ifile.close();
int samplenum0 = 0;
int samplenum1 = 0;
int imgempty = 0;
int unvisual = 0;
for (auto& element : DBjson) {
//std::cout << element << '\n';
std::string image_id = element["image_id"];
std::string image_path = "F:\\DataBase\\ai_challenger\\keypoint\\ai_challenger_keypoint_validation_20170911\\keypoint_validation_images_20170911\\" + image_id + ".jpg";
cv::Mat img = imread(image_path.c_str());
if (img.empty())
{