PeakGen
PeakGen

Reputation: 23045

OpenCV image is not showing

I am working on the following code:

Main.cpp

#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
    Mat im = imread("C:/Users/Public/Pictures/Sample Pictures/Koala.jpg");
    if (im.empty())
    {
        cout << "Cannot load image!" << endl;
        return -1;
    }
    imshow("Image", im);
    waitKey(0);

    return 0;
}

I am trying to test the OpenCV with QT, by simply opening an image. This is my very first QT application. However, the program runs, but there is no image display! The same code runs in VS 2010 and display the image correctly. Following is the only output I get from QT.

enter image description here

Following is my QT Project configuration.

Tester.pro

#-------------------------------------------------
#
# Project created by QtCreator 2013-04-25T23:36:30
#
#-------------------------------------------------

QT       += core

QT       -= gui

TARGET = Tester
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app


SOURCES += main.cpp

INCLUDEPATH += C:\opencv\build\include\

LIBS += -LC:\opencv\build\x86\mingw\lib\
-lopencv_core240 \
-lopencv_highgui240 \
-lopencv_imgproc240 \
-lopencv_features2d240 \
-lopencv_calib3d240

Here are the version I am using:

How can I make this opencv task work correctly?

Update

I just checked the .exe file it built. It gives the following error when I double click on it

enter image description here

Upvotes: 1

Views: 1524

Answers (1)

karlphillip
karlphillip

Reputation: 93478

That error means that the Operating System was unable to find the .DLL when your application was launched.

There are 2 ways to fix that:

  • Locate and copy that .DLL to the .exe folder.
  • Modify Windows' PATH environment variable and add the full path to that .DLL. It's best to reboot your machine after this change.

Upvotes: 1

Related Questions