jsoncpp读取修改json文件

这个程序演示了如何使用jsoncpp库读取和修改JSON文件。它首先打开并解析一个名为'alphapose-results.json'的文件,提取其中的图像ID、类别ID、关键点坐标和分数。然后,根据用户输入,更新每个对象的'isStand'字段,并将结果写入新的JSON文件'1.json'。同时,程序还利用OpenCV在图像上显示关键点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include <memory>
#include <fstream>
#include <string>
#include <opencv2\opencv.hpp>
#include <opencv2\highgui\highgui.hpp>


#include <json/json.h>

using namespace std;
using namespace cv;
struct point3d
{
    double x;
    double y;
    double z;
};
void readfile();

int main() {
    readfile();
    return 0;
}

void readfile()
{
    Json::CharReaderBuilder rbuilder;
    rbuilder["collectComments"] = false;
    Json::Value root;
    JSONCPP_STRING errs;

    ifstream f;
    f.open("alphapose-results.json", ios::in);
    if (!f.is_open()){
        cout << "Open json file error!" << endl;
    }

    bool parse_ok = Json::parseFromStream(rbuilder, f, &root, &errs);
    f.close();
    if (!parse_ok) {
        cout << "Parse json file error!" << endl;
    }
    else{
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值