当前位置:网站首页>[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);
}
边栏推荐
- Pit resolution encountered using East OCR (compile LAMS)
- NLP pre training model-2018:bert dictionary
- UE4_UE5结合offline voice recognition插件做语音识别功能
- Huawei cloud SRE deterministic operation and maintenance special issue (the first issue)
- OBS-Studio-27.2.4-Full-Installer-x64.exe 下载
- Multithreaded learning 2- call control
- OpenJudge NOI 2.1 15:Counterfeit Dollar
- UE4_UE5結合offline voice recognition插件做語音識別功能
- ES6-Const常量与数组解构
- Actual combat: how to quickly change font color in typera (blog sharing - perfect) -2022.6.25 (solved)
猜你喜欢

STM32开发板+机智云AIoT+家庭监测控制系统

小程序绘制一个简单的饼图

LM small programmable controller software (based on CoDeSys) note XVII: PTO pulse function block

为什么OpenCV计算的帧率是错误的?

What aspects should we start with in the feasibility analysis of dry goods?

Pycharm student's qualification expires, prompting no suitable licenses associated with account solution

Meta universe standard forum established

Fastjson deserialization randomness failed

ES6学习-- LET

Unity的Ping类使用
随机推荐
多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%...
Oracle - getting started
论文笔记: 多标签学习 MSWL
Unity technical manual - life cycle rotation rotationoverlifetime- speed rotation rotationbyspeed- and external forces
Exclusive or operator simple logic operation a^=b
电路模块分析练习5(电源)
为什么OpenCV计算的帧率是错误的?
Implementation of importing vscode from PDM
OBS-Studio-27.2.4-Full-Installer-x64.exe 下载
漏刻有时API接口实战开发系列(13):小鹅通云服务PHP-API二维数组传参解决方案
记一次beego通过go get命令后找不到bee.exe的坑
LM small programmable controller software (based on CoDeSys) note XVII: PTO pulse function block
剑指 Offer 46. 把数字翻译成字符串(DP)
Mysql database index
Baidu: in 2022, the top ten hot spots will rise and the profession will be released. There is no suspense about the first place!
Live800在线客服系统:跨越时空做生意,从每次互动开始
Flex & Bison Start
Multi modal data can also be Mae? Berkeley & Google proposed m3ae to conduct Mae on image and text data! The optimal masking rate can reach 75%, significantly higher than 15% of Bert
Technology blog site collection
ES6学习-- LET