当前位置:网站首页>[opencv450 samples] read the image path list and maintain the proportional display
[opencv450 samples] read the image path list and maintain the proportional display
2022-06-25 23:25:00 【Ten year dream Lab】
/*
* Created on: Nov 23, 2010
* Author: Ethan Rublee
*
* A starter sample for using opencv, load up an imagelist
* that was generated with imagelist_creator.cpp
* easy as CV_PI right?
*/
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
#include <vector>
using namespace cv;
using namespace std;
static void help(char** av)
{
cout << "\nThis program gets you started being able to read images from a list in a file\n"
"Usage:\n./" << av[0] << " image_list.yaml\n"
<< "\tThis is a starter sample, to get you up and going in a copy pasta fashion.\n"
<< "\tThe program reads in an list of images from a yaml or xml file and displays\n"
<< "one at a time\n"
<< "\tTry running imagelist_creator to generate a list of images.\n"
"Using OpenCV version %s\n" << CV_VERSION << "\n" << endl;
}
// Read path string list
static bool readStringList(const string& filename, vector<string>& l)
{
l.resize(0);// Resize container
FileStorage fs(filename, FileStorage::READ);// Read the file
if (!fs.isOpened())
return false;
FileNode n = fs.getFirstTopLevelNode();// Head node
if (n.type() != FileNode::SEQ)
return false;
FileNodeIterator it = n.begin(), it_end = n.end();// iterator
for (; it != it_end; ++it)
l.push_back((string)*it);// Join list
return true;
}
// Display all images in sequence
static int process(const vector<string>& images)
{
namedWindow("image", WINDOW_KEEPRATIO); // Maintain image scale resizable window;
for (size_t i = 0; i < images.size(); i++)
{
Mat image = imread(images[i], IMREAD_GRAYSCALE); // do grayscale processing?
imshow("image", image);
cout << "Press a key to see the next image in the list." << endl;
waitKey(); // wait infinitely for a key to be pressed
}
return 0;
}
int main(int ac, char** av)
{
cv::CommandLineParser parser(ac, av, "{help h||}{@input||}");
if (parser.has("help"))
{
help(av);
return 0;
}
std::string arg = parser.get<std::string>("@input");// file name
if (arg.empty())
{
help(av);
return 1;
}
vector<string> imagelist;// Image path list
if (!readStringList(arg, imagelist))// Read file path list
{
cerr << "Failed to read image list\n" << endl;
help(av);
return 1;
}
return process(imagelist);
}
边栏推荐
- ES6 learning -- let
- My C language learning process
- Unity technical manual - particle emission and life cycle velocity sub module
- 提问的智慧?如何提问?
- 等价类,边界值,场景法的使用方法和运用场景
- LM小型可编程控制器软件(基于CoDeSys)笔记十七:pto脉冲功能块
- App new function launch
- 2、一个向量乘它的转置,其几何意义是什么?
- Implementation of importing vscode from PDM
- UE4_ Ue5 combines the offline voice recognition plug-in for speech recognition
猜你喜欢
Live800在线客服系统:跨越时空做生意,从每次互动开始
Unity的Ping類使用
ES6 learning -- let
Civil Aviation Administration: by 2025, China will initially build a safe, intelligent, efficient and green aviation logistics system
论文笔记: 多标签学习 MSWL
多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%...
Ue4 Ue5 combine le plug - in de reconnaissance vocale de bureau pour la reconnaissance vocale
ACM. HJ16 购物单 ●●
干货丨产品的可行性分析要从哪几个方面入手?
The Ping class of unity uses
随机推荐
Live800在线客服系统:跨越时空做生意,从每次互动开始
百度:2022年十大热度攀升专业出炉,第一名无悬念!
2022年河南省第一届职业技能大赛网络安全项目试题
Day3 data types and operators summary and job
我的vscode
Why is BeanUtils not recommended?
记一次beego通过go get命令后找不到bee.exe的坑
NLP pre training model-2018:bert dictionary
ES6 - numerical extension and object extension
To solve the incompatibility between VM and device/credential guard, an effective solution for the whole network
Fastjson反序列化随机性失败
pdm的皮毛
信息学奥赛一本通 1353:表达式括号匹配(stack) | 洛谷 P1739 表达式括号匹配
Jupiter notebook common shortcut keys
多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%...
问题记录与思考
What is CDN acceleration
Somme logarithmique (deux points) pour le Groupe 52 - - e de la course de la lune blanche de niuke
No absurd tea applet - rule change
How to solve the problem of SQL?