生物特征 高性能服务 智能交互分享 http://blog.sciencenet.cn/u/bluewind23 带着鲜刺的玫瑰刺得血如雨下一如既往前行!

博文

OpenCV Write XML File of Facial Feature

已有 7399 次阅读 2009-8-21 10:54 |个人分类:学习研究|系统分类:科研笔记| OpenCV, 人脸特征

void my_opencv_xml_write(void)
{
 char pID[] = "0001";
 int featureCount = 10;
 // 具体数据
 int _record[]={30000,4200,50090};
 //创建文件存储对象
 CvFileStorage *fs=cvOpenFileStorage("test.xml",0,CV_STORAGE_WRITE);
 
 // 写注释
 cvWriteComment(fs,"Person Feature Analysis NO.0001",1);
 // 开始写结构,类型是图map,也就是有名字的无序节点集合
 cvStartWriteStruct(fs, "Person", CV_NODE_MAP, pID , cvAttrList(NULL,NULL));
 {
  //1
  cvWriteComment(fs,"Face Feature NO.001",1);
  // 开始写结构,类型是图map,也就是有名字的无序节点集合
  cvStartWriteStruct(fs, "Face_Feature", CV_NODE_MAP, "001", cvAttrList(NULL,NULL));
  {
   //注释Properties
   cvWriteComment(fs,"MAPTYPE Properties",1);
   // 开始写结构,类型是图map,也就是有名字的无序节点集合
   cvStartWriteStruct(fs, "Properties", CV_NODE_MAP, NULL, cvAttrList(NULL,NULL));
   // 注释
   cvWriteComment(fs,"MAPType, name, age",0);
   // 姓名
   cvWriteString(fs,"name","liuyue", 0);
   // 年龄
   cvWriteInt(fs,"age",18); 
   // 特征值
   cvWriteInt(fs,"feature_count",featureCount);
   // 结束Properties
   cvEndWriteStruct(fs);
  }
  {
   // 注释Feature
   cvWriteComment(fs,"SEQType Feature",1);
   // 开始写结构,类型是序列sequence,无名字的有序节点集合
   cvStartWriteStruct(fs,"Feature",CV_NODE_SEQ, NULL, cvAttrList(NULL,NULL));
   // 前3条记录
   cvWriteRawData(fs,_record,3,"i");
   // 第4条记录,注意无名字
   cvWriteInt(fs,0,6100);
   // 结束Feature
   cvEndWriteStruct(fs);
  }
  // 结束1
  cvEndWriteStruct(fs);
    }
 {
  //2
  cvWriteComment(fs,"Face Feature NO.002",1);
  // 开始写结构,类型是图map,也就是有名字的无序节点集合
  cvStartWriteStruct(fs, "Face_Feature", CV_NODE_MAP, "002", cvAttrList(NULL,NULL));
  {
   //注释Properties
   cvWriteComment(fs,"MAPTYPE Properties",1);
   // 开始写结构,类型是图map,也就是有名字的无序节点集合
   cvStartWriteStruct(fs, "Properties", CV_NODE_MAP, NULL, cvAttrList(NULL,NULL));
   // 注释
   cvWriteComment(fs,"MAPType, name, age",0);
   // 姓名
   cvWriteString(fs,"name","liuyue", 0);
   // 年龄
   cvWriteInt(fs,"age",18);
   
   // 特征值
   cvWriteInt(fs,"feature_count",featureCount);
   // 结束Properties
   cvEndWriteStruct(fs);
  }
  {
   // 注释Feature
   cvWriteComment(fs,"SEQType Feature",1);
   // 开始写结构,类型是序列sequence,无名字的有序节点集合
   cvStartWriteStruct(fs,"Feature",CV_NODE_SEQ, NULL, cvAttrList(NULL,NULL));
   // 前3条记录
   cvWriteRawData(fs,_record,3,"i");
   // 第4条记录,注意无名字
   cvWriteInt(fs,0,6100);
   // 结束Feature
   cvEndWriteStruct(fs);
  }
  // 结束2
  cvEndWriteStruct(fs);
 }

 // 结束
 cvEndWriteStruct(fs);
 // 释放文件存储对象
 cvReleaseFileStorage(&fs);
}



https://blog.sciencenet.cn/blog-297739-250653.html


下一篇:OpenCV Capture Camera
收藏 IP: .*| 热度|

0

发表评论 评论 (1 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-12-23 22:49

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部