Hi all,
I have a Qt (4.6 mingw) application that uses OpenCV (2.0) 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);
}
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);
}
To copy to clipboard, switch view to plain text mode
crashes when testButton is clicked.
However:
If I call the same cvThreshold function in any other place such as main or the Widget's constructor, it works.
If f I put the same code in a separate function and call that function with QtConcurrent::run() inside the same slot, it works.
If I use OpenCV 1.0, it works.
Why this behaviour? Are there any restrictions about the operations that can be done inside Qt slots?
Thanks in advance.
Bookmarks