/*-----------------opencv Mat的使用方法-------------------------*/
/*-----------------coding by wyz 2017-8-10----------------------*/
#include "cv.h"
#include "highgui.h"
#include <opencv2/opencv.hpp>
#include "windows.h"
#include <opencv2/core/core.hpp>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include<iostream>
using namespace std;
using namespace cv;
int main(){
//cv::FileStorage fs("test.yml",FileStorage::WRITE);
//int imageWidth=5;
//int imageHeight=10;
fs<<"imageWidth"<<imageWidth;
fs<<"imageHeight"<<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"<<m1;
//fs<<"m2"<<m2;
//
//fs<<"wyz"<<resultMat;
//Mat cameraMatrix=(Mat_<int>(3,3)<<1000,0,320,0,1000,240,0,0,1);
//Mat distCoeffs=(Mat_<float>(5,1)<<0.1,0.2,0.3,0.4,0.5);
//fs<<"cameraMatrix"<<cameraMatrix<<"distCoeffs"<<distCoeffs;
//time_t rawtime;
//time(&rawtime);
//fs<<"time"<<asctime(localtime(&rawtime));
//fs.release();
//system("pause");
//bool FileStorage::open(const s)
/*
cv::FileStorage fs;
fs.open("test.yml",FileStorage::WRITE);
bool flag=fs.isOpened();
cout<<"flag="<<flag<<endl;
//if failed to open a file
if(!fs.isOpened()){
cout<<"faied to open file test.yml"<<endl;
}
int firstNode =fs.getFirstTopLevelNode();
cout<<"Node"<<firstNode<<endl;
*/
cv::FileStorage fs("test.yml", FileStorage::READ);
int width;
int height;
fs["imageWidth"]>>width;
fs["imageHeight"]>>height;
cout<<"width readed = "<<width<<endl;
cout<<"height readed = "<<height<<endl<<endl;
// read Mat
cv::Mat resultMatRead;
fs["resultMat"]>>resultMatRead;
cout<<"resultMat readed = "<<resultMatRead<<endl<<endl;
cv::Mat cameraMatrixRead,distCoeffsRead;
fs["cameraMatrix"]>>cameraMatrixRead;
fs["distCoeffs"]>>distCoeffsRead;
cout<<"cameraMatrix readed = "<<cameraMatrixRead<<endl;
cout<<"distCoeffs readed = "<<distCoeffsRead<<endl<<endl;
// read string
string timeRead;
fs["calibrationDate"]>>timeRead;
cout<<"calibrationDate readed = "<<timeRead<<endl<<endl;
fs.release();
//fs.release();
system("pause");
return 0;
}