1

I have recently started using OpenCV 2.4.10 with VS2013. My program involves displaying a few images using imshow() along with outputting some values in the console window using cout. I have used getchar() before returning from the main function. This allows me to see the program output before the program exits.

Once the program exits, all the windows are closed. Is it possible to keep the windows open even after the program exits?

I found a related post but the answers are for the debugging phase and not after the program exits. As suggested by other answers to that post, my Properties>Configuration Properties> Linker> System>SubSystem is already set to console. Another post suggests using ctrl+F5 instead of F5. That keeps the program output window open but the windows showing images close down.

I looked through the OpenCV documentation on User Interface related functions but couldn't find my answer as well.

Community
  • 1
  • 1
Ruchir
  • 845
  • 2
  • 10
  • 24

1 Answers1

1

I don't think you can. After the program ends, it will close also the windows of your images.

If you need to view the images after program end, you could simply save (using imwrite) the images and see them in your preferred image viewer.

If you need to check pixel values, type of matrix and other useful stuff, you should install Image Watch extension in Visual Studio. Note that also this will close when program ends.

Miki
  • 40,887
  • 13
  • 123
  • 202
  • Thanks @Miki for the answer. The images just show outputs of the intermediate stages. I would have used imwrite but that would save many images which I won't need after debugging. Later I'll have to delete them manually. ImageWatch sounds great but it is not supported with VS2013 express edition which I'm using. I'll have to switch to community edition in order to use it. If there is no option, I'll have to make a switch. Thanks again :) – Ruchir Jul 06 '15 at 09:04
  • 1
    Usually I create a folder that contains my intermediate results. You can clear its content when your program starts using pre-build events, or just ctrl+a, canc :D – Miki Jul 06 '15 at 09:11
  • That's a good idea which did not strike to me. I'm from Matlab background where windows don't close automatically. – Ruchir Jul 06 '15 at 09:17
  • Thanks @Miki for telling about Image Watch. Now I've installed the community version of VS2013 and can use Image Watch. It's really helpful for debugging :) – Ruchir Jul 16 '15 at 01:57