Visual Basic - MANEJO DE CAMARA WEB POR VB6

Life is soft - evento anual de software empresarial
 
Vista:

MANEJO DE CAMARA WEB POR VB6

Publicado por paber (1 intervención) el 28/01/2005 16:20:54
HOLA.
ESTOY NECESITANDO UN CONTROL O UNA FUNCION QUE ME PERMITA MANEJAR LA IMAGEN DE LA CAMARA WEB. TAMBIEN QUIERO PODER GRABARLA.
ADEMAS MI IDEA ES CONECTAR 10 CAMARAS WEB A UN PC Y PODER MONITOREAR VARIAS HABITACIONES A LA VEZ.

DESDE YA LES ESTOY MUY AGRADECIDO

PABER
MONTEVIDEO - URUGUAY
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:MANEJO DE CAMARA WEB POR VB6

Publicado por ignacio (15 intervenciones) el 16/11/2006 17:09:56
Yo estoy haciendo una aplicacion de vigilancia por captacion de movimiento por video. he estado navegando y encontre que la mejor forma de utilizar varias camaras en una pc es por medio de tcp ip o mediante una tarjeta pci controladora que desde ya son muy caras.
Para controlar una camara web usb utiliza las api de windows y visualizala en un picturebox.
codigo
Const WM_CAP As Integer = &H400

Const WM_CAP_DRIVER_CONNECT As Long = WM_CAP + 10
Const WM_CAP_DRIVER_DISCONNECT As Long = WM_CAP + 11
Const WM_CAP_EDIT_COPY As Long = WM_CAP + 30

Const WM_CAP_SET_PREVIEW As Long = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Long = WM_CAP + 52
Const WM_CAP_SET_SCALE As Long = WM_CAP + 53
Const WS_CHILD As Long = &H40000000
Const WS_VISIBLE As Long = &H10000000
Const SWP_NOMOVE As Long = &H2
Const SWP_NOSIZE As Integer = 1
Const SWP_NOZORDER As Integer = &H4
Const HWND_BOTTOM As Integer = 1

Dim iDevice As Long ' Current device ID
Dim hHwnd As Long ' Handle to preview window

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 SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Declare Function DestroyWindow Lib "user32" (ByVal hndw As Long) As Boolean

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 capGetDriverDescriptionA Lib "avicap32.dll" (ByVal wDriver As Long, _
ByVal lpszName As String, ByVal cbName As Long, ByVal lpszVer As String, _
ByVal cbVer As Long) As Boolean
Private Sub cmdSave_Click()
Dim bm As Image

'
' Copy image to clipboard
'

SendMessage hHwnd, WM_CAP_EDIT_COPY, 0, 0
ClosePreviewWindow

picCapture.Picture = Clipboard.GetData

CommonDialog1.CancelError = True
CommonDialog1.FileName = "Webcam1"
CommonDialog1.Filter = "Bitmap |*.bmp"

On Error GoTo NoSave
CommonDialog1.ShowSave

SavePicture picCapture.Image, CommonDialog1.FileName
NoSave:
cmdStop.Enabled = False
cmdSave.Enabled = False
cmdStart.Enabled = True
End Sub

Private Sub cmdStart_Click()
iDevice = lstDevices.ListIndex
OpenPreviewWindow
End Sub

Private Sub cmdStop_Click()
ClosePreviewWindow
cmdStop.Enabled = False
cmdSave.Enabled = False
cmdStart.Enabled = True
End Sub

Private Sub Form_Load()
LoadDeviceList

If lstDevices.ListCount > 0 Then
lstDevices.Selected(0) = True
Else
cmdStart.Enabled = False
lstDevices.AddItem ("No Device Available")
End If

cmdStop.Enabled = False
cmdSave.Enabled = False
End Sub

Private Sub LoadDeviceList()
Dim strName As String
Dim strVer As String
Dim iReturn As Boolean
Dim x As Long

x = 0
strName = Space(100)
strVer = Space(100)
'
' Load name of all avialable devices into the lstDevices
'

Do
'
' Get Driver name and version
'
iReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)

'
' If there was a device add device name to the list
'
If iReturn Then lstDevices.AddItem Trim$(strName)
x = x + 1
Loop Until iReturn = False
End Sub

Private Sub OpenPreviewWindow()
'
' Open Preview window in picturebox
'
hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0, 0, 640, _
480, picCapture.hwnd, 0)

'
' Connect to device
'
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
'
'Set the preview scale
'
SendMessage hHwnd, WM_CAP_SET_SCALE, True, 0

'
'Set the preview rate in milliseconds
'
SendMessage hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0

'
'Start previewing the image from the camera
'
SendMessage hHwnd, WM_CAP_SET_PREVIEW, True, 0

'
' Resize window to fit in picturebox
'
SetWindowPos hHwnd, HWND_BOTTOM, 0, 0, picCapture.ScaleWidth, picCapture.ScaleHeight, _
SWP_NOMOVE Or SWP_NOZORDER

cmdSave.Enabled = True
cmdStop.Enabled = True
cmdStart.Enabled = False
Else
'
' Error connecting to device close window
'
DestroyWindow hHwnd

cmdSave.Enabled = False
End If
End Sub

Private Sub ClosePreviewWindow()
'
' Disconnect from device
'
SendMessage hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0

'
' close window
'

DestroyWindow hHwnd
End Sub

Private Sub Form_Unload(Cancel As Integer)
If cmdStop.Enabled Then
ClosePreviewWindow
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar