请教或讨论:在窗体中捕获摄像头、扫描仪图像的思路
老师好:
在窗体中有什么办法可以捕获到摄像头、数码相机、扫描仪采集到的图像(尚未保存的)。提供一下思路好吗。谢谢。
或者指导我一下,有什么简洁的方法采集人员照片?(我目前是将每个人的照片一张一张的扫描进计算机,存储成为文件,再进入学生管理应用程序,找到每名学员,再将每名学员的照片一一对应的找到添加。工作量太大。有什么可以直接采集图像或者便捷的方法吗?)
介绍一下您的经验好吗?
谢谢您的指导
问题点数:50、回复次数:3Top
1 楼napsoft(乡下人)回复于 2006-02-13 16:22:14 得分 0
倒。看起来怎么感觉是学校,学生写给考师的信~~
一、数码相机采集。
二、扫描仪Top
2 楼sx_lxh(路漫漫)回复于 2006-02-20 00:37:40 得分 50
摄像头即时截图程序
想要让外面的摄像头,实现每隔一段时间就截取一幅图,程序可以在后台运行,电脑可以正常使用.我利用API只做到了需要介媒才可以截到图,不可以把窗口最小化,不然只可以截到黑屏.以下是我的代码:
Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal strWindowName As String, ByVal dwStyle As Int32, ByVal x As Int32, ByVal y As Int32, ByVal width As Int32, ByVal height As Int32, ByVal hwdParent As IntPtr, ByVal nID As Int32) As IntPtr
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Long) As Int32
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As IntPtr) As IntPtr
Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As IntPtr, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Int32) As Boolean
Private Const WM_USER = &H400
Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000
Private Const WM_CAP_START = WM_USER
Private Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Private Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
Private Const WM_CAP_SAVEDIB = WM_CAP_START + 25
Private Const WM_CAP_SET_OVERLAY = WM_CAP_START + 51
Private Const WM_CAP_SET_PREVIEW = WM_CAP_START + 50
Private Const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6
Private Const WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2
Private Const WM_CAP_SET_CALLBACK_STATUSA = WM_CAP_START + 3
Private Const WM_CAP_SET_SCALE = WM_CAP_START + 53
Private Const WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52
Dim blnRunning As Boolean = False
Dim hWndC As IntPtr
Dim mCaptureObject As Object
Public Sub New()
'
End Sub
Public Sub New(ByVal m_CaptureObject As Object)
mCaptureObject = m_CaptureObject
End Sub
Public Property CaptureObject() As Object
Get
Return mCaptureObject
End Get
Set(ByVal Value As Object)
mCaptureObject = Value
End Set
End Property
'开始显示图像
Public Function Start() As Boolean
If blnRunning = True Then
Return True
Exit Function
Else
blnRunning = True
End If
Dim lpszName As String = Space(100)
hWndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, 0, 0, 176, 144, mCaptureObject.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) '设置收回状态
If SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0) = 0 Then '驱动程序连接
blnRunning = False''''''''''''''
Return True'''''''''''''''''''''???????????????????
Exit Function'''''''''''''''''''
End If
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_DLG_VIDEOFORMAT, 0, 0)
'SendMessage(hWndC, WM_CAP_SET_VIDEOFORMAT, 0, 0)
'SendMessage(hWndC, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)
SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0) '设置预览
End If
End Function
'停止显示
Public Sub Stoped()
If blnRunning = True Then
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0)
End If
blnRunning = False
End Sub
'抓图
Public Sub GrabImage()
Dim map As Bitmap
Dim dc1 As IntPtr = GetDC(mCaptureObject.Handle)
Dim g As Graphics = Graphics.FromHdc(dc1)
map = New Bitmap(176, 144, g)
Dim g1 As Graphics = Graphics.FromImage(map)
Dim dc2 As IntPtr = g1.GetHdc
BitBlt(dc2, 0, 0, 176, 144, g.GetHdc(), 0, 0, 13369376)
g1.ReleaseHdc(dc2)
Try
Dim callback As System.Drawing.Image.GetThumbnailImageAbort
map.GetThumbnailImage(176, 144, callback, IntPtr.Zero).Save("E:\" & Format(Now, "yyMMdd HHmmss") & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
Catch
End Try
map.Dispose()
GC.Collect()
End Sub
Top
3 楼sx_lxh(路漫漫)回复于 2006-02-20 00:39:00 得分 0
可以参考一下。Top




