yaml写法的简单例子。将 $ ./ 1 2 3 4 5 命令的参数(代表图片地址)写入yaml中。

写yaml文件。

参考:[OpenCV] Samples 06: [ML] logistic regression 读xml文件。

    {
/*
* Jeff --> Load xml.
* transform to Mat.
* FileStorage.
*/
cout << "loading the dataset...";
// Step 1.
FileStorage f;
if(f.open(filename, FileStorage::READ))
{
// Step 2.
f["datamat"] >> data;
f["labelsmat"] >> labels;
f.release();
}
else
{
cerr << "file can not be opened: " << filename << endl;
return ;
}
// Step 3.
data.convertTo(data, CV_32F);
labels.convertTo(labels, CV_32F); cout << "read " << data.rows << " rows of data" << endl;
}

read xml

/*this creates a yaml or xml list of files from the command line args
*/ #include "opencv2/core/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <string>
#include <iostream> using std::string;
using std::cout;
using std::endl; using namespace cv; static void help(char** av)
{
cout << "\nThis creates a yaml or xml list of files from the command line args\n"
"usage:\n./" << av[0] << " imagelist.yaml *.png\n"
<< "Try using different extensions.(e.g. yaml yml xml xml.gz etc...)\n"
<< "This will serialize this list of images or whatever with opencv's FileStorage framework" << endl;
} int main(int ac, char** av)
{
cv::CommandLineParser parser(ac, av, "{help h||}{@output||}");
if (parser.has("help"))
{
help(av);
return 0;
}
string outputname = parser.get<string>("@output"); cout << "{yaml} outputname = " << outputname << endl; if (outputname.empty())
{
help(av);
return 1;
} Mat m = imread(outputname); //check if the output is an image - prevent overwrites!
if(!m.empty()){
std::cerr << "fail! Please specify an output file, don't want to overwrite you images!" << endl;
help(av);
return 1;
} //Jeff --> write into outputname.
FileStorage fs(outputname, FileStorage::WRITE);
fs << "images" << "[";
for(int i = 2; i < ac; i++){
//Jeff --> write by "<<", redirection to file stream.
fs << string(av[i]);
}
fs << "]";
return 0;
}

[OpenCV] Samples 10: imagelist_creator的更多相关文章

  1. [OpenCV] Samples 16: Decompose and Analyse RGB channels

    物体的颜色特征决定了灰度处理不是万能,对RGB分别处理具有相当的意义. #include <iostream> #include <stdio.h> #include &quo ...

  2. [OpenCV] Samples 06: [ML] logistic regression

    logistic regression,这个算法只能解决简单的线性二分类,在众多的机器学习分类算法中并不出众,但它能被改进为多分类,并换了另外一个名字softmax, 这可是深度学习中响当当的分类算法 ...

  3. [OpenCV] Samples 06: logistic regression

    logistic regression,这个算法只能解决简单的线性二分类,在众多的机器学习分类算法中并不出众,但它能被改进为多分类,并换了另外一个名字softmax, 这可是深度学习中响当当的分类算法 ...

  4. [OpenCV] Samples 13: opencv_version

    cv::CommandLineParser的使用. I suppose CommandLineParser::has("something") should be true whe ...

  5. [OpenCV] Samples 03: cout_mat

    操作Mat元素时:I.at<double>(1,1) = CV_PI; /* * * cvout_sample just demonstrates the serial out capab ...

  6. [OpenCV] Samples 01: drawing

    基本的几何图形,标注功能. commondLineParser的使用参见:http://blog.csdn.net/u010305560/article/details/8941365 #includ ...

  7. [OpenCV] Samples 01: Geometry - 几何图形

    前言 基本的几何图形,标注功能. commondLineParser的使用参见:http://blog.csdn.net/u010305560/article/details/8941365 #inc ...

  8. [OpenCV] Samples 03: kmeans

    注意Mat作为kmeans的参数的含义. 扩展:高维向量的聚类. 一.像素聚类 #include "opencv2/highgui.hpp" #include "open ...

  9. [OpenCV] Samples 15: Background Subtraction and Gaussian mixture models

    不错的草稿.但进一步处理是必然的,也是难点所在. Extended: 固定摄像头,采用Gaussian mixture models对背景建模. OpenCV 中实现了两个版本的高斯混合背景/前景分割 ...

随机推荐

  1. solr&lucene3.6.0源码解析(三)

    solr索引操作(包括新增 更新 删除 提交 合并等)相关UML图如下 从上面的类图我们可以发现,其中体现了工厂方法模式及责任链模式的运用 UpdateRequestProcessor相当于责任链模式 ...

  2. android开发中监控android软件网络请求的软件Charles使用入门

    1.下载并安状软件,官网在此: http://www.charlesproxy.com/ 2.前题条件,电脑和手机必须在同一网段 3.在Charles界面选择菜单 proxy->proxy se ...

  3. Windows下为MySQL做定时备份

    第一种:新建批处理文件 backup.dat,里面输入以下代码:  代码如下 复制代码 net stop mysqlxcopy "C:/Program Files/MySQL/MySQL S ...

  4. React 随笔二

    这周做的demo3和demo4.5 随记的小点. 1.js错误提示: Warning: Each child in an array or iterator should have a unique  ...

  5. [Cocoa设计模式] 动态创建

    Cocoa利用底层Objective-C运行时的很多特性,包括能够创建在应用程序编译时不存在的类的实例并在运行时动态加载和链接新类.诸如Ruby, Perl, Python之类的脚本语言就利用这种技术 ...

  6. Encrypt

    begin#BE37F2FB34350DCA6242ADC91F33FA9ABDB6F502F5CA07E3D0CE0C3FAF8799AB3F4622564487B3729F111D9E132A08 ...

  7. Restful.Data,现招募有为骚年,群号 338570336

    光阴似箭,日月如梭,套用小学作文惯用的一句开场白来开始重新开始我的博客园生涯吧. 8年的风霜雪雨,不断的击打着我内心的哀伤,可我依旧坚挺的屹立在这里,是因为技术是我一直坚持的梦想. 追寻着先辈和高人的 ...

  8. Oracle Enterprise Manager打不开的解决方法

    之前OEM一直可以打开,但今天上班发现打不开了,输入http://localhost:1158/em 提示该网页无法打开. 那么检查一下: cmd进命令行 C:\Documents and Setti ...

  9. 说说WeakReference弱引用

    WeakReference弱引用概述 http://www.cnblogs.com/xrq730/p/4836700.html,关于Java的四种引用状态具体请参看此文 Java里一个对象obj被创建 ...

  10. 《C#图解教程》读书笔记之一:C#和.NET框架

    本篇已收录至<C#图解教程>读书笔记目录贴,点击访问该目录可获取更多内容. 一.在.NET之前的编程世界 C#语言是在微软公司的.NET框架上开发程序而设计的,首先作者给大家纠正了一下C# ...