资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net外接摄像头 vb调用摄像头实现拍照

VB.NET 摄像头编程求助大神们帮帮忙

下面是我之前在VB6里测试过的代码:在窗体里放一个按钮叫Command1和一个PictureBox叫Picture1。 Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" _ Alias "capCreateCaptureWindowA" ( _ ByVal lpszWindowName As String, _ ByVal dwStyle As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hWndParent As Long, _ ByVal nID As Long) As Long Private Const WS_CHILD = H40000000 Private Const WS_VISIBLE = H10000000 Private Const WM_USER = H400 Private Const WM_CAP_START = H400 Private Const WM_CAP_EDIT_COPY = (WM_CAP_START + 30) Private Const WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10) Private Const WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52) Private Const WM_CAP_SET_OVERLAY = (WM_CAP_START + 51) Private Const WM_CAP_SET_PREVIEW = (WM_CAP_START + 50) Private Const WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11) Private Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" ( _ ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Private Declare Function SendMessageAsLong Lib "user32" Alias "SendMessageA" _ (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Private Preview_Handle As Long Private iDevice As Long Private hHwnd As Long Private Sub Command1_Click() Dim bRet As Boolean Dim szTest As String szTest = App.Path "\TEST.bmp" Chr$(0) bRet = capEditCopy(hHwnd) If bRet Then DoEvents If Clipboard.GetFormat(vbCFBitmap) Then Picture1.Picture = Clipboard.GetData(vbCFBitmap) Picture1.Picture = Clipboard.GetData(vbCFBitmap) SavePicture Picture1.Image, szTest DoEvents Clipboard.Clear End If End If End Sub Private Sub Form_Load() '建立捕获窗口 Preview_Handle = capCreateCaptureWindow("Video", WS_CHILD + WS_VISIBLE, 0, 0, 320, 240, Me.hWnd, 1) '建立捕获窗口到捕获设备的连接 SendMessage Preview_Handle, WM_CAP_DRIVER_CONNECT, 0, 0 '设置捕获的帧频率为30毫秒一帧 SendMessage Preview_Handle, WM_CAP_SET_PREVIEWRATE, 30, 0 '用预览模式在捕获窗口开始预览图像 SendMessage Preview_Handle, WM_CAP_SET_PREVIEW, 1, 0 End Sub Private Sub Form_Unload(Cancel As Integer) '断开到捕获设备的连接 SendMessage Preview_Handle, WM_CAP_DRIVER_DISCONNECT, 0, 0 End Sub Private Function capEditCopy(ByVal hCapWnd As Long) As Boolean capEditCopy = SendMessageAsLong(hCapWnd, WM_CAP_EDIT_COPY, 0, 0) End Function

成都创新互联专注为客户提供全方位的互联网综合服务,包含不限于网站制作、成都网站设计、华坪网络推广、重庆小程序开发公司、华坪网络营销、华坪企业策划、华坪品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;成都创新互联为所有大学生创业者提供华坪建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com

windows8.1下VB.net使用摄像头

这个方法没问题。

win8.1,我用网上的方法,有时也有黑屏现象,但多试几次就好了。有时还会弹出要选择摄像头,选择确认、取消、应用都是黑屏。

VB.NET怎么调用摄像头啊?求实例,最好配注释啊

Private Const WS_CHILD = H40000000

Private Const WS_VISIBLE = H10000000

Private Const WM_CAP_START = H400

Private Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10

Private Const WM_CAP_SET_SCALE = WM_CAP_START + 53

Private Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52

Private Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50

Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll" ( _

ByVal lpszWindowName As String, _

ByVal dwStyle As Long, _

ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Integer, _

ByVal hWndParent As Long, ByVal nID As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long

Private Sub Form_Load()

'建立采集窗口(不显示窗口,处理后显示到PIC控件)

uwndc = capCreateCaptureWindowA("", WS_VISIBLE Or WS_CHILD, 0, 0, 320, 240, Me.hWnd, 0)

'连接

SendMessage uwndc, WM_CAP_DRIVER_CONNECT, 0, 0

'Scale开

SendMessage uwndc, WM_CAP_SET_SCALE, True, 0

'显示刷新MS

SendMessage uwndc, WM_CAP_SET_PREVIEWRATE, 40, 0

'用予览方式显示(特殊需要,不显示予缆)

SendMessage uwndc, WM_CAP_SET_PREVIEW, True, 0

End Sub

上述代码就可以实现 但是要注意相应的控件是否存在 不存在的 你自己画出来


网站名称:vb.net外接摄像头 vb调用摄像头实现拍照
文章链接:http://cdkjz.cn/article/hhidsd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220