小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

OpenCV 2.4.3 Cheat Sheet學(xué)習(xí) 數(shù)據(jù)的輸入和輸出

 昵稱14216904 2016-02-24
// wenjianduxie.cpp : 定義控制臺應(yīng)用程序的入口點(diǎn)。
//

#include "stdafx.h"
#include "stdafx.h"
#include <opencv2/core/core.hpp>  
#include <opencv2/highgui/highgui.hpp>  
#include <iostream>  


using namespace cv;  
using namespace std;  

int main( int argc, char** argv )

{      //1.    將數(shù)據(jù)寫入YAML(或XML)
//注意,在OpenCV中,無論讀寫,文件的格式均由指定的后綴名確定。示例:
/*
FileStorage fs("test.yml", FileStorage::WRITE);
fs << "i" << 5 << "r" << 3.1 << "str" << "ABCDEFGH";
fs << "mtx" << Mat::eye(3,3,CV_32F);
fs << "mylist" << "[" << CV_PI << "1+1" << "{:" << "month" << 12 << "day" << 31 << "year" << 1969 << "}" << "]";
fs << "mystruct" << "{" << "x" << 1 << "y" << 2 << "width" << 100 << "height" << 200 << "lbp" << "[:";
const uchar arr[] = {0, 1, 1, 0, 1, 1, 0, 1};
fs.writeRaw("u", arr, (int)(sizeof(arr)/sizeof(arr[0])));
fs << "]" << "}";
*/

///*
//1.    將數(shù)據(jù)讀回 這段代碼把上面寫入文件的數(shù)據(jù)再讀回來。
FileStorage fs("test.yml", FileStorage::READ);
int i1 = (int)fs["i"];
double r1 = (double)fs["r"];
string str1 = (string)fs["str"];
Mat M;
fs["mtx"] >> M;
cout<<M<<endl;
FileNode tl = fs["mylist"];
CV_Assert(tl.type() == FileNode::SEQ && tl.size() == 3);
double tl0 = (double)tl[0];
string tl1 = (string)tl[1];
int m = (int)tl[2]["month"], d = (int)tl[2]["day"];
int year = (int)tl[2]["year"];
FileNode tm = fs["mystruct"];
Rect r;
r.x = (int)tm["x"], r.y = (int)tm["y"];
r.width = (int)tm["width"], r.height = (int)tm["height"];
int lbp_val = 0;
FileNodeIterator it = tm["lbp"].begin();
for(int k = 0; k < 8; k++, ++it)
  lbp_val |= ((int)*it) << k;
  //*/

cvWaitKey(0);  

return 0;  
}

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多