Issue #78 invalid

Capturing an image using pygame and saving it

Anonymous 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

import pygame.camera

from pygame.locals import *

pygame.init()

pygame.camera.init()

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

cam = pygame.camera.Camera(0)

cam.start()

image = cam.get_image()

pygame.image.save(window,'abc.jpg')

cam.stop()"

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 (10)

  1. Anonymous

    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:

    pygame.image.save(window,'abc.jpg')

    to:

    pygame.image.save(image,'abc.jpg')

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

  3. Log in to comment