A very good program in C to use multiple webcams:
Would be able to translate this C program in GB32?
Salut à tous !
Hello dear friends of GFA 32!
I always try to use a small directshow library to access the advanced feature webcams from escapi.dll.
The start of this little program works, it recognizes the camera or cameras.
But then I can not make it display the images!
If someone had an idea, it would be welcome!
below the program and attached the escapi.dll
which comes from
sol.gfxile.net/escapi/index.htmlRegards
'-----------------------------------------------------------------------
'Programme d'utilisation de escapi.dll
'pour passer par directshow avec les caméras ou webcam
'et accéder à une définition supérieure à 640 x480 par exemple 960x720
'que ne permet pas avicap.dll
'jrs février 2013
LoadForm frm1
'vers escapi
initialisation
//deviceno = 0 'attention la première =0 !
lbl1.Caption = "OK!" + "Valeur de initCOM=" + Str$( initCOM(p6%))
lbl2.Caption = "Version=" + Str$(ESCAPIDLLVersion(p1%))
lbl3.Caption = "nombre de caméras=" + Str$(countCaptureDevices(p2%))
Global Dim nomdecamera$(10)
If countCaptureDevices(p2%) > 0
For deviceno = 0 To countCaptureDevices(p2%) - 1
If deviceno = 0
getCaptureDeviceName(deviceno, namebuffer1, bufferlength)
nomdecamera$(deviceno) = CharPeek(*namebuffer1)
lbl4.Caption = "Caméra n°" + Str$(deviceno) + " : " + CharPeek(*namebuffer1)
EndIf
If deviceno = 1
getCaptureDeviceName(deviceno, namebuffer2, bufferlength)
nomdecamera$(deviceno) = CharPeek(*namebuffer2)
lbl5.Caption = "Caméra n°" + Str$(deviceno) + " : " + CharPeek(*namebuffer2)
EndIf
Next deviceno
EndIf
'choix de la caméra à capturer
deviceno = 0
Global i% = 0 'nombre de tours
frm1.Caption = "Visualisation de " + nomdecamera$(deviceno)
//Local scp:SimpleCapParams = New SimpleCapParams
Dim scp As SimpleCapParams
'taille de l'image
Global width = 320, height = 240
Global imaje = mAlloc(width * height * 4) 'réservation espace pour l'image (pourquoi x4?)
'les valeurs des variables de type scp (SimpleCapParams)
scp.mTargetBuf = imaje
scp.mWidth = width
scp.mHeight = height
' A PixMap for captured data...
//pix:TPixmap = CreatePixmap (width, height, PF_BGRA8888)
//à tester: a% = GetDIBits(_DC(), bmp&, 0, height&, 0, pinfo%, DIB_RGB_COLORS)
Global h%, p As Picture
'p = mAlloc(width * height * 4)
Set p = CreatePicture(h, 1) ' h correspond au handle et 1 à Owner
' Start capture process...
//avec la déclaration de type scp ?
If initCapture(deviceno, *scp) = 0
lbl6.Caption = "Failed to initialise capture device!"
Stop
End
Else
lbl6.Caption = "Capture vidéo démarrée !"
EndIf
Repeat
doCapture(deviceno)
Repeat
If InKey$ <> ""
quit% = 1
EndIf
Until isCaptureDone(deviceno)
'copie du contenu de scp.mTargetBuf dans l'image p
MemCpy V:p, V:scp.mTargetBuf, SizeOf(scp.mTargetBuf)
'ici afficher le contenu du bloc commençant en *imaje
' PaintPicture p, 200, 0
'img1.Picture = p
lbl7.Caption = Str$(i%)
i%++
Until quit% = 1
' Stop capture process...
deinitCapture(deviceno)
End
'---------------Fin du pgm------------------------------
Do
Sleep
Loop Until IsNothing(Me)
Sub initialisation
Global quit% = 0
'déclaration de l'image vidéo
Type SimpleCapParams
mTargetBuf As Integer ' ;(*mTargetBuf.i
Must be at least mWidth * mHeight * SizeOf(int) of size!
mWidth As Long
mHeight As Long
End Type
Global p1%, p2%, p3%, p4%, p5%, p6%, p7%, p8% 'pas forcément utile ...
Global deviceno As Long, namebuffer As Integer, bufferlength As Long, namebuffer1 As Integer, namebuffer2 As Integer
'pour 2 caméras
namebuffer1 = mAlloc(1000)
namebuffer2 = mAlloc(1000)
namebuffer = mAlloc(1000) 'à libérer en fin de prgm
bufferlength = 1000
Declare Function ESCAPIDLLVersion CDecl Lib "escapi.dll" (ByVal p1%) As Long
Declare Function countCaptureDevices CDecl Lib "escapi.dll" (ByVal p2%) As Long
Declare Function deinitCapture CDecl Lib "escapi.dll" (ByVal deviceno) As Long
Declare Function doCapture CDecl Lib "escapi.dll" (ByVal deviceno) As Long
Declare Function getCaptureDeviceName CDecl Lib "escapi.dll" (ByVal deviceno, ByRef namebuffer, ByVal bufferlength) As Long
Declare Function initCOM CDecl Lib "escapi.dll" (ByVal p6%) As Long
Declare Function initCapture CDecl Lib "escapi.dll" (ByVal deviceno As Long, ByVal SimpleCapParams As Integer) As Long
Declare Function isCaptureDone CDecl Lib "escapi.dll" (ByVal p8%) As Long
End Sub
Sub frm1_Close(Cancel?)
' Stop capture process...
deinitCapture(deviceno)
End
'libération des blocs mémoire
~mFree(*namebuffer)
~mFree(*namebuffer1)
FreeDll "escapi.dll"
EndSub
'-----------------------------------------------------------------------