dverleysen
Posts: 34
Joined: Wed Jan 06, 2016 2:00 pm

USB Microsoft webcam - over exposed problem - code issue?

Fri Apr 22, 2016 12:32 pm

Hey,

I have a Microsoft USB webcam connected to my raspberry PI 2 B, but sometimes i've got a totally white picture and sometimes a bit of a normal picture. See attachment, it's like the picture is over exposed.

It's something that can be fixed with some changes on the code? I've added already a kind of time before and after that the picture is taken, but that isn't a solution - time.sleep(.)

The code that I currently use

Code: Select all

import os
import pygame, sys

from pygame.locals import *
import pygame.camera

width = 1280
height = 720

#initialise pygame
pygame.init()
pygame.camera.init()
cam = pygame.camera.Camera("/dev/video0",(width,height))

cam.start()
#setup window
windowSurfaceObj = pygame.display.set_mode((width,height),1,32)
pygame.display.set_caption('Camera')
#take a picture
time.sleep(4)
image = cam.get_image()
time.sleep(1)
cam.stop()

#display the picture
catSurfaceObj = image
windowSurfaceObj.blit(catSurfaceObj,(0,0))
pygame.display.update()

#save picture
pygame.image.save(windowSurfaceObj,'/home/pi/python/data/usbwebcamimage.jpg')
used usb cam = https://www.microsoft.com/hardware/en-g ... cam-cinema

Thanks for the feedback!
Attachments
2016-04-22 14_26_30-Nieuwe melding.jpg
2016-04-22 14_26_30-Nieuwe melding.jpg (56.51 KiB) Viewed 1506 times
https://www.linkedin.com/pulse/harvesting-tomatoes-version-20-didier-verleysen/

barsznica
Posts: 20
Joined: Thu Apr 14, 2016 12:38 pm

Re: USB Microsoft webcam - over exposed problem - code issue

Sun Mar 05, 2017 2:46 am

I am having similar issues using fswebcam. The controls ("--list-controls", brightness, contrast, gain, exposure) don't seem to make much difference.
Maybe you could find some setting, too?

Return to “Python”