帮帮我啊,昨晚都没睡觉了
我用VFW编了个摄像头图像采集程序,为什么换个无驱的摄像头,就不成功呢???部份源代码:
Public Sub PreviewVideo(ByVal pbCtrl As PictureBox)
hWnd = capCreateCaptureWindowA(0, _
WS_VISIBLE Or WS_CHILD, 0, 0, 0, _
0, pbCtrl.Handle.ToInt32, 0)
If SendMessage( _
hWnd, WM_CAP_DRIVER_CONNECT, _
0, 0) Then
'也连接成功了,可就是没有图像是个黑框框啊
'---set the preview scale---
SendMessage(hWnd, WM_CAP_SET_SCALE, True, 0)
'---set the preview rate (ms)---
SendMessage(hWnd, WM_CAP_SET_PREVIEWRATE, 15, 0)
'---start previewing the image---
SendMessage(hWnd, WM_CAP_SET_PREVIEW, True, 0)
'---resize window to fit in PictureBox control---
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, _
pbCtrl.Width, pbCtrl.Height, _
SWP_NOMOVE Or SWP_NOZORDER)
Else
'--error connecting to video source---
DestroyWindow(hWnd)
End If
End Sub
Public Function GetEncoderInfo(ByVal mimeType As String) As System.Drawing.Imaging.ImageCodecInfo
Dim codecs() As System.Drawing.Imaging.ImageCodecInfo = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()
'Find the correct image codec
Dim i As Integer
For i = 0 To codecs.Length - 1
'Response.Write(codecs(i).MimeType & " : " & mimeType)
If (codecs(i).MimeType.Equals(mimeType)) Then
'Response.Write("...ok<br>")
Return codecs(i)
Else
'Response.Write("<br>")
End If
Next
Return Nothing
End Function --------------------编程问答--------------------
--------------------编程问答-------------------- 那真的要帮顶啦 --------------------编程问答-------------------- 這個幫你頂哈咯··· --------------------编程问答-------------------- 只能帮顶 --------------------编程问答-------------------- 飄過。。。
Dim lpszName(99) As Byte
Try
hWndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, 0, 0, Picture1.Width, Picture1.Height, Picture1.Handle, 0)
If hWndC.ToInt32() <> 0 Then
SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)
SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0)
SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0)
SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0)
SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0)
SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0)
SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
补充:.NET技术 , VB.NET