问题:OpenCV的imshow无法正常显示图片
解决方法:在imshow()语句下一句添加waitKey(30)
int main()
{
inputImg = imread("input.bmp");
imshow("input image", inputImg);//显示原图
//waitKey(30);
imgSplit(inputImg);//求取M(x)
imgBlur(mImg);//均值滤波
imgAvg(mImg);//求M(x)中所有元素均值
imgL(blurImg, mImg);//求L(x)
imgMaxInput(inputImg);//求maxImg
A = imgA(imgMaxpx(blurImg), imgMaxpx(maxImg));//求A
imgDefogged(inputImg);//去雾
imshow("defoggedImg", defoggedImg);//显示去雾后的图
imwrite("defoggedImg.bmp", defoggedImg);
//waitKey(0);
system("pause");
return 0;
}
#include<opencv2/opencv.hpp>
#include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv/cv.h>
using namespace std;
using namespace cv;
int main()
{
inputImg = imread("input.bmp");
imshow("input image", inputImg);//显示原图
waitKey(30);
imgSplit(inputImg);//求取M(x)
imgBlur(mImg);//均值滤波
imgAvg(mImg);//求M(x)中所有元素均值
imgL(blurImg, mImg);//求L(x)
imgMaxInput(inputImg);//求maxImg
A = imgA(imgMaxpx(blurImg), imgMaxpx(maxImg));//求A
imgDefogged(inputImg);//去雾
imshow("defoggedImg", defoggedImg);//显示去雾后的图
imwrite("defoggedImg.bmp", defoggedImg);
waitKey(0);
system("pause");
return 0;
}

本文解决了一个在使用OpenCV库显示图片时遇到的常见问题:imshow()函数无法正常显示图片。通过在imshow()函数后添加waitKey(30),可以确保图像正确显示并解决相关问题。
870

被折叠的 条评论
为什么被折叠?



