Ask Your Question
0

imshow namedWindow crash

asked 2013-07-12 08:32:30 -0600

el_gato_de_ch gravatar image

updated 2013-07-12 15:41:23 -0600

Kirill Kornyakov gravatar image

Hey.

I downloaded opencv 2.4.6 archive and extract it. Decided to use standart build from build/x86/mingw/lib. I had no compilation errors, but when I run my programm it's crashed on cv::namedWindow() or cv::imshow() functions.

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

#include <iostream>

using namespace std;

int main()
{
cv::Mat pic = cv::imread("1.jpg");
//cv::namedWindow("Smile", CV_WINDOW_NORMAL);
cv::imshow("Smile", pic);
cv::imwrite("2.jpg", pic);
cout << pic.rows << endl;

char ch;

cin >> ch;
cv::destroyWindow("Smile");
return 0;
}

I searched this problem in internet and found this solution. Then I tried to disable all checkboxes ENABLE_SSE in cmake, but it didn't work, programm is still crashing on imshow()

Could you, please, give me cmake properties for build opencv with mingw compiler. I use just mingw compiler without any IDE, but my friend uses QT, so I need to build this libraries with qt support, I also need this bug, with crashing on namedWindow calling, is fixed. I've got WIN7 32 on my computer.

I do built this way:

  • configuring and generating cmake
  • run terminal in the directory of cmake binary
  • mingw32-make
  • mingw32-make install

I hope you will help. Thanks a lot.

edit retag flag offensive close merge delete

Comments

2

Do you get any kind of error message when your program crashes, or does it just exit completely? Also, it is not clear from your description; if you uncomment the namedWindow line, does your program crash on the namedWindow function or the imshow function?

Calden gravatar imageCalden ( 2013-07-12 09:43:47 -0600 )edit

yes, error msg please.

and, did you check the WITH_QT box ?

man, that ticket is 3 years old ... the current issues are here

berak gravatar imageberak ( 2013-07-12 10:08:14 -0600 )edit

I got no errors in terminal, just only gray window with no image inside. You know just a hang up window and when you want to close it windows pops up a message with buttons "close" "wait for response" ...

May be somehow I can post an screenshot to explain what I mean, but it will be russian language.

el_gato_de_ch gravatar imageel_gato_de_ch ( 2013-07-13 02:42:18 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2013-07-13 11:26:15 -0600

Vladislav Vinogradov gravatar image

You forgot to call waitKey function. This function fetchs and handles window events, such as repaint event, so it must be called. Also check that your image was loaded properly:

cv::Mat pic = cv::imread("1.jpg");
if (pic.empty())
{
    cout << "can't load image" << endl;
    return -1;
}
cv::imshow("Smile", pic);
cv::waitKey();
edit flag offensive delete link more

Comments

I love you man! You are my hero! It is realy working, Thanks a lot.

el_gato_de_ch gravatar imageel_gato_de_ch ( 2013-07-13 23:27:17 -0600 )edit

Question Tools

Stats

Asked: 2013-07-12 08:32:30 -0600

Seen: 8,507 times

Last updated: Jul 13 '13