views:

439

answers:

1

Hi all,

I have a Qt application that uses OpenCV for image processing.

Everything was working fine with OpenCV 1.0 but when I upgraded to OpenCV 2.0 it started crashing. I noticed that it only crashes whenever OpenCV functions are called inside Qt slots.

For instance, the following slot:

void TestClass::on_testButton_clicked() {
   IplImage* src = cvLoadImage("test.jpg");
   IplImage* dst = cvCreateImage(cvGetSize(src), src->depth, src->nChannels);
   cvThreshold(src, dst, 100, 255, CV_THRESH_BINARY);
}

crashes when testButton is clicked.

However, if I call the same cvThreshold function in any other place, such as inside the main() function or inside the Widget constructor, it works fine. Also, if I put the same code in a separate function and call that function with QtConcurrent::run() inside the same slot, it works fine too.

Why this behaviour? Are there any restrictions about the operations that can be done inside Qt slots? Which changes in OpenCV 2.0 functions may be causing the conflict?

Thanks in advance

A: 

Never mind, I was using OpenCV's precompiled libraries, which were created with a different version of mingw.

I compiled the library with cmake+mingw and using the generated libraries solved the problem.

Andres