这个opencv程序用于同时从一个文件夹中加载不同的图像,但它只读取一个图像
This opencv program is for loading different images from a folder at the same time, but it reads only one image
这个OpenCV程序用于同时从文件夹中加载不同的图像。但它只读取一张图像,请帮助我找到这里发生的事情。
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include<cv.h>
#include<highgui.h>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
struct dirent *dirpent;
DIR *dirp;
IplImage* image;
if(argc!=2)
{
printf("Cant continue with the programn");
return 0;
}
dirp= opendir(argv[1]);
if(dirp==NULL)
{
cout<<"error"<<endl;
}
while(dirpent=readdir(dirp))
{
char *b=dirpent->d_name;
if(b[0]=='.')
{
}
else
{
image=(IplImage*)cvLoadImage(dirpent->d_name);
cvNamedWindow("output");
cvShowImage("output",image);
cvWaitKey(0);
cvReleaseImage(&image);
cvDestroyWindow("output");
}
}
closedir(dirp);
return 0;
}
尝试将
以下行移出(之后)while
-scope:
cvReleaseImage(&image);
cvDestroyWindow("output");
并将以下行移动到 while
-scope 之前,因为您不需要每次都创建窗口。
cvNamedWindow("output");
相关文章:
- 重新定位图像时如何前进到下一个内存块
- 如何在 OpenCV 中将图像与另一个图像相关联
- 是否可以通过每次在内存中仅保存一个平铺来处理完整的平铺 tiff 图像?
- 计算另一个图像像素满足条件的像素值的平均值
- 由于alpha值的原因,将一个图像混合到另一个图像会产生不正确的图像
- 访问和更改基于另一个图像的像素颜色-opencv c++
- 如何在打开另一个图像时关闭图像 - linux c ++
- Opencv,在图像中的对象周围绘制一个框
- 在 allegro5 中的另一个图像上的图像 (C++)
- Vuforia -- 如何在识别图像时仅播放一个视频
- OPENCV C .在for循环中在不同的图像像素上绘制一个圆圈(应在每个循环运行时将图像打开)
- SFML 将图像从 txt 文件加载到矢量中仅加载最后一个图像
- Houghlinesp生成一个空图像
- 处理一个大图像文本文件
- sfml pollevent,每个新图像都会删除上一个图像
- 尝试在另一个 SDL2 上显示一个图像没有错误,但不会显示第二个图像
- 如何使用CIMG.H库在另一个图像上显示一个图像
- 如何在C 和QT中的另一个窗口中显示MainWindow的结果图像
- 将图像从 C++ 传递给 Haskell 并取回一个字符串
- 如何从打开的简历中的图像访问第一个 5*5 块