// Exposure need to be changed private void exposureUpDown_ValueChanged(object sender, EventArgs e) { if (videoSource != null) { try { videoSource.SetParam(CameraParameter.Exposure, (int)((float)exposureUpDown.Value * 1000)); // set interval between capturing new frames from camera videoSource.FrameInterval = (int)(1000.0f / videoSource.GetParamFloat(CameraParameter.FramerateMax)); // reset statistics stopWatch = null; int bin = videoSource.FramesReceived; spareLabel.Text = string.Format("frame interval = {0} ms, max fps = {1}", videoSource.FrameInterval, videoSource.GetParamFloat(CameraParameter.FramerateMax)); } catch { } } }
// On "Connect" button click private void connectButton_Click(object sender, EventArgs e) { // set busy cursor this.Cursor = Cursors.WaitCursor; // close whatever is open now CloseCamera( ); if (videoSource == null) { try { videoSource = new XimeaVideoSource(deviceCombo.SelectedIndex); // start the camera videoSource.Start( ); // get some parameters nameBox.Text = videoSource.GetParamString(CameraParameter.DeviceName); snBox.Text = videoSource.GetParamString(CameraParameter.DeviceSerialNumber); typeBox.Text = videoSource.GetParamString(CameraParameter.DeviceType); // width widthUpDown.Minimum = videoSource.GetParamInt(CameraParameter.WidthMin); widthUpDown.Maximum = videoSource.GetParamInt(CameraParameter.WidthMax); widthUpDown.Value = videoSource.GetParamInt(CameraParameter.WidthMax); // height heightUpDown.Minimum = videoSource.GetParamInt(CameraParameter.HeightMin); heightUpDown.Maximum = videoSource.GetParamInt(CameraParameter.HeightMax); heightUpDown.Value = videoSource.GetParamInt(CameraParameter.HeightMax); // exposure exposureUpDown.Minimum = videoSource.GetParamInt(CameraParameter.ExposureMin) / 1000; exposureUpDown.Maximum = videoSource.GetParamInt(CameraParameter.ExposureMax) / 1000; exposureUpDown.Value = 0; exposureUpDown.Value = 10; // gain gainUpDown.Minimum = new Decimal(videoSource.GetParamFloat(CameraParameter.GainMin)); gainUpDown.Maximum = new Decimal(videoSource.GetParamFloat(CameraParameter.GainMax)); gainUpDown.Value = new Decimal(videoSource.GetParamFloat(CameraParameter.Gain)); videoSourcePlayer.VideoSource = videoSource; EnableConnectionControls(false); // reset stop watch stopWatch = null; // start timer timer.Start( ); } catch (Exception ex) { MessageBox.Show("Failed openning XIMEA camera:\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseCamera( ); } } this.Cursor = Cursors.Default; }