Skip to content
Advertisement

How to save captured image to disk, using Pygame

This is my code, which starts the webcam :

JavaScript

I want to know how to capture an image and store it to the current directory. Please suggest the changes required.

Advertisement

Answer

When you call webcam.get_image it returns an RGB Surface. So just call pygame.image.save(), the file type is determined by the extension and defaults to TGA. Options are BMP, TGA, PNG, and JPEG. In this case you could append this line to your file.

JavaScript

Check out http://www.pygame.org/docs/ref/image.html and http://www.pygame.org/docs/ref/camera.html

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement