/// <summary> /// 根据相机UserID实例化相机 /// </summary> /// <param name="UserID"></param> public BaslerCamera(string UserID) { try { strUserID = UserID; // 枚举相机列表 List <ICameraInfo> allCameraInfos = CameraFinder.Enumerate(); foreach (ICameraInfo cameraInfo in allCameraInfos) { if (strUserID == cameraInfo[CameraInfoKey.UserDefinedName]) { camera = new Camera(cameraInfo); } } if (camera == null) { MessageBox.Show("未识别到UserID为“" + strUserID + "”的相机!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception e) { ShowException(e); } }
/****************** 实例化相机 ******************/ /// <summary> /// 实例化第一个找到的相机 /// </summary> public BaslerCamera() { try { camera = new Camera(); } catch (Exception e) { ShowException(e); } }