OpenCV mat not working in debug mode

Viewed 969

I'm trying to create a function making possible the setting of the contrast/brightness of a QImage with OpenCV 3.1. This perfectly works in release but not in debug (it returns a blank image) :

QImage getNewImage(QImage *img, float contrast, float brightness)
{
    // Convert image to temporary cv::Mat with a deep copy
    // Output format is BGRA
    cv::Mat temp(img->height(),img->width(),CV_8UC4,(uchar*)img->bits(),img->bytesPerLine());

    temp.convertTo(temp, -1, contrast, brightness);
    cv::cvtColor(temp, temp, CV_BGRA2RGB);

    // Convert back to QImage RGB
    QImage dest((const uchar *) temp.data, temp.cols, temp.rows, temp.step, QImage::Format_RGB888);
    return dest;
}

Do you see what could be the problem ?


EDIT

My .pro (the two related dll are in the bin dir).

INCLUDEPATH += ../lib/opencv/include

CONFIG(debug, debug|release) {
    LIBS += ../lib/opencv/opencv_world310d.lib
} else {
    LIBS += ../lib/opencv/opencv_world310.lib
}

Includes :

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
2 Answers

I have had the same problem, as if I created the Mat object in a function than the qtcreator debugger can not debug that function just stopped with an empty debug window and timed out after a while, so I added the Mat object variable in the class definition and after that the debugger went smoothly and worked as expected! :) (sorry for bad english)

Related