一. Qt搭建海康机器人工业相机开发环境
-
参考这个链接安装好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中添加以下代码文章来源:https://www.toymoban.com/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; }
-
运行程序,出现以下内容则说明安装库成功
文章来源地址https://www.toymoban.com/news/detail-679209.html
到了这里,关于海康机器人工业相机 Win10+Qt+Cmake 开发环境搭建的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!