Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1470
  • Last Modified:

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

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()
 Me.VideoCap1.Stop
   
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
'ScanControl.ShowScanPreferences


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



 Me.VideoCap1.Start

'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
ScanControl.ShowSelectScanner
'VideoCap1.Devices
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~
0
Sam Cohen
Asked:
Sam Cohen
  • 4
  • 4
3 Solutions
 
SidFishesCommented:
i'm not familiar with that activex

but ezvidcap works nice

check out
 http://www.experts-exchange.com/Databases/MS_Access/Q_21396005.html

0
 
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
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!!!
0
 
SidFishesCommented:
this is much simpler than what you were trying

...as 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 this...you 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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
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

0
 
SidFishesCommented:
you can't -stop- the webcam...it's always on...you could hide it if you want...but it isn't capturing anything...it'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

vid.ShowDlgVideoSource

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

0
 
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
Thanks...It works great with my Sony camcorder as well!!!
0
 
Sam CohenConsultant to Digital/DeveloperAuthor Commented:
Youre the best Sid!!!!
0
 
SidFishesCommented:
glad to help
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now