1. 程式人生 > 實用技巧 >Qt+OpenCV呼叫海康相機SDK採集影象(C++)

Qt+OpenCV呼叫海康相機SDK採集影象(C++)

配置環境:

  Qt5.12.5

  OpenCV3.4.9

  海康MVS3.1.0

開發工具:QT Creator-4.11.0

1、開發步驟:

1)建立QT專案,在pro檔案中新增相機的引用檔案

1.1)新增海康的庫:

將海康SDK庫MVS\Development\Includes和MVS\Development\Libraries\win64下複製到自己的工程目錄下

然後把庫新增到.pro檔案中

點選下一步之後就會在.pro檔案中出現如下程式碼

然後在這後面加上以下程式碼,新增依賴項

1 INCLUDEPATH += $$PWD/includes/
2 INCLUDEPATH += $$PWD/includes/GenICam/
3
4 DEPENDPATH += $$PWD/includes/ 5 DEPENDPATH += $$PWD/includes/GenICam/

1.2)配置OpenCV

跟上面配置HKSDK步驟相同庫檔案目錄為OpenCV的安裝目錄D:/OpenCV/opencv/build/x64/vc14/lib/opencv_world349d.lib

配置完成會在。pro檔案中出現如下程式碼

需要在後面新增如下程式碼

1 INCLUDEPATH += D:\OpenCV\opencv\build\include \
2                 D:\OpenCV\opencv\build\include\opencv \
3 D:\OpenCV\opencv\build\include\opencv2 4 DEPENDPATH += D:\OpenCV\opencv\build\include \ 5 D:\OpenCV\opencv\build\include\opencv \ 6 D:\OpenCV\opencv\build\include\opencv2

這樣海康SDK和OpenCV庫就配置完成了,可以在專案引入他們的標頭檔案了。

2、