Ask Your Question
0

Install OpenCV in Windows 10

asked 2019-09-04 10:18:02 -0600

I installed Qt 5, CMake 3, Visual Studio 2015 and OpenCV 3. I made a test program using Qt Creator that tries to open an image, but nothing happens. I see no error messages in Qt Creator. How do I know I have installed OpenCV correctly and what I am missing? The reason I tried OpenCV 3 instead of OpenCV 4 is that I found an e-book (Amin Ahmadi Tazehkandi, 2018) in my school's library and wanted to see if it helps me learn OpenCV more easily. I can try to install OpenCV 4 instead, if it makes installing OpenCV more easy.

edit retag flag offensive close merge delete

Comments

I guess you are not setting the INCLUDEPATH and LIBS in your *.pro file in QT appropriate.

gino0717 gravatar imagegino0717 ( 2019-09-05 22:11:49 -0600 )edit

In opencv.pri I have

INCLUDEPATH += c:/opencv/install/include
Debug: {
LIBS += -lc:/opencv/install/x86/vc14/lib/opencv_world343d
}
Release: {
LIBS += -lc:/opencv/install/x86/vc14/lib/opencv_world343
}

In Test.pro I have

QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
        main.cpp
tomihasa gravatar imagetomihasa ( 2019-09-06 03:36:27 -0600 )edit

add

include(opencv.pri)

to your Test.pro

gino0717 gravatar imagegino0717 ( 2019-09-06 04:22:46 -0600 )edit

I had to do some other changes also and it works now.

Test.pro:

QT += core
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
TEMPLATE = app
SOURCES += \
        main.cpp
TARGET = Test
include(C:\opencv\opencv.pri)

main.cpp:

#include "opencv/cv.hpp"
#include <QCoreApplication>
#include <QDebug>
using namespace cv;
using namespace std;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    cv::Mat image = cv::imread("test.jpg");

    if ( image.empty() ) {

        qDebug() << "Problem";
        return -1;
    }

    cv::imshow("Output", image);

    return a.exec();
}
tomihasa gravatar imagetomihasa ( 2019-09-07 04:55:39 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2019-09-07 11:51:44 -0600

I had to do some modifications to the .pro and .cpp files - see the comments in this discussion. Thanks, gino0717!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-09-04 10:18:02 -0600

Seen: 837 times

Last updated: Sep 07 '19