[Qt-interest] Cannot call OpenCV 2.0 functions inside Qt slots
Andres Sanin
asanin at gmail.com
Thu Feb 18 19:10:09 CET 2010
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?
Thanks in advance,
Andres
More information about the Qt-interest-old
mailing list