使用QT編寫Opencv2/3的LIB設定

YouthDance發表於2017-12-05

由於,連結生成方式的不同。因此,opencv2和opencv3使用的Lib設定並不相同。
1、opencv2

INCLUDEPATH += /opencv-direction/opencv-2.4.13.4/include/opencv \
               /opencv-direction/opencv-2.4.13.4/include/opencv2

LIBS += /opencv-direction/opencv-2.4.13.4/build/lib/libopencv_core.so \
        /opencv-direction/opencv-2.4.13.4/build/lib/libopencv_highgui.so \
        /opencv-direction/opencv-2.4.13.4/build/lib/libopencv_imgproc.so \
        /opencv-direction/opencv-2.4.13.4/build/lib/libopencv_video.so

2、opencv3

INCLUDEPATH += /opencv-direction/opencv-3.3.0/include/opencv \
               /opencv-direction/opencv-3.3.0/include/opencv2

LIBS += -lopencv_highgui -lopencv_core -lopencv_imgproc

INCLUDEPATH += /opencv-direction/opencv-3.3.0/include/opencv \
               /opencv-direction/opencv-3.3.0/include/opencv2

LIBS +=  -L /usr/local/lib/libopencv_*.so

3、總結分析
根據上面的設定,可以看出。主要的區別在Lib上,Include的匯入方法並無且別。
opencv2的lib匯入,主要是從編譯好的檔案lib中配置.so連結。
而opencv3則使用更加方便的-lopencv_* 加上需要使用的函式名。

相關文章