Image capture from USB camera with Python

asked 2014-07-25 10:57:26 -0500

Good afternoon,

I am trying to acquire a single image from a USB camera. I can successfully visualise a live stream with the code provided in the "Getting Started with VideosĀ¶" section from the tutorial by replacing 0 with 1, but I can't figure out how to capture just a single image with this camera. I could solve the problem by just pressing print screen then saving the image but this is rather annoying, is there a way to do that by code ?

Thanks

edit retag flag offensive close merge delete

Comments

what again is the problem ? saving the (captured) image to disk ?

berak gravatar imageberak ( 2014-07-25 11:19:12 -0500 )edit

Yes that's it.

jfmamjjasond gravatar imagejfmamjjasond ( 2014-07-25 11:48:42 -0500 )edit

a simple cv2.imwrite("my.png",frame) will do the trick.

also, opencv comes with a lot of nice samples. which are probably already on your disk.

berak gravatar imageberak ( 2014-07-25 11:57:26 -0500 )edit