opencv xml读写
来源:互联网 发布:大数据来源于 编辑:程序博客网 时间:2024/05/17 04:53
#include <opencv2/core/core.hpp>#include <iostream>#include <string>#include <time.h> using namespace cv;using namespace std;int main(int argc, char** argv) {if (0)//write{FileStorage fs("test.xml", FileStorage::WRITE); fs << "frameCount" << 5; time_t rawtime; time(&rawtime); fs << "calibrationDate" << asctime(localtime(&rawtime)); Mat cameraMatrix = (Mat_<double>(3,3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1); Mat distCoeffs = (Mat_<double>(5,1) << 0.1, 0.01, -0.001, 0, 0); fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs; fs << "features" << "["; for( int i = 0; i < 3; i++ ) { int x = rand() % 640; int y = rand() % 480; uchar lbp = rand() % 256; fs << "{:" << "x" << x << "y" << y << "lbp" << "[:"; for( int j = 0; j < 8; j++ ) fs << ((lbp >> j) & 1); fs << "]" << "}"; } fs << "]"; fs.release(); }else{FileStorage fs2("test.xml", FileStorage::READ);// first method: use (type) operator on FileNode.int frameCount = (int)fs2["frameCount"];std::string date;// second method: use FileNode::operator >>fs2["calibrationDate"] >> date;Mat cameraMatrix2, distCoeffs2;fs2["cameraMatrix"] >> cameraMatrix2;fs2["distCoeffs"] >> distCoeffs2;cout << "frameCount: " << frameCount << endl << "calibration date: " << date << endl << "camera matrix: " << cameraMatrix2 << endl << "distortion coeffs: " << distCoeffs2 << endl;FileNode features = fs2["features"];FileNodeIterator it = features.begin(), it_end = features.end();int idx = 0;std::vector<uchar> lbpval;// iterate through a sequence using FileNodeIteratorfor( ; it != it_end; ++it, idx++ ){cout << "feature #" << idx << ": ";cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp: (";// you can also easily read numerical arrays using FileNode >> std::vector operator.(*it)["lbp"] >> lbpval;for( int i = 0; i < (int)lbpval.size(); i++ )cout << " " << (int)lbpval[i];cout << ")" << endl;}fs2.release();}return 0; }
0 0
- opencv 读写xml文件
- OpenCv xml读写
- OpenCv的xml读写
- opencv学习-读写xml
- OpenCV 读写XML
- opencv xml读写
- opencv 读写XML YML
- opencv-读写xml
- opencv 操作XML,读写数组
- 【学习OpenCV】xml的读写
- opencv的XML文件读写
- opencv读写xml 、yml文件
- OpenCV学习——XML的读写
- OpenCV笔记(一)-XML文件读写
- OpenCV FileStorage类读写XML/YML文件
- OpenCV FileStorage类读写XML/YML文件
- opencv下XML 文件的读写
- OpenCV FileStorage类读写XML/YML文件
- android studio进行测试,单元测试
- Web_PHP_DedeCMS_自定义函数汇总;
- java单例模式案例
- iphone 配件通信
- hdu1074 doing homework
- opencv xml读写
- POJ 1503 Integer Inquiry
- 在线调试工具集锦
- android sdk---radioGroup用法实例
- Flex 添加效果的两种方法
- vnc 相关
- hdu 4366 Successor 线段树
- 发现一个grails中判断domain保存(save)不成功的方法
- hdoj.1163 Eddy's digital Roots 20140813