前言:
配置环境是编程的第一步,所以写这篇文章来指导环境的配置。如果已经配置好了,想在qt上使用海康的摄像头,可以参考这篇文章:海康威视相机在QTcreate上的使用教程
环境配置:
1.海康SDK
海康SDK
LIBS += -L 你的路径 \ -lMvCameraControl
2.opencv
配置opencv
跟着这位大佬的配置,按部就班,一定要一模一样,
配置好以后,在qt中添加对应的头文件:
INCLUDEPATH += D:\opencv\opencv\opencv-build\install\include
LIBS += D:\opencv\opencv\opencv-build\install\x64\mingw\lib\libopencv_*.a
把我的路径换成你的路径,可以先测试一下opencv是不是按照成功了,小技巧:头文件声明一个mat,看一下能不能点击跳槽,如果可以,说明导入成功了。如下就是安装成功界面
参考导入文件
MyCamera.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
MyCamera.cpp \
main.cpp \
widget.cpp \
workthread.cpp
HEADERS += \
MyCamera.h \
widget.h \
workthread.h
FORMS += \
widget.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
LIBS += -LD:\QTprojcet\Documents\HKconfigright\Libraries\win64\ -lMvCameraControl
INCLUDEPATH += $$PWD/Includes
DEPENDPATH += $$PWD/Includes
INCLUDEPATH += D:\opencv\opencv\opencv-build\install\include
LIBS += D:\opencv\opencv\opencv-build\install\x64\mingw\lib\libopencv_*.a