Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to safely disconnect from a webcam ....

How to safely disconnect from a webcam ....

Scheduled Pinned Locked Moved Visual Basic
databasejsonhelptutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mohan G
    wrote on last edited by
    #1

    hello i have written an application to take pictures from a webcam (using APIs) and to save the picture into database.its working fine ... But when i try to close my application its NOT CLOSING PERFECTLY. some times it hangs too.(expect this problem the application is running smoothly) i am calling the "EndAppln" procedure in a closebutton_click and in the queryunload event of the main form please see the code below . . . . Any one please suggest any changes to be made to my application TO SAFELY CLOSE MY APPLICATION ?. '***** variables declared in a bas module Public Const CAP_START = &H400 Public Const CAP_GET_CAPSTREAMPTR = CAP_START + 1 Public Const CAP_SET_CALLBACK_ERROR = CAP_START + 2 Public Const CAP_SET_CALLBACK_STATUS = CAP_START + 3 Public Const CAP_SET_CALLBACK_YIELD = CAP_START + 4 Public Const CAP_SET_CALLBACK_FRAME = CAP_START + 5 Public Const CAP_SET_CALLBACK_VIDEOSTREAM = CAP_START + 6 Public Const CAP_SET_CALLBACK_WAVESTREAM = CAP_START + 7 Public Const CAP_DRIVER_CONNECT = CAP_START + 10 Public Const CAP_DRIVER_DISCONNECT = CAP_START + 11 '***** private sub EndAppln ' the below given are functions declared a module and called from the main form capSetCallbackOnError = SendMessage(lwnd,CAP_SET_CALLBACK_ERROR, 0,lpProc) capSetCallbackOnStatus = SendMessage(lwnd,CAP_SET_CALLBACK_STATUS,0,lpProc) capSetCallbackOnYield = SendMessage(lwnd,CAP_SET_CALLBACK_YIELD, 0,lpProc) capSetCallbackOnFrame = SendMessage(lwnd,CAP_SET_CALLBACK_FRAME,0,lpProc) capSetCallbackOnVideoStream = SendMessage(lwnd,CAP_SET_CALLBACK_VIDEOSTREAM, 0,lpProc) capSetCallbackOnWaveStream = SendMessage(lwnd,CAP_SET_CALLBACK_WAVESTREAM, 0,lpProc) capSetCallbackOnCapControl = SendMessage(lwnd,CAP_SET_CALLBACK_CAPCONTROL, 0,lpProc) ''''' end of the callback DoEvents capDriverDisconnect (mywdc) capCaptureStop (mywdc) DestroyWindow (mywdc) ' the API declared in the bas module UnLoad Me End End Sub Thanks in advance Mohan G Mohan G

    D 1 Reply Last reply
    0
    • M Mohan G

      hello i have written an application to take pictures from a webcam (using APIs) and to save the picture into database.its working fine ... But when i try to close my application its NOT CLOSING PERFECTLY. some times it hangs too.(expect this problem the application is running smoothly) i am calling the "EndAppln" procedure in a closebutton_click and in the queryunload event of the main form please see the code below . . . . Any one please suggest any changes to be made to my application TO SAFELY CLOSE MY APPLICATION ?. '***** variables declared in a bas module Public Const CAP_START = &H400 Public Const CAP_GET_CAPSTREAMPTR = CAP_START + 1 Public Const CAP_SET_CALLBACK_ERROR = CAP_START + 2 Public Const CAP_SET_CALLBACK_STATUS = CAP_START + 3 Public Const CAP_SET_CALLBACK_YIELD = CAP_START + 4 Public Const CAP_SET_CALLBACK_FRAME = CAP_START + 5 Public Const CAP_SET_CALLBACK_VIDEOSTREAM = CAP_START + 6 Public Const CAP_SET_CALLBACK_WAVESTREAM = CAP_START + 7 Public Const CAP_DRIVER_CONNECT = CAP_START + 10 Public Const CAP_DRIVER_DISCONNECT = CAP_START + 11 '***** private sub EndAppln ' the below given are functions declared a module and called from the main form capSetCallbackOnError = SendMessage(lwnd,CAP_SET_CALLBACK_ERROR, 0,lpProc) capSetCallbackOnStatus = SendMessage(lwnd,CAP_SET_CALLBACK_STATUS,0,lpProc) capSetCallbackOnYield = SendMessage(lwnd,CAP_SET_CALLBACK_YIELD, 0,lpProc) capSetCallbackOnFrame = SendMessage(lwnd,CAP_SET_CALLBACK_FRAME,0,lpProc) capSetCallbackOnVideoStream = SendMessage(lwnd,CAP_SET_CALLBACK_VIDEOSTREAM, 0,lpProc) capSetCallbackOnWaveStream = SendMessage(lwnd,CAP_SET_CALLBACK_WAVESTREAM, 0,lpProc) capSetCallbackOnCapControl = SendMessage(lwnd,CAP_SET_CALLBACK_CAPCONTROL, 0,lpProc) ''''' end of the callback DoEvents capDriverDisconnect (mywdc) capCaptureStop (mywdc) DestroyWindow (mywdc) ' the API declared in the bas module UnLoad Me End End Sub Thanks in advance Mohan G Mohan G

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The problem might not be in your application at all. It's possible that it's in the API for the webcam. Usually, something like this happens because not all resources and handles are freed before you quit. Check to make absolutely sure you free all the resources you allocate and close any handles you have and make sure your shutting down the API correctly so it can free up any resources that it has allocated. After doing that you'd have to get ahold of developer support for the API to find a solution. Hey! Maybe you've found a bug! :) RageInTheMachine9532

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        The problem might not be in your application at all. It's possible that it's in the API for the webcam. Usually, something like this happens because not all resources and handles are freed before you quit. Check to make absolutely sure you free all the resources you allocate and close any handles you have and make sure your shutting down the API correctly so it can free up any resources that it has allocated. After doing that you'd have to get ahold of developer support for the API to find a solution. Hey! Maybe you've found a bug! :) RageInTheMachine9532

        M Offline
        M Offline
        Mohan G
        wrote on last edited by
        #3

        thank you rage i am puzzled here, how to debug my application exactly. will you please help me to fix this problem.i will send the whole application . ok. Mohan G

        D 1 Reply Last reply
        0
        • M Mohan G

          thank you rage i am puzzled here, how to debug my application exactly. will you please help me to fix this problem.i will send the whole application . ok. Mohan G

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          It's just a thorough code review. If you can eliminate everything YOUR doing as a possible cause, then the cause is in the API your using. RageInTheMachine9532

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            It's just a thorough code review. If you can eliminate everything YOUR doing as a possible cause, then the cause is in the API your using. RageInTheMachine9532

            M Offline
            M Offline
            Mohan G
            wrote on last edited by
            #5

            thank you rage i have gone through my code. I am not good in working with API.This is a simple application (i mean less no. of lines of code).can you please check my code.(this is very urgent for me to fix this problem).so i look forward for an helping hand like you. Mohan G

            D 1 Reply Last reply
            0
            • M Mohan G

              thank you rage i have gone through my code. I am not good in working with API.This is a simple application (i mean less no. of lines of code).can you please check my code.(this is very urgent for me to fix this problem).so i look forward for an helping hand like you. Mohan G

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Send it to my email address. I'm also going to need the address to pick up a copy of the SDK your using. RageInTheMachine9532

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups