opencv中对FileStorage的几个设置XML

XML:
FileStorage::WRITE,覆盖写)
追加(FileStorage::APPEND,追加写)
读取(FileStorage::READ)

向filestorage中写入数据

// 1.create our writter
    cv::FileStorage fs("test.yml", FileStorage::WRITE);

    // 2.Save an int
    int imageWidth= 5;
    int imageHeight= 10;
    fs << "imageWidth" << imageWidth;
    fs << "imageHeight" << imageHeight;

    // 3.Write a Mat
    cv::Mat m1= Mat::eye(3,3, CV_8U);
    cv::Mat m2= Mat::ones(3,3, CV_8U);
    cv::Mat resultMat= (m1+1).mul(m1+2);
    fs << "resultMat" << resultMat;

    // 4.Write multi-variables 
    cv::Mat cameraMatrix = (Mat_<double>(3,3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1);
    cv::Mat distCoeffs = (Mat_<double>(5,1) << 0.1, 0.01, -0.001, 0, 0);
    fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs;

    // 5.Save local time
    time_t rawtime; time(&rawtime); //#include <time.h>
    fs << "calibrationDate" << asctime(localtime(&rawtime));

    // 6.close the file opened
    fs.release();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值