开发者

Qt and OpenCV 2.0 integration problems

开发者 https://www.devze.com 2022-12-20 20:25 出处:网络
I have a Qt application that uses OpenCV for image processing. Everything was working fine with OpenCV 1.0 but when I upgraded to

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, 开发者_StackOverflowdst, 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号