VB6 Frame capture
17 year
Hello, I'd like to use a VisualBasic6 Pipe extension to capture the video stream from the webcam and store each frame in separate individual files
(or a large array).  Any ideas on how to do this?  How does the VB program
know when a new frame is sent? Does it get called for each frame?

Roborealm is a fantastic program, great work!
Found it!
17 year
Ok, I figured out how to do this myself, it's realy quite easy.
VB Pipes
17 year
When using the VB Pipe extension your program (regardless of language) is called for each image frame being processed. However, if you are using the API to grab images this is not the case. This is why the Extensions can slow the processing down.

You may also want to just use the Image Write module under Loading/Saving to achieve the same result if you just want to save the images to disk.

Can you include your realization in this forum to help others that may be confused by the same issues?

Anonymous 17 year
Thanks for the reply Steven.  Processing speed is not an issue so far, the VB pipe extension method works just fine.  If anyone is interested here's the VB6 code (written quick n dirty), just delete or rem out the existing code in the "Process" Sub and add this:

'^^^^^^^^^^^^^^^^^^begin paste^^^^^^^^^^^^^^^^^^^^
Dim xbegin As Long, ybegin As Long, yend As Long
Dim j As Long, i As Long, a As Long
Dim ycount As Long, xcount As Long, pixbegin As Long
Static imarray() As Long

Static framenum As Long

'******************user set parameters********************
'set to same size as webcam HxV resolution
Const xsizecam = 160   'H
Const ysizecam = 120   'V
'Region of Interest SubWindow HxV change size here, must be <= to cam HxV
Const xsize = 40       'H
Const ysize = 40       'V
'number of frames to store in array, change here must be <= # of picture boxes on PipeServer form
Const framestocapture = 30
'capture `framestocapture` #of frames
If framenum >= framestocapture Then
    framenum = 0
   ''' Exit Sub
End If
framenum = framenum + 1

If framenum = 1 Then
    ReDim imarray(1 To 60, 1 To xsize, 1 To ysize)              'framenum, H, V
End If

For a = 1 To framestocapture
    With PipeServer.Picture1(a - 1)
    .Width = (.Width / .ScaleWidth) * xsize
    .Height = (.Height / .ScaleHeight) * ysize
    End With
Next a

xbegin = (xsizecam / 2) - (xsize / 2)
ybegin = (ysizecam / 2) - (ysize / 2)
yend = ybegin + ysize

'copy frame to array
ycount = 1
For i = ybegin To yend - 1                                  'rows, V
    xcount = 1
    pixbegin = ((i * xsizecam * 3) + xbegin * 3)            'first pixel memory position
    For j = pixbegin To pixbegin + ((xsize - 1) * 3) Step 3 'columns H
        imarray(framenum, xcount, ycount) = imagePixels(j)
        xcount = xcount + 1
    Next j
    ycount = ycount + 1
Next i

'copy image in position #n from imarray() to picture(n)
a = framenum
For i = 1 To ysize
    For j = 1 To xsize
        PipeServer.Picture1(a - 1).PSet (j, i), RGB(imarray(a, j, i), imarray(a, j, i), _
        imarray(a, j, i))
    Next j
Next i
'^^^^^^^^^^^^^^^end paste^^^^^^^^^^^^^^^^^^^^^^^

Next add this line below the Dim statements close to the top of the "Main" Sub:
'^^^^^^^^^^^^^^^^^^^^^begin paste^^^^^^^^^^^^^^
PipeServer.Show  'show form
'^^^^^^^^^^^^^^^^end paste^^^^^^^^^^^^^^^^^^^^^

Next add a picturebox control to the PipeServer form.  Go to the picturebox's property window and set ScaleMode to "Pixels"  Then
copy the pictuerebox and paste it ("Yes" when asked if you want to create a control array) until you have 30 picture boxes on the form.

RoboRealm is powerful and easy to work with, a fine piece of work, complments to the author(s)!


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index