''' <summary>
''' Gets and sets the camera control properties of DirectShow camera.
''' </summary>
Public Shared Sub GetAndSetCameraControlProperties()
' get a list of installed cameras
Dim captureDevices As System.Collections.ObjectModel.ReadOnlyCollection(Of Vintasoft.Imaging.Media.ImageCaptureDevice) = Vintasoft.Imaging.Media.ImageCaptureDeviceConfiguration.GetCaptureDevices()
' if cameras are not found
If captureDevices.Count = 0 Then
System.Console.WriteLine("No connected devices.")
Return
End If
' get the first available camera
Dim camera As Vintasoft.Imaging.Media.DirectShowCamera = DirectCast(captureDevices(0), Vintasoft.Imaging.Media.DirectShowCamera)
' output camera name
System.Console.WriteLine(camera.FriendlyName)
Dim propertyValue As Vintasoft.Imaging.Media.DirectShowCameraControlPropertyValue
Dim minValue As Integer, maxValue As Integer, [step] As Integer, defaultValue As Integer
System.Console.WriteLine(" - Exposure")
Try
' get supported values
camera.CameraControl.GetSupportedExposureValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Exposure
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Exposure = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
System.Console.WriteLine(" - Focus")
Try
' get supported values
camera.CameraControl.GetSupportedFocusValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Focus
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Focus = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
System.Console.WriteLine(" - Iris")
Try
' get supported values
camera.CameraControl.GetSupportedIrisValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Iris
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Iris = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
System.Console.WriteLine(" - Pan")
Try
' get supported values
camera.CameraControl.GetSupportedPanValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Pan
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Pan = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
System.Console.WriteLine(" - Roll")
Try
' get supported values
camera.CameraControl.GetSupportedRollValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Roll
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Roll = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
System.Console.WriteLine(" - Tilt")
Try
' get supported values
camera.CameraControl.GetSupportedTiltValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Tilt
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Tilt = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
System.Console.WriteLine(" - Zoom")
Try
' get supported values
camera.CameraControl.GetSupportedZoomValues(minValue, maxValue, [step], defaultValue)
System.Console.WriteLine(String.Format(" - Supported values: Min={0}, Max={1}, Step={2}, Default={3}", minValue, maxValue, [step], defaultValue))
' get current value
propertyValue = camera.CameraControl.Zoom
System.Console.WriteLine(String.Format(" - Current value: {0}", propertyValue.Value))
' set current value
camera.CameraControl.Zoom = propertyValue
Catch ex As System.Exception
System.Console.WriteLine(" {0}", ex.Message)
End Try
End Sub