//打开指定相机 private void Selected_comboBox_SelectedIndexChanged(object sender, EventArgs e) { int n = Selected_comboBox.SelectedIndex; RemoveCamera(); svscamera = SVS_CameraSys.CameraList[n]; ConnectCamera(); if (DispPanel != null) { if (DispPanel.Width / DispPanel.Height > svscamera.camWidth / svscamera.camHeight) { DispPanel.Width = DispPanel.Height * svscamera.camWidth / svscamera.camHeight; } else { DispPanel.Height = DispPanel.Width * svscamera.camHeight / svscamera.camWidth; } } InitBuffer(svscamera.camWidth, svscamera.camHeight); //Label显示分辨率 Cam_Width.Text = svscamera.camWidth.ToString(); Cam_Height.Text = svscamera.camHeight.ToString(); //滚动条初始化 Frame_value.Text = svscamera.framerate.ToString(); hScrollBarFrame.Maximum = (int)svscamera.maxFrames * 10; hScrollBarFrame.Minimum = (int)svscamera.minFrames * 10; hScrollBarFrame.SmallChange = (hScrollBarFrame.Maximum - hScrollBarFrame.Minimum) / 10; hScrollBarFrame.LargeChange = hScrollBarFrame.SmallChange * 5; hScrollBarFrame.Value = (int)svscamera.framerate * 10; labelExplorValue.Text = ((svscamera.ExpTime) / 1000).ToString(); hScrollBarExp.Maximum = /*(int)svscamera.ExpTimeMax*/ 10000 * 100; hScrollBarExp.Minimum = (int)svscamera.ExpTimeMin * 100; hScrollBarExp.SmallChange = 1000; hScrollBarExp.LargeChange = 1000 * 20; hScrollBarExp.Value = (int)svscamera.ExpTime * 100; Gain_value.Text = svscamera.GainValue.ToString(); hScrollBarGain.Maximum = (int)svscamera.GainValueMax * 10; hScrollBarGain.Minimum = 0; hScrollBarGain.SmallChange = (hScrollBarGain.Maximum - hScrollBarGain.Minimum) / 100; hScrollBarGain.LargeChange = hScrollBarGain.SmallChange * 5; hScrollBarGain.Value = (int)svscamera.GainValue * 10; }
//获得相机个数 public static int getCameras() { camAnz = 0; if (hCameraContainer != GigeApi.SVGigE_NO_CLIENT) { myApi.Gige_CameraContainer_delete(hCameraContainer); } hCameraContainer = myApi.Gige_CameraContainer_create(GigeApi.SVGigETL_Type.SVGigETL_TypeFilter); if (hCameraContainer >= 0) { errorflag = myApi.Gige_CameraContainer_discovery(hCameraContainer); if (errorflag == GigeApi.SVSGigeApiReturn.SVGigE_SUCCESS) { camAnz = myApi.Gige_CameraContainer_getNumberOfCameras(hCameraContainer); } } if (camAnz > 0) { CameraList = new SVS_Camera[camAnz]; for (int i = 0; i < camAnz; i++) { CameraList[i] = new SVS_Camera(); CameraList[i].CameraIndex = i; CameraList[i].InitSvsCamer(1); CameraList[i].SetSVSCameraMode(0); CameraList[i].hCamera = SVS_CameraSys.myApi.Gige_CameraContainer_getCamera(SVS_CameraSys.hCameraContainer, i); CameraList[i].modelname = SVS_CameraSys.myApi.Gige_Camera_getModelName(CameraList[i].hCamera); CameraList[i].SN = SVS_CameraSys.myApi.Gige_Camera_getSerialNumber(CameraList[i].hCamera); CameraList[i].GetSvsCamFps(); //帧率初始化 CameraList[i].GetExpTime(); //曝光时间初始化 CameraList[i].GetGainValue(); //增益初始化 CameraList[i].StopLive(); } } return(camAnz); }