Note that there are some explanatory texts on larger screens.

plurals
  1. POCapturing a single image from my webcam in Java or Python
    text
    copied!<p>I want to capture a single image from my webcam and save it to disk. I want to do this in Java or Python (preferably Java). I want something that will work on both 64-bit Win7 and 32-bit Linux.</p> <p>EDIT: I use Python 3.x, not 2.x</p> <p>Because everywhere else I see this question asked people manage to get confused, I'm going to state a few things explicitly:</p> <ul> <li>I do not want to use Processing</li> <li>I do not want to use any language other than those stated above</li> <li>I do want to display this image on my screen in any way, shape or form</li> <li>I do not want to display a live video feed from my webcam on my screen, or save such a feed to my hard drive</li> <li>The Java Media Framework is far too out of date. Do not suggest it.</li> <li>I would rather not use JavaCV, but if I absolutely must, I want to know exactly which files from the OpenCV library I need, and how I can use these files without including the entire library (and preferably without sticking these files in any sort of PATH. Everything should be included in the one directory)</li> <li>I can use Eclipse on the 64-bit Win7 computer if need be, but I also have to be able to compile and use it on 32-bit Linux as well</li> <li><strong>If you think I might or might not know something related to this subject in any way shape or form, please assume I do not know it, and tell me</strong></li> </ul> <p>EDIT2: I was able to get Froyo's pygame example working on Linux using Python 2.7 and pygame 1.9.1. the pygame.camera.camera_list() call didn't work, but it was unnecessary for the rest of the example. However, I had to call cam.set_controls() (for which you can find the documentation here <a href="http://www.pygame.org/docs/ref/camera.html">http://www.pygame.org/docs/ref/camera.html</a>) to up the brightness so I could actually see anything in the image I captured.</p> <p>Also, I need to call the cam.get_image() and pygame.image.save() methods three times before the image I supposedly took on the first pair of calls actually gets saved. They appeared to be stuck in a weird buffer. Basically, instead of calling cam.get_image() once, I had to call it three times every single time I wanted to capture an image. Then and only then did I call pygame.image.save().</p> <p>Unfortunately, as stated below, pygame.camera is only supported on Linux. I still don't have a solution for Windows.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload