Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV imshow() does not work

I have written an openCV code and my code has following statement:

cv::imshow("Matches", matchesImg);
cv::waitKey(0);

When I run the code either in Debug or Release I am not able to see window which shows me the output.

And this is happening for every project I create.

Not able to figure out the reason, Can someone please guide me on this?

I am coding on Windows 7 and Visual studio 2010, with opencv version of 2.4.6

like image 386
Armin Mustafa Avatar asked Oct 24 '13 11:10

Armin Mustafa


People also ask

Why is OpenCV not working?

You can try the following: Download and install the latest version of python. Restart your terminal. Create a new virtualEnv and install dependencies, check the script below.

What is cv2 Imshow ()?

cv2. imshow() method is used to display an image in a window. The window automatically fits to the image size. Syntax: cv2.imshow(window_name, image)

Is cv2 waitKey necessary?

4. cv2. waitKey() This function is very important, without this function cv2.


1 Answers

As I mentioned in the comments, you have to create a window first, using namedWindow with the same window name as in imshow See this tutorial for details.

EDIT

This strongly suggest that you have to create the window beforehand. Some may argue that it didn't work this way for previous versions of OpenCV. Then, let's say this solution apply at least to OpenCV 2.4.6, which is the version of concern here (and it solved the problem).

like image 126
CTZStef Avatar answered Sep 20 '22 10:09

CTZStef