Wednesday, December 22, 2010

How to link OpenCV with Qt

Hi... after a long time!!!.

These days, I am learning OpenCV and Qt programming for my undergraduate project. So, I thought to share my knowledge with you all.

I was struggling a lot to link both OpenCV and Qt as a beginner. Finally, I found these posts which are great.



This is how my project's .pro file looks... (OS - Windows 7)

INCLUDEPATH += "C:\OpenCV2.1\include\opencv" \
"C:\OpenCV2.1\src\cv" \
"C:\OpenCV2.1\src\cvaux" \
"C:\OpenCV2.1\src\cxcore" \
"C:\OpenCV2.1\src\highgui" \
"C:\OpenCV2.1\src\ml"

LIBS += -L"C:\OpenCV2.1\lib" \
-lcv210 \
-lcvaux210 \
-lhighgui210 \
-lcxcore210

Here cv210, cvaux210 and so on..... are the names of lib files in your opencv lib folder.

Very simple thing... but as a beginner, I know how I struggled with this.. So, this post is for those who are new to OpenCv with Qt Programming.

Have a nice day!!! :)



5 comments:

  1. Thanks for sharing. It is almost the same under Linux. Following line solved my problem:

    LIBS += -lcv -lhighgui -lfftw3

    except that I don't have to tell the include path, it is managed by Ubuntu. Just install the package using package manager and you're done.

    ReplyDelete
  2. really had a little hard time finding =x
    Works like a charm thanks ^^

    ReplyDelete
  3. For example you can use pkg-config.
    It will be look like this:
    CONFIG += link_pkgconfig
    PKGCONFIG += opencv

    ReplyDelete
  4. Alex, I didn't get you. You meant instead of giving include and library paths, we can just give only pkg-config ??

    ReplyDelete

Amazing Products