opencv Mat的使用方法



/*-----------------opencv Mat的使用方法-------------------------*/


/*-----------------coding by wyz 2017-8-10----------------------*/

#include "cv.h" 
#include "highgui.h"
#include
#include "windows.h"
#include
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include  
#include
#include
using namespace std;
using namespace cv;


int main(){

//cv::FileStorage fs("test.yml",FileStorage::WRITE);
//int imageWidth=5;
//int imageHeight=10;
////fs<<"imageWidth"< ////fs<<"imageHeight"< //cv::Mat m1=Mat::eye(3,3,CV_8U);
//cv::Mat m2=Mat::ones(3,3,CV_8U);
//cv::Mat resultMat=(m2).mul(m2+1);
//fs<<"m1"< //fs<<"m2"< //
//fs<<"wyz"<

//Mat cameraMatrix=(Mat_(3,3)<<1000,0,320,0,1000,240,0,0,1);
//Mat distCoeffs=(Mat_(5,1)<<0.1,0.2,0.3,0.4,0.5);
//fs<<"cameraMatrix"< //time_t rawtime;
//time(&rawtime);
//fs<<"time"< //fs.release();
//system("pause");



//bool FileStorage::open(const s)
/*
cv::FileStorage fs;
fs.open("test.yml",FileStorage::WRITE);
bool flag=fs.isOpened();
cout<<"flag="< //if failed to open a file 
if(!fs.isOpened()){
cout<<"faied to open file test.yml"< }
int firstNode =fs.getFirstTopLevelNode();
cout<<"Node"< */


cv::FileStorage fs("test.yml", FileStorage::READ);  
    int width;  
    int height;  
    fs["imageWidth"]>>width;  
    fs["imageHeight"]>>height;  
    cout<<"width readed = "<     cout<<"height readed = "<   
// read Mat  
    cv::Mat resultMatRead;  
    fs["resultMat"]>>resultMatRead;  
    cout<<"resultMat readed = "<       
    cv::Mat cameraMatrixRead,distCoeffsRead;  
    fs["cameraMatrix"]>>cameraMatrixRead;  
    fs["distCoeffs"]>>distCoeffsRead;  
    cout<<"cameraMatrix readed = "<     cout<<"distCoeffs readed = "<   
// read string  
    string timeRead;  
    fs["calibrationDate"]>>timeRead;  
    cout<<"calibrationDate readed = "<   
    fs.release();  
//fs.release();
system("pause");
return 0;
}

你可能感兴趣的:(opencv Mat的使用方法)