locked
Capturing image from webcam RRS feed

  • Question

  • Before I begin, I would like to say that it would help greatly if any solution has example code in vb.net explaining it's use... I need to show video in a picturebox, and when a button is pressed, capture the frame. I am making a desktop qr reader. I have the qr reader completed and working. my issue is my camera now. I would prefer something that actually works, and doesn't have severe memory leak issues, and doesn't throw an exception after it's first or second use. Would AviCap32 or Direct Show be better for what I want? Which would capture the image fastest, without causing exceptions? I tried using an open source solution called webcam_capture.dll, and it worked at first, but now I am getting an exception that I dont know how to fix.

    I'm assuming this goes in vbGeneral, and not the Interop and Upgrade. Most examples i have seen, use interop, so I wasn't sure.


    I would prefer not to use WIA. I have attempted it, and it doesn't work quite right on my computer, and this application will be distributed.
    • Edited by Slysoft Tuesday, May 1, 2012 9:31 AM
    Tuesday, May 1, 2012 9:19 AM

Answers

  • It runs the first time, but when you attempt to run the application again, it pops up asking you to pick a webcam. when you do, it closes the popup, but loads nothing. It's like EVERY example i've found doesn't release the webcam properly or something. I dont know.
    • Proposed as answer by jjfund Thursday, May 10, 2012 7:55 PM
    • Unproposed as answer by jjfund Thursday, May 10, 2012 7:55 PM
    • Proposed as answer by jjfund Thursday, May 10, 2012 7:59 PM
    • Marked as answer by Slysoft Friday, May 11, 2012 10:50 AM
    Monday, May 7, 2012 11:48 AM

All replies

    • Proposed as answer by Mark Liu-lxf Wednesday, May 2, 2012 3:47 AM
    • Marked as answer by Slysoft Wednesday, May 2, 2012 4:11 AM
    • Unmarked as answer by Slysoft Wednesday, May 2, 2012 7:30 PM
    Tuesday, May 1, 2012 10:07 AM
  • .Net has no possibilities to capture an video from a webcam so you have to do it with interop.

    http://www.vb-tips.com/Webcam.aspx


    Success
    Cor

    • Proposed as answer by Mark Liu-lxf Wednesday, May 2, 2012 3:46 AM
    • Unproposed as answer by Slysoft Wednesday, May 2, 2012 4:11 AM
    Tuesday, May 1, 2012 10:14 AM
  • I'll take a look. Thanks.
    Tuesday, May 1, 2012 10:33 AM
  • Alright. Thanks for the help. I was trying to make it 100% Managed code. oh well.
    Tuesday, May 1, 2012 10:33 AM
  • Well. unfortunately, It will need to read off of the desktop webcam, and it wont just be for my computer. Other's will be using it also. So it will automatically need to detect the webcam, and use it..
    Tuesday, May 1, 2012 12:44 PM
  • OK,

    I hope this helps:

    http://www.vb-helper.com/howto_net_video_capture.html

    regards Ellen


    Ich benutze/ I'm using VB2008 & VB2010

    Tuesday, May 1, 2012 1:00 PM
  • Thanks Ellen. That allowed me to capture the image, but if I try to run the application again, it pops up with a frozen picture from the previous time it ran. It can't access the camera. What would be the easiest/best way to dispose or release the camera, that way I can use it next time I run the application. One of my issues, is that the camera still seems to work for other applications....
    Wednesday, May 2, 2012 7:32 PM
  • I built an application similar to this using the code I found after a quick google search.
    I found this YouTube video:

    http://www.youtube.com/watch?v=-dMQNlrkGWQ

    It does continuously throw PInvoke/StackImbalance errors, but I guess, if someone can find a way to solve them, this would work great.

    For a download of this project, I noticed a link in the description.

    Hope it helps (at least somewhat!)

    Sincerely yours,
    - bilde2910



    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

    Wednesday, May 2, 2012 7:44 PM
  • Thanks for the suggestion, but when I tried it, it did the same thing. it loaded the list of cameras correctly, but when I tried to click the start preview button, it popped up with a window asking me to pick a video device. I did, and it did nothing at all. It doesn't freeze, but it doesn't actually seem to access the camera. I have tried this on 2 different computers. they both do the same thing. can anyone help?
    Wednesday, May 2, 2012 9:00 PM
  • I have found a couple references to the same thing happening to others. It appears to be a windows 7 issue. I have yet to find a solution... It starts the first time, but wont run again until you restart the computer... Any suggestions?

    Wednesday, May 2, 2012 10:51 PM
  • So, the solution provide by members works for other OS except win7?

    No code, No fact.

    Monday, May 7, 2012 9:49 AM
  • It runs the first time, but when you attempt to run the application again, it pops up asking you to pick a webcam. when you do, it closes the popup, but loads nothing. It's like EVERY example i've found doesn't release the webcam properly or something. I dont know.
    • Proposed as answer by jjfund Thursday, May 10, 2012 7:55 PM
    • Unproposed as answer by jjfund Thursday, May 10, 2012 7:55 PM
    • Proposed as answer by jjfund Thursday, May 10, 2012 7:59 PM
    • Marked as answer by Slysoft Friday, May 11, 2012 10:50 AM
    Monday, May 7, 2012 11:48 AM