IMAGENS DE MAIS DE UMA WEB CAM

ALEGON 20/01/2011 23:10:11
#362907
Estou com um grande problema. Preciso capturar imagens de 2 webcam's. Já tentei de tudo mas não funciona. Hoje eu uso a DLL avicap32.dll e funciona com uma câmera conforme o exemplo abaixo. Esse código eu peguei na internet, se alguém puder me ajudar ficarei grato. PS : VB NET.

Const WM_CAP As Short = &H400S

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

Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const SWP_NOMOVE As Short = &H2S
Const SWP_NOSIZE As Short = 1
Const SWP_NOZORDER As Short = &H4S
Const HWND_BOTTOM As Short = 1

Dim NrDispositivo As Integer = 0 [ô]
Dim hHwnd As Integer [ô] manipulador da janela do visualizador

Declare Function SendMessage Lib [Ô]user32[Ô] Alias [Ô]SendMessageA[Ô] _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
ByVal lParam As Object) As Integer

Declare Function SetWindowPos Lib [Ô]user32[Ô] Alias [Ô]SetWindowPos[Ô] (ByVal hwnd As Integer, _
ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, _
ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer

Declare Function DestroyWindow Lib [Ô]user32[Ô] (ByVal hndw As Integer) As Boolean


Declare Function capCreateCaptureWindowA Lib [Ô]avicap32.dll[Ô] _
(ByVal lpszWindowName As String, ByVal dwStyle As Integer, _
ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Short, ByVal hWndParent As Integer, _
ByVal nID As Integer) As Integer

Declare Function capGetDriverDescriptionA Lib [Ô]avicap32.dll[Ô] (ByVal wDriver As Short, _
ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, _
ByVal cbVer As Integer) As Boolean

Private Sub AbreVisualizacaoImagem()
Dim iHeight As Integer = PicIdent.Height
Dim iWidth As Integer = PicIdent.Width
Dim NrDispositivo AS Integer = 0
[ô]
[ô] Abre a janela de visualização no picturebox
hHwnd = capCreateCaptureWindowA(NrDispositivo, WS_VISIBLE Or WS_CHILD, 0, 0, 640, 480, PicIdent.Handle.ToInt32, 0)

[ô]
[ô] Conecta com o drive
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, NrDispositivo, 0) Then
[ô]
[ô]Define a escala de previsão
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)

[ô]
[ô]Define a taxa de visualização em milisegundos
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)

[ô]
[ô]Iniciar a visualização da imagem a partir da camara
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)

[ô]
[ô] Redimensiona a janela para se ajustar no picturebox
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, PicIdent.Width, PicIdent.Height, _
SWP_NOMOVE Or SWP_NOZORDER)

Else
[ô]
[ô] Erro de conexão fecha a janela de dispostivos
DestroyWindow(hHwnd)

MsgBox([Ô]Erro ao tentar abrir a imagem da WebCam[Ô])
End If
End Sub
ASHKATCHUP 03/02/2011 17:00:06
#364270
Crie dois picture box?
KURTGU 03/02/2011 17:20:14
#364275
eu tambem tive esse problema com esse sistema de mais de uma webcam mais o avicap32 nao deixa ligar as duas web cam por eles entao o que eu fiz uma picture box acessar pelo avicap32 e outra usei um exemplo daqui captura de web cam via directshow ai funciono....tenta ai.....cara procura o exemplo ta na pagina principal...... com ele voce pode ultilizar duas web cam mais agora to tirando o avicap32 e usando so o directshow.....
Tópico encerrado , respostas não são mais permitidas