We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

how to capture picture using webcam in vb6.0

Last post 04-28-2008 5:06 AM by tanghengs. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-15-2007 7:16 AM

    • menka
    • Not Ranked
    • Joined on 03-15-2007
    • New Member
    • Points 15

    how to capture picture using webcam in vb6.0

    hello sir

    i have a programm in vb6.0.In which i want to capture the employee picture and add them to aspecific location not in default location.

    how can i do it '

    plz help

     

    • Post Points: 10
  • 03-19-2007 12:22 PM In reply to

    Re: how to capture picture using webcam in vb6.0

    Write the following code in a module

    '******************* module code **************

    Public Const WS_CHILD As Long = &H40000000
    Public Const WS_VISIBLE As Long = &H10000000


    Public Const WM_USER As Long = &H400
    Public Const WM_CAP_START As Long = WM_USER


    Public Const WM_CAP_DRIVER_CONNECT As Long = WM_CAP_START + 10
    Public Const WM_CAP_DRIVER_DISCONNECT As Long = WM_CAP_START + 11
    Public Const WM_CAP_SET_PREVIEW As Long = WM_CAP_START + 50
    Public Const WM_CAP_SET_PREVIEWRATE As Long = WM_CAP_START + 52
    Public Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_CAP_START + 41
    Public Const WM_CAP_FILE_SAVEDIB As Long = WM_CAP_START + 25






    Public Declare Function capCreateCaptureWindow _
        Lib "avicap32.dll" Alias "capCreateCaptureWindowA" _
             (ByVal lpszWindowName As String, ByVal dwStyle As Long _
            , ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long _
            , ByVal nHeight As Long, ByVal hwndParent As Long _
            , ByVal nID As Long) As Long






    Public Declare Function SendMessage Lib "user32" _
        Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long _
            , ByVal wParam As Long, ByRef lParam As Any) As Long


    '************* end of module code ******************

    Add the following controls in a form

    1. A picture box with name "PicWebCam"

    2. A commondialog control with name "CDialog"

    3. Add 4 command buttons with name "cmd1","cmd2,"cmd3","cmd4"

    then paste the following code

    '************************** Code **************

    Dim hCap As Long
    Private Sub cmd4_Click()
    Dim sFileName As String
        Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(False), 0&)
        With CDialog
            .CancelError = True
            .Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt
            .Filter = "Bitmap Picture(*.bmp)|*.bmp|JPEG Picture(*.jpg)|*.jpg|All Files|*.*"
            .ShowSave
            sFileName = .FileName









        End With
        Call SendMessage(hCap, WM_CAP_FILE_SAVEDIB, 0&, ByVal CStr(sFileName))
    DoFinally:
        Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(True), 0&)
    End Sub




    Private Sub Cmd3_Click()
    Dim temp As Long
    temp = SendMessage(hCap, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
    End Sub


    Private Sub Cmd1_Click()
    hCap = capCreateCaptureWindow("Take a Camera Shot", WS_CHILD Or WS_VISIBLE, 0, 0, PicWebCam.Width, PicWebCam.Height, PicWebCam.hWnd, 0)
        If hCap <> 0 Then
            Call SendMessage(hCap, WM_CAP_DRIVER_CONNECT, 0, 0)
            Call SendMessage(hCap, WM_CAP_SET_PREVIEWRATE, 66, 0&)
            Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(True), 0&)
        End If
    End Sub






    Private Sub Cmd2_Click()
    Dim temp As Long
    temp = SendMessage(hCap, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
    End Sub


    Private Sub Form_Load()
    cmd1.Caption = "Start &Cam"
    cmd2.Caption = "&Format Cam"
    cmd3.Caption = "&Close Cam"
    cmd4.Caption = "&Save Image"
    End Sub
    '**************** Code end ************************





    Enjoy

    Akhtar

    Sr. App Engnr

    Akhtar
    (Software Engnr )
    • Post Points: 20
  • 03-23-2007 3:28 AM In reply to

    • menka
    • Not Ranked
    • Joined on 03-15-2007
    • New Member
    • Points 15

    Re: how to capture picture using webcam in vb6.0

    hello sir

    well thanx for sending me coding it works fine. well i want to do more, can i capture the selected window instead of whole if yes then can u send me the code plz

    well thanx again

    monika

     

    • Post Points: 5
  • 05-26-2007 5:09 PM In reply to

    • pawzasys
    • Not Ranked
    • Joined on 05-26-2007
    • India
    • New Member
    • Points 5

    Re: how to capture picture using webcam in vb6.0

    Thank you, Hi how are you. But I want to capture picture from digital camera. tell me the code for this please.....
    • Post Points: 5
  • 04-28-2008 5:06 AM In reply to

    • tanghengs
    • Not Ranked
    • Joined on 04-28-2008
    • Cambodia
    • New Member
    • Points 5

    Re: how to capture picture using webcam in vb6.0

    Hello Akhtar Hussain!

     Hope you are fine!

     
    Could you please help me for capture picture from webcam and than save that picture into SQL server database?

     
    I hope to hearing from you soon.

     

    Thanks so much!
     Smiley Face

    • Post Points: 5
Page 1 of 1 (5 items)