本片博客重点利用FileStorage 进行文件读写操作练习;
创建一个common.hpp文件,存放结构体
#ifndef common_hpp
#define common_hpp
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core/core.hpp>
typedef struct my_struct
{
int m_value;
CvPoint st_Point;
CvRect st_Rect;
}MY_STRUCT;
extern void write_my_struct(CvFileStorage * fs,const char * name,MY_STRUCT *ms);
extern void read_my_struct(CvFileStorage * fs,CvFileNode * ms_node,MY_STRUCT *ms);
创建main函数进行文件读写操作
#include <iostream>
#include "common.hpp"
using namespace std;
using namespace cv;
void write_my_struct(FileStorage fs,const char *name,my_struct *mt)
{
fs <<name<< "[";//结构数组开始的标志
fs<<"{:";//一个结构体开始的标志,yml才有:,xml自动忽略
fs<&