webcam to capture images and save to file, URGENT!!

Posted on 2005-04-27
Last Modified: 2008-01-09
I have a web cam im using to show live video in my MS access form, but i want to beable to snap the image and save to file.(sort of like the windows movie maker works , in XP)

so far im using VideoCapFree activex to capture live video.... but how can i take snap shots and save it to .jpg, .bmp.etc?
heres my code:


Option Compare Database

Private Sub Command1_Click()
End Sub

Private Sub Command16_Click()

End Sub

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim Bx, Hwn, Scnav As Boolean
Scnav = ScanControl.ScannerAvailable
Select Case Scnav
Case True

'check for file type being used

DoCmd.GoToControl "piclocation"
If InStr(piclocation.Text, ".bmp") Then
VideoPreview1.FileType = BMP_Bitmap
ElseIf InStr(piclocation.Text, ".awa") Then
VideoPreview1.FileType = AWD_MicrosoftFax
ElseIf InStr(piclocation.Text, ".tif") Then
VideoPreview1.FileType = TIFF
End If

'Uncomment the next line to give user scan preferences

DoCmd.GoToControl "piclocation"
ScanControl.Image = piclocation.Text


'names the file in this case I named it by combining ID and Last Name
Me.Imagepath = Me.NameID & Me.LastName & ".bmp"
Exit Sub

Case False
MsgBox "Scanner is Busy!" + vbCrLf + "Try Again Later.", vbInformation, "Scanner: Busy!"
Exit Sub

End Select
Err_Command2_Click: MsgBox Err.Description

End Sub

Private Sub Command3_Click()
'comment out the next line to select the default cam/scanner
End Sub

please let me know how to add a save image feature..
or if you might know of a better way please let me know!!

I reply quickly~
Question by:Sam Cohen
    LVL 36

    Accepted Solution

    i'm not familiar with that activex

    but ezvidcap works nice

    check out

    LVL 8

    Author Comment

    by:Sam Cohen
    Hey Sid, Can you help me out with the code, im a 2 year Beginner to vba
    Basically im trying to capture video then click a button to snap frames, and once snapped, save to file with a custom filename..

    Thanks in Advance!!!
    LVL 36

    Assisted Solution

    this is much simpler than what you were trying in the link i posted

    Get the file from shrinkwrapvb
    unzip file

    open a new form

    goto the code page, tools > references , register the ocx's (the rest of the files in the zip are inrelevant unless you have VB)

    place a vbVidC60.ezVidCap Control on your form (from the More Controls button on your tool bar)

    Name the control Vid

    create a button called capture

    then in the on click event

    Private Sub Capture_Click()
    Me.Vid.SaveDIB "C:\test.dib"

    strSQl = "Insert Into MyTable (ID, CapPath), values (me.SomeID, "C:\test.dib")
    execute...blah blah
    End Sub

    how you do this depends on whether you are are using DAO or ADO

    if you are going to do multiple captures from a stream....
    set up something to sequentially name the file after each click

    you could have multicapture and autorename

    Public FilePad
    Private Sub Capture_Click()
    If IsNull(filePad) Then
       filePad = 1
    End If
    Me.Vid.SaveDIB "C:\Pic_" & filePad & ".dib"
    filePad = filePad + 1
    End Sub

    to capture a single frame

    Private Sub Capture_Click()

    CapName = inputbox ("Please Enter CapName")

    Me.Vid.SaveDIB "C:\ & CapName & ".dib"
    strSQl = "Insert Into MyTable (ID, CapPath), values (me.SomeID, "C:\test.dib")
    execute...blah blah
    end sub

    you could also -prename- the file by creating a text box on your form which the user would fill out prior to clicking the capture button...this way you can capture a file from an active stream...a static stream (say an employee photo from a webcam) doesn't need can use the input box method  

    you'll note that the file is a dib format 9device independent bitmap...but access can deal with these no problem

    if you need some help with the specific code to insert let me know if you are using DAO or ADO
    LVL 8

    Author Comment

    by:Sam Cohen
    Ok i see!
    basic i have the filename saving as: ImagePath= CapName & ".bmp"
    so therefore i will execute sql: insert into MyTable (imagePath) blah blah
    but how do stop the camera from running onload?
    I want to be able to start and stop at any time..

    when i loaded the activex on to the form and viewed it, it automatically as for the device...-- i dont want this to happen , i want beable to choose my device in the form , with other functions

    LVL 36

    Assisted Solution

    you can't -stop- the's always could hide it if you want...but it isn't capturing's just in preview mode.

    if you read the exVidCap.doc that came with the ocx you will see all of the different methods and properties of the ocx

    amoung other things you'll see this

    ShowDlgVideoSource returns: Boolean
    <takes no parameters>

    Displays a dialog box in which the user can control the video source. The Video Source dialog box might contain controls that select input sources; alter the hue, contrast, brightness of the image; and modify the video quality before digitizing the images into the frame buffer.

    to use it all you would do is  create a button with a click event


    and that will pop up a dialog box to select your source

    there's a lot of other settings you can play around with as well

    LVL 8

    Author Comment

    by:Sam Cohen
    Thanks...It works great with my Sony camcorder as well!!!
    LVL 8

    Author Comment

    by:Sam Cohen
    Youre the best Sid!!!!
    LVL 36

    Expert Comment

    glad to help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now