Capturing an image using pygame and saving it

Issue #78 invalid
Former user created an issue

I had a problem with respect to the capturing of a image from a webcam and saving it. I wrote a small code to do this, but on executing the program i am just getting a black(blank) image of size(640,480).

"import pygame


from pygame.locals import *


window = pygame.display.set_mode((640,480),0)

cam =


image = cam.get_image(),'abc.jpg')


It also opens the pygame window but that is also blank, and it goes to the NOT RESPONDING state in a seconds time. Any solutions you could suggest me regarding the above?

Comments (11)

  1. Former user Account Deleted

    Thank you Nirav(nrp).

    I am working on a Image processing task.

    Is there any method to control the exposure time and frame rate of the camera from the pygame package? I am asking this because when the images are captured in dark situations then the same image is copied to around 30 frames before the next frame is captured and copied for the next 30 frames. Can this be because of the Buffer involved. Is the buffer slow ??

    Any Inputs ??

  2. Sam Bull

    Change the line from your code:,'abc.jpg')


    You saved the window screen, and not the camera image.

  3. Log in to comment