在Qt Creator中添加OpenCV库
在项目的pro文件中添加如下代码:
INCLUDEPATH += D:/opencv/build/include
win32:CONFIG(debug, debug|release): {
LIBS += -LD:/opencv/build/x86/vc12/lib \
-lopencv_core249d \
-lopencv_imgproc249d \
-lopencv_highgui249d \
-lopencv_ml249d \
-lopencv_video249d \
-lopencv_features2d249d \
-lopencv_calib3d249d \
-lopencv_objdetect249d \
-lopencv_contrib249d \
-lopencv_legacy249d \
-lopencv_flann249d
} else:win32:CONFIG(release, debug|release): {
LIBS += -LD:/opencv/build/x86/vc12/lib \
-lopencv_core249 \
-lopencv_imgproc249 \
-lopencv_highgui249 \
-lopencv_ml249 \
-lopencv_video249 \
-lopencv_features2d249 \
-lopencv_calib3d249 \
-lopencv_objdetect249 \
-lopencv_contrib249 \
-lopencv_legacy249 \
-lopencv_flann249
}
注意:
- LIBS路径要对应Qt使用的VS版本。
- -l链接的都是当前版本下的动态链接库文件名(没有后缀名)。
参考:https://www.librehat.com/qt-5-2-vs2012-opencv-2-4-7-dev-environment-setup-tutorial/