Update:
Here's a sample of the current code which uses video controls to build a video screen control on the form in the specified location with specified height and width. This also has a trackbar attached to the form along with a combobox to pick and edit settings for the camera view (gain, exposure, etc..).
It's pretty sweet. I haven't gone HD with it, and im not sure how to yet. That's one of the long term goals. I believe this is the start to getting there. Also I'm working on getting pictures out of this now as well. I'm thinking that will be pretty easy, though. We'll see!
Imports DirectShowLib
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.ComTypes
Imports System.Threading
Imports MySql.Data.MySqlClient
Inherits System.Windows.Forms.Form
Dim myTestInt As Integer
Enum PlayState
Stopped
Paused
Running
Init
End Enum
Dim CurrentState As PlayState = PlayState.Stopped
Dim D As Integer = Convert.ToInt32("0X8000", 16)
Public WM_GRAPHNOTIFY As Integer = D + 1
Dim VideoWindow As IVideoWindow = Nothing
Dim MediaControl As IMediaControl = Nothing
Dim MediaEventEx As IMediaEventEx = Nothing
Dim GraphBuilder As IGraphBuilder = Nothing
Dim CaptureGraphBuilder As ICaptureGraphBuilder2 = Nothing
Dim rot As DsROTEntry = Nothing
Dim capDevices As DsDevice()
Dim camDevice As DsDevice = Nothing
Dim myExposureValue As Integer
Dim myBrightnessValue As Integer
Dim myGainValue As Integer
Dim mySaturationValue As Integer
Dim myZoomValue As Integer
Dim camFilter As IBaseFilter = Nothing
Dim camControl As IAMCameraControl
Dim vidControl As IAMVideoProcAmp
Dim myGraphBuilder As IFilterGraph2 = CType(New FilterGraph, IFilterGraph2)
#Region "Camera"
Private Sub CaptureVideo()
Dim hr As Integer = 0
Dim sourceFilter As IBaseFilter = Nothing
Try
GetInterfaces()
hr = Me.CaptureGraphBuilder.SetFiltergraph(Me.GraphBuilder)
Debug.WriteLine("Attach the filter graph to the capture graph : " & DsError.GetErrorText(hr))
DsError.ThrowExceptionForHR(hr)
sourceFilter = FindCaptureDevice()
SetConfigParms(CaptureGraphBuilder, sourceFilter, 45, 1280, 720)
hr = Me.GraphBuilder.AddFilter(sourceFilter, "Video Capture")
Debug.WriteLine("Add capture filter to our graph : " & DsError.GetErrorText(hr))
DsError.ThrowExceptionForHR(hr)
hr = Me.CaptureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, sourceFilter, Nothing, Nothing)
Debug.WriteLine("Render the preview pin on the video capture filter : " & DsError.GetErrorText(hr))
DsError.ThrowExceptionForHR(hr)
Marshal.ReleaseComObject(sourceFilter)
SetupVideoWindow()
rot = New DsROTEntry(Me.GraphBuilder)
hr = Me.MediaControl.Run()
Debug.WriteLine("Start previewing video data : " & DsError.GetErrorText(hr))
DsError.ThrowExceptionForHR(hr)
Me.CurrentState = PlayState.Running
Debug.WriteLine("The currentstate : " & Me.CurrentState.ToString)
Catch ex As Exception
MessageBox.Show("An unrecoverable error has occurred.With error : " & ex.ToString)
End Try
End Sub
Private Sub SetConfigParms(ByVal capGraph As ICaptureGraphBuilder2, ByVal capFilter As IBaseFilter, ByVal iFrameRate As Integer, ByVal iWidth As Integer, ByVal iHeight As Integer)
Try
Dim hr As Integer
Dim o As New Object
Dim media As New AMMediaType
Dim FoundFormat As Boolean
hr = capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, GetType(IAMStreamConfig).GUID, o)
Dim videoStreamConfig As IAMStreamConfig = CType(o, IAMStreamConfig)
If (videoStreamConfig Is Nothing) Then
Throw New Exception("Failed to get IAMStreamConfig")
End If
Dim iCount As Integer = 0, iSize As Integer = 0
videoStreamConfig.GetNumberOfCapabilities(iCount, iSize)
Dim pmtConfig As New AMMediaType
For iFormat As Integer = 0 To iCount - 1
Dim scc As New VideoStreamConfigCaps, pScc As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(scc))
hr = videoStreamConfig.GetStreamCaps(iFormat, pmtConfig, pScc)
DsError.ThrowExceptionForHR(hr)
Marshal.PtrToStructure(pScc, scc)
Dim header As VideoInfoHeader = New VideoInfoHeader
Marshal.PtrToStructure(pmtConfig.formatPtr, header)
If pmtConfig.subType = MediaSubType.RGB24 Then
Debug.Print("iFormat: " & header.BmiHeader.Width & "x" & header.BmiHeader.Height)
If header.BmiHeader.Width = iWidth And header.BmiHeader.Height = iHeight Then
If (iFrameRate > 0) Then
End If
hr = videoStreamConfig.SetFormat(pmtConfig)
DsError.ThrowExceptionForHR(hr)
FoundFormat = True
Exit For
End If
End If
Marshal.DestroyStructure(pScc, GetType(VideoStreamConfigCaps))
Marshal.DestroyStructure(pmtConfig.formatPtr, GetType(VideoInfoHeader))
DsUtils.FreeAMMediaType(pmtConfig)
pmtConfig = Nothing
header = Nothing
scc = Nothing
Next
If Not FoundFormat Then
hr = videoStreamConfig.GetFormat(media)
DsError.ThrowExceptionForHR(hr)
Dim v As VideoInfoHeader = New VideoInfoHeader
Marshal.PtrToStructure(media.formatPtr, v)
If (iFrameRate > 0) Then
v.AvgTimePerFrame = (10000000 / iFrameRate)
End If
If (iWidth > 0) Then
v.BmiHeader.Width = iWidth
End If
If (iHeight > 0) Then
v.BmiHeader.Height = iHeight
End If
Marshal.StructureToPtr(v, media.formatPtr, False)
hr = videoStreamConfig.SetFormat(media)
DsError.ThrowExceptionForHR(hr)
DsUtils.FreeAMMediaType(media)
media = Nothing
End If
Catch ex As Exception
MsgBox("error in setConfigParms - " & ex.Message)
End Try
End Sub
Private Sub GetInterfaces()
Dim hr As Integer = 0
Me.GraphBuilder = CType(New FilterGraph, IGraphBuilder)
Me.CaptureGraphBuilder = CType(New CaptureGraphBuilder2, ICaptureGraphBuilder2)
Me.MediaControl = CType(Me.GraphBuilder, IMediaControl)
Me.VideoWindow = CType(Me.GraphBuilder, IVideoWindow)
Me.MediaEventEx = CType(Me.GraphBuilder, IMediaEventEx)
hr = Me.MediaEventEx.SetNotifyWindow(Me.Handle, WM_GRAPHNOTIFY, IntPtr.Zero)
DsError.ThrowExceptionForHR(hr)
Debug.WriteLine("I started Sub Get interfaces , the result is : " & DsError.GetErrorText(hr))
End Sub
Public Function FindCaptureDevice() As IBaseFilter
Debug.WriteLine("Start the Sub FindCaptureDevice")
Dim hr As Integer = 0
Dim classEnum As IEnumMoniker = Nothing
Dim moniker As IMoniker() = New IMoniker(0) {}
Dim source As Object = Nothing
Dim devEnum As ICreateDevEnum = CType(New CreateDevEnum, ICreateDevEnum)
hr = devEnum.CreateClassEnumerator(FilterCategory.VideoInputDevice, classEnum, 0)
Debug.WriteLine("Create an enumerator for the video capture devices : " & DsError.GetErrorText(hr))
DsError.ThrowExceptionForHR(hr)
Marshal.ReleaseComObject(devEnum)
If classEnum Is Nothing Then
Throw New ApplicationException("No video capture device was detected.\r\n\r\n" & _
"This sample requires a video capture device, such as a USB WebCam,\r\n" & _
"to be installed and working properly. The sample will now close.")
End If
If classEnum.Next(moniker.Length, moniker, IntPtr.Zero) = 0 Then
Dim iid As Guid = GetType(IBaseFilter).GUID
moniker(0).BindToObject(Nothing, Nothing, iid, source)
Else
Throw New ApplicationException("Unable to access video capture device!")
End If
Marshal.ReleaseComObject(moniker(0))
Marshal.ReleaseComObject(classEnum)
Return CType(source, IBaseFilter)
End Function
Public Sub SetupVideoWindow()
Dim hr As Integer = 0
hr = Me.VideoWindow.put_Owner(Me.Handle)
DsError.ThrowExceptionForHR(hr)
hr = Me.VideoWindow.put_WindowStyle(WindowStyle.Child Or WindowStyle.ClipChildren)
DsError.ThrowExceptionForHR(hr)
ResizeVideoWindow()
hr = Me.VideoWindow.put_Visible(OABool.True)
DsError.ThrowExceptionForHR(hr)
End Sub
Protected Overloads Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case WM_GRAPHNOTIFY
HandleGraphEvent()
End Select
If Not (Me.VideoWindow Is Nothing) Then
Me.VideoWindow.NotifyOwnerMessage(m.HWnd, m.Msg, m.WParam.ToInt32, m.LParam.ToInt32)
End If
MyBase.WndProc(m)
End Sub
Public Sub HandleGraphEvent()
Dim hr As Integer = 0
Dim evCode As EventCode
Dim evParam1 As Integer
Dim evParam2 As Integer
If Me.MediaEventEx Is Nothing Then
Return
End If
While Me.MediaEventEx.GetEvent(evCode, evParam1, evParam2, 0) = 0
hr = Me.MediaEventEx.FreeEventParams(evCode, evParam1, evParam2)
DsError.ThrowExceptionForHR(hr)
End While
End Sub
Public Sub closeinterfaces()
If Not (Me.MediaControl Is Nothing) Then
Me.MediaControl.StopWhenReady()
End If
Me.CurrentState = PlayState.Stopped
If Not (Me.MediaEventEx Is Nothing) Then
Me.MediaEventEx.SetNotifyWindow(IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero)
End If
If Not (Me.VideoWindow Is Nothing) Then
Me.VideoWindow.put_Visible(OABool.False)
Me.VideoWindow.put_Owner(IntPtr.Zero)
End If
If Not (rot Is Nothing) Then
rot.Dispose()
rot = Nothing
End If
Marshal.ReleaseComObject(Me.MediaControl) : Me.MediaControl = Nothing
Marshal.ReleaseComObject(Me.MediaEventEx) : Me.MediaEventEx = Nothing
Marshal.ReleaseComObject(Me.VideoWindow) : Me.VideoWindow = Nothing
Marshal.ReleaseComObject(Me.GraphBuilder) : Me.GraphBuilder = Nothing
Marshal.ReleaseComObject(Me.CaptureGraphBuilder) : Me.CaptureGraphBuilder = Nothing
End Sub
Private Sub Form1_Resize1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.WindowState = FormWindowState.Minimized Then
ChangePreviewState(False)
End If
If Me.WindowState = FormWindowState.Normal Then
ChangePreviewState(True)
End If
ResizeVideoWindow()
End Sub
Public Sub ChangePreviewState(ByVal showVideo As Boolean)
Dim hr As Integer = 0
If Me.MediaControl Is Nothing Then
Debug.WriteLine("MediaControl is nothing")
Return
End If
If showVideo = True Then
If Not (Me.CurrentState = PlayState.Running) Then
Debug.WriteLine("Start previewing video data")
hr = Me.MediaControl.Run
Me.CurrentState = PlayState.Running
End If
Else
Debug.WriteLine("Stop previewing video data")
hr = Me.MediaControl.StopWhenReady
Me.CurrentState = PlayState.Stopped
End If
End Sub
Public Sub ResizeVideoWindow()
If Not (Me.VideoWindow Is Nothing) Then
Me.VideoWindow.SetWindowPosition(0, 27, Me.Width, Me.ClientSize.Height - 27)
End If
End Sub
#End Region
#Region "Loading"
Public Sub LoadMe(ByRef PartsDRow As DataRow, ByRef loadThisProjectRow As DataRow, ByVal editMode As Boolean)
InitializeBuffers()
CaptureVideo()
SetupCamera()
If editMode Then
If camFound Then
Me.Label1.Visible = True
Me.TrackBar1.Visible = True
Me.ComboBox1.Visible = True
Me.ComboBox1.SelectedItem = Me.ComboBox1.Items(0)
Else
MsgBox("Camera not found")
Me.Close()
Exit Sub
End If
Else
Me.Label1.Visible = False
Me.TrackBar1.Visible = False
Me.ComboBox1.Visible = False
End If
_WorkerPSU.RunWorkerAsync()
Me.Show()
End Sub
Private Sub SetupCamera()
If Not camFound Then
capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)
For Each CD As DsDevice In capDevices
If CD.Name = "USB2.0 2MP UVC AF Camera" Then
camDevice = CD
camFound = True
ElseIf CD.Name = "Logitech HD Webcam C615" Then
camDevice = CD
camFound = True
End If
Next
End If
If camFound Then
Dim hr As Integer = myGraphBuilder.AddSourceFilterForMoniker(camDevice.Mon, Nothing, camDevice.Name, camFilter)
camControl = CType(camFilter, IAMCameraControl)
vidControl = CType(camFilter, IAMVideoProcAmp)
Dim iMin As Integer
Dim iMax As Integer
Dim iStep As Integer
Dim iDft As Integer
Dim iResult As Integer
iResult = camControl.GetRange(CameraControlProperty.Exposure, iMin, iMax, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
myExposureValue = 0.35 * iMax
iResult = camControl.Set(CameraControlProperty.Exposure, myExposureValue, DirectShowLib.CameraControlFlags.Manual)
Me.ComboBox1.Items.Add("Exposure")
iResult = camControl.GetRange(CameraControlProperty.Focus, iMin, iMax, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
iResult = camControl.Set(CameraControlProperty.Focus, 0, DirectShowLib.CameraControlFlags.Manual)
iResult = camControl.GetRange(CameraControlProperty.Pan, iMin, iMax, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
iResult = camControl.Set(CameraControlProperty.Pan, 0, DirectShowLib.CameraControlFlags.Manual)
iResult = camControl.GetRange(CameraControlProperty.Zoom, iMin, iMax, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
myZoomValue = iMin
iResult = camControl.Set(CameraControlProperty.Zoom, myZoomValue, DirectShowLib.CameraControlFlags.Manual)
Me.ComboBox1.Items.Add("Zoom")
Me.Button1.Text = "Zoom in"
iResult = vidControl.GetRange(VideoProcAmpProperty.BacklightCompensation, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.Set(VideoProcAmpProperty.BacklightCompensation, iMax, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.GetRange(VideoProcAmpProperty.Brightness, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
myBrightnessValue = 0.15 * iMax
iResult = vidControl.Set(VideoProcAmpProperty.Brightness, myBrightnessValue, DirectShowLib.VideoProcAmpFlags.Manual)
Me.ComboBox1.Items.Add("Brightness")
iResult = vidControl.GetRange(VideoProcAmpProperty.Contrast, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.Set(VideoProcAmpProperty.Contrast, iMax, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.GetRange(VideoProcAmpProperty.Gain, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
myGainValue = 0.25 * iMax
iResult = vidControl.Set(VideoProcAmpProperty.Gain, myGainValue, DirectShowLib.VideoProcAmpFlags.Manual)
Me.ComboBox1.Items.Add("Gain")
iResult = vidControl.GetRange(VideoProcAmpProperty.Saturation, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
mySaturationValue = 0.3 * iMax
iResult = vidControl.Set(VideoProcAmpProperty.Saturation, mySaturationValue, DirectShowLib.VideoProcAmpFlags.Manual)
Me.ComboBox1.Items.Add("Saturation")
iResult = vidControl.GetRange(VideoProcAmpProperty.Sharpness, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.Set(VideoProcAmpProperty.Sharpness, iMax, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.GetRange(VideoProcAmpProperty.WhiteBalance, iMin, iMax, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
iResult = vidControl.Set(VideoProcAmpProperty.WhiteBalance, iMax, DirectShowLib.VideoProcAmpFlags.Manual)
videoLoaded = True
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged1(sender As Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.Focus()
AttachItemToTrackBar()
End Sub
Private Sub AttachItemToTrackBar()
If videoLoaded Then
Dim iSetting As Integer = GetCurrentSetting()
Dim iMin As Integer
Dim iMax As Integer
GetMinMaxSetting(iMin, iMax)
Me.TrackBar1.Minimum = iMin
Me.TrackBar1.Maximum = iMax
Me.TrackBar1.Value = iSetting
SetTextBoxToTrackBar()
End If
End Sub
Private Sub TrackBar1_Scroll(sender As System.Object, e As System.EventArgs) Handles TrackBar1.Scroll
SetCurrentSetting(Me.TrackBar1.Value)
SetTextBoxToTrackBar()
End Sub
Private Sub SetTextBoxToTrackBar()
Me.Label1.Text = Me.TrackBar1.Value
End Sub
Private Sub GetMinMaxSetting(ByRef minVal As Integer, ByRef maxVal As Integer)
Dim iResult As Integer
Dim iStep As Integer
Dim iDft As Integer
Select Case Me.ComboBox1.SelectedItem
Case "Zoom"
iResult = camControl.GetRange(CameraControlProperty.Zoom, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Exposure"
iResult = camControl.GetRange(CameraControlProperty.Exposure, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Focus"
iResult = camControl.GetRange(CameraControlProperty.Focus, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Iris"
iResult = camControl.GetRange(CameraControlProperty.Iris, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Pan"
iResult = camControl.GetRange(CameraControlProperty.Pan, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Roll"
iResult = camControl.GetRange(CameraControlProperty.Roll, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Tilt"
iResult = camControl.GetRange(CameraControlProperty.Tilt, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "Zoom"
iResult = camControl.GetRange(CameraControlProperty.Zoom, minVal, maxVal, iStep, iDft, DirectShowLib.CameraControlFlags.Manual)
Case "BacklightCompensation"
iResult = vidControl.GetRange(VideoProcAmpProperty.BacklightCompensation, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Brightness"
iResult = vidControl.GetRange(VideoProcAmpProperty.Brightness, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "ColorEnable"
iResult = vidControl.GetRange(VideoProcAmpProperty.ColorEnable, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Contrast"
iResult = vidControl.GetRange(VideoProcAmpProperty.Contrast, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Gain"
iResult = vidControl.GetRange(VideoProcAmpProperty.Gain, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Gamma"
iResult = vidControl.GetRange(VideoProcAmpProperty.Gamma, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Hue"
iResult = vidControl.GetRange(VideoProcAmpProperty.Hue, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Saturation"
iResult = vidControl.GetRange(VideoProcAmpProperty.Saturation, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "Sharpness"
iResult = vidControl.GetRange(VideoProcAmpProperty.Sharpness, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
Case "WhiteBalance"
iResult = vidControl.GetRange(VideoProcAmpProperty.WhiteBalance, minVal, maxVal, iStep, iDft, DirectShowLib.VideoProcAmpFlags.Manual)
End Select
End Sub
Private Function GetCurrentSetting() As Integer
Dim iResult As Integer
Dim iSetting As Double
Select Case Me.ComboBox1.SelectedItem
Case "Zoom"
iResult = camControl.Get(CameraControlProperty.Zoom, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Exposure"
iResult = camControl.Get(CameraControlProperty.Exposure, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Focus"
iResult = camControl.Get(CameraControlProperty.Focus, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Iris"
iResult = camControl.Get(CameraControlProperty.Iris, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Pan"
iResult = camControl.Get(CameraControlProperty.Pan, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Roll"
iResult = camControl.Get(CameraControlProperty.Roll, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Tilt"
iResult = camControl.Get(CameraControlProperty.Tilt, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Zoom"
iResult = camControl.Get(CameraControlProperty.Zoom, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "BacklightCompensation"
iResult = vidControl.Get(VideoProcAmpProperty.BacklightCompensation, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Brightness"
iResult = vidControl.Get(VideoProcAmpProperty.Brightness, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "ColorEnable"
iResult = vidControl.Get(VideoProcAmpProperty.ColorEnable, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Contrast"
iResult = vidControl.Get(VideoProcAmpProperty.Contrast, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Gain"
iResult = vidControl.Get(VideoProcAmpProperty.Gain, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Gamma"
iResult = vidControl.Get(VideoProcAmpProperty.Gamma, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Hue"
iResult = vidControl.Get(VideoProcAmpProperty.Hue, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Saturation"
iResult = vidControl.Get(VideoProcAmpProperty.Saturation, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "Sharpness"
iResult = vidControl.Get(VideoProcAmpProperty.Sharpness, iSetting, DirectShowLib.CameraControlFlags.Manual)
Case "WhiteBalance"
iResult = vidControl.Get(VideoProcAmpProperty.WhiteBalance, iSetting, DirectShowLib.CameraControlFlags.Manual)
End Select
Return iSetting
End Function
Private Sub SetCurrentSetting(ByVal newValue As Integer)
Dim iResult As Integer
Select Case Me.ComboBox1.SelectedItem
Case "Zoom"
iResult = camControl.Set(CameraControlProperty.Zoom, newValue, DirectShowLib.CameraControlFlags.Manual)
myZoomValue = newValue
Case "Exposure"
iResult = camControl.Set(CameraControlProperty.Exposure, newValue, DirectShowLib.CameraControlFlags.Manual)
myExposureValue = newValue
Case "Brightness"
iResult = vidControl.Set(VideoProcAmpProperty.Brightness, newValue, DirectShowLib.VideoProcAmpFlags.Manual)
myBrightnessValue = newValue
Case "Gain"
iResult = vidControl.Set(VideoProcAmpProperty.Gain, newValue, DirectShowLib.VideoProcAmpFlags.Manual)
myGainValue = newValue
Case "Saturation"
iResult = vidControl.Set(VideoProcAmpProperty.Saturation, newValue, DirectShowLib.VideoProcAmpFlags.Manual)
mySaturationValue = newValue
End Select
End Sub