一. Qt搭建??禉C器人工業(yè)相機開發(fā)環(huán)境
-
參考這個鏈接安裝好MVS客戶端
-
Qt新建一個c++項目
-
cmakeList中添加海康機器人的庫,如下:
cmake_minimum_required(VERSION 3.5) project(HIKRobotCameraTest LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) # 海康機器人庫文件設置 set(MVC_DIR "C:\\Program Files (x86)\\MVS\\Development") set(MVC_INCLUDE_DIRS ${MVC_DIR}\\Includes) set(MVC_LIB_DIRS ${MVC_DIR}\\Libraries\\win64) include_directories(${MVC_INCLUDE_DIRS}) link_directories(${MVC_LIB_DIRS}) add_executable(HIKRobotCameraTest main.cpp) target_link_libraries(${PROJECT_NAME} PUBLIC MvCameraControl) install(TARGETS HIKRobotCameraTest LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-
main.cpp中添加以下代碼文章來源:http://www.zghlxwxcb.cn/news/detail-679209.html
#include <iostream> #include "MvCameraControl.h" #include <stdio.h> #include <Windows.h> #include <conio.h> using namespace std; bool PrintDeviceInfo(MV_CC_DEVICE_INFO* pstMVDevInfo) { if (NULL == pstMVDevInfo) { printf("The Pointer of pstMVDevInfo is NULL!\n"); return false; } if (pstMVDevInfo->nTLayerType == MV_CAMERALINK_DEVICE) { printf("chPortID: [%s]\n", pstMVDevInfo->SpecialInfo.stCamLInfo.chPortID); printf("chModelName: [%s]\n", pstMVDevInfo->SpecialInfo.stCamLInfo.chModelName); printf("chFamilyName: [%s]\n", pstMVDevInfo->SpecialInfo.stCamLInfo.chFamilyName); printf("chDeviceVersion: [%s]\n", pstMVDevInfo->SpecialInfo.stCamLInfo.chDeviceVersion); printf("chManufacturerName: [%s]\n", pstMVDevInfo->SpecialInfo.stCamLInfo.chManufacturerName); printf("Serial Number: [%s]\n", pstMVDevInfo->SpecialInfo.stCamLInfo.chSerialNumber); } else { printf("Not support.\n"); } return true; } int main() { int nRet = MV_OK; void* handle = NULL; MV_CC_DEVICE_INFO_LIST stDeviceList; memset(&stDeviceList, 0, sizeof(MV_CC_DEVICE_INFO_LIST)); nRet = MV_CC_EnumDevices(MV_CAMERALINK_DEVICE, &stDeviceList); if (MV_OK != nRet) { printf("Enum Devices fail! nRet [0x%x]\n", nRet); } if (stDeviceList.nDeviceNum > 0) { for (unsigned int i = 0; i < stDeviceList.nDeviceNum; i++) { printf("[device %d]:\n", i); MV_CC_DEVICE_INFO* pDeviceInfo = stDeviceList.pDeviceInfo[i]; if (NULL == pDeviceInfo) { } PrintDeviceInfo(pDeviceInfo); } } else { printf("Find No Devices!\n"); } return 0; }
-
運行程序,出現(xiàn)以下內容則說明安裝庫成功
文章來源地址http://www.zghlxwxcb.cn/news/detail-679209.html
到了這里,關于??禉C器人工業(yè)相機 Win10+Qt+Cmake 開發(fā)環(huán)境搭建的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!