SageDO
SageDO

Reputation: 27

Qt dll error with opencv

I'm trying to run a program to display an image using opencv but I get the following errors:

file not recognized: File format not recognized
C:\opencv\release\bin\opencv_ffmpeg249_64.dll

error:Id returned 1 exit status
File not found: collect2.exe

.pro file:

QT       += core

QT       -= gui

TARGET = myFirstOpenCVProject
CONFIG   += console
CONFIG   -= app_bundle
CONFIG   -= qt

TEMPLATE = app


SOURCES += main.cpp

INCLUDEPATH += C://opencv//release//install//include

LIBS += C://opencv//release//bin//*.dll

#LIBS += C://opencv//release//lib//*.a

LIBS += -LC://opencv//release//lib -llibopencv_core249 -llibopencv_highgui249 -llibopencv_imgproc249

OTHER_FILES += \
    img.JPG

main.cpp

#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>


int main()
{
        // read an image
        cv::Mat image= cv::imread("img.jpg");
        // create image window named "My Image"
        cv::namedWindow("My Image");
        // show the image on window
        cv::imshow("My Image", image);
        // wait key for 5000 ms
        cv::waitKey(1000);
        return 1;
}

The image(img.jpg) is in the appropriate directory; where the project executable is. I tried removing the dll and the code ran without errors but it did nothing and just showed a shell prompting me to hit return.

enter image description here

Upvotes: 0

Views: 1040

Answers (1)

GPPK
GPPK

Reputation: 6666

This line is the problem

LIBS += C://opencv//release//bin//*.dll

This line makes you include all the .dll files that are in the bin folder for OpenCV. You don't want to do this.


You may just be able to remove this line and it will work I am unable to test. Failing that see below


What you want to do is include only the dll files for the code you are using. The matching DLLs for

  • core
  • highgui
  • imgproc

something like this would work for OpenCV 2.4.9 debug (remove the last d for release libs):

LIBS += C://opencv//release//bin//opencv_highgui249d.dll
LIBS += C://opencv//release//bin//opencv_imgproc249d.dll
LIBS += C://opencv//release//bin//opencv_core249d.dll

Upvotes: 1

Related Questions