简体   繁体   English

openCV中的imshow函数

[英]imshow function in openCV

I am using imshow function to display images in OpenCV. 我正在使用imshow函数在OpenCV中显示图像。 It works fine, there is just a little thing though: the title I write for the image is not correctly displayed. 它工作正常,但只有一点点:我为图像写的标题没有正确显示。

For example, when I write "Original" or "inverted" they are displayed with some extra and unintelligible data in the beginning. 例如,当我写“ Original”或“ inverted”时,它们在开始时会显示一些额外且难以理解的数据。 However, when I write "thresholded Image" a long line of unintelligible words is displayed instead of the title... 但是,当我写“阈值图像”时,会显示一长串难以理解的单词,而不是标题...

It does not effect anything else but it seems queer to me. 它没有任何其他影响,但是对我来说似乎很奇怪。 Do you have any idea why that happens? 你知道为什么会这样吗?

Here is my code: 这是我的代码:

IplImage* image=cvLoadImage("Black&White.jpg");
Mat image1;
image1=Mat(image,false);
imshow("Image",image1);
cvWaitKey(0);

First of all, you are using the C and C++ libraries interchangeably - IpIImage belongs to C and Mat belongs to C++, this could be the source of your problem. 首先,您可以互换地使用C和C ++库 - IpIImage属于C而Mat属于C ++,这可能是您问题的根源。 Instead, try just using the C++ interface and your code will be as follows : 相反,尝试使用C ++接口,您的代码如下:

Mat image = imread("Black&White.jpg"); 
imshow("Image",image);
waitKey(0);

That should fix your problem, if not, try using the C interface 这应该可以解决您的问题,如果没有,请尝试使用C接口

IplImage* image = cvLoadImage("Black&White.jpg");
cvNamedWindow( "Image", CV_WINDOW_AUTOSIZE );
cvShowImage("Image", image);
cvWaitKey(0);

Have you really checked that you used the proper link to the file? 你真的检查过你使用了正确的文件链接吗? In my case, I usually check it by doing: 就我而言,我通常会这样做:

image = imread( "C:\\\CloudStation\\\Bestanden\\\VisualStudio2010\\\Projects\\\TMerger\\\Debug\\\black_and_white.tif")

So in my case, I have to use a double backward slash. 因此,就我而言,我必须使用双反斜杠。

Hope it helps. 希望能帮助到你。

greetings, Floris. 问候,弗洛里斯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM