kramkroc
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 18
Joined: Fri Aug 04, 2017 10:11 am

PILlow, PiCamera and rogue readings

Sun Jan 28, 2018 5:35 pm

Hi folks,

getting close to finishing our project for the Space Lab. We're using PIL to calculate the mean brightness of our photos but find that the levels returned tend to be very high for the first picture and do tend to vary under on a theoretically steady light source. We can obviously discard the first image but wanted to know what is happening:

Code: Select all

	cam.capture(photoName) # Take photo of Earth
	image = Image.open(photoName).convert('L') # convert image to monochrome
	lux = ImageStat.Stat(image).mean[0] # calculate mean brightness/lux of image
Is the PiCamera (PiNoIR) doing some image adjustment? If so, can we turned it off?

/Mark

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: PILlow, PiCamera and rogue readings

Mon Jan 29, 2018 9:28 am

Ah yes, you probably want to start the camera preview some seconds before you capture a photo to allow it to adjust to the light level.
So for example:

Code: Select all

cam.start_preview()
time.sleep(5)
cam.capture(photoName) # Take photo of Earth
cam.stop_preview()
image = Image.open(photoName).convert('L') # convert image to monochrome
lux = ImageStat.Stat(image).mean[0] # calculate mean brightness/lux of image

kramkroc
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 18
Joined: Fri Aug 04, 2017 10:11 am

Re: PILlow, PiCamera and rogue readings

Mon Jan 29, 2018 10:35 am

Cheers Dave! I'll try it later on, but in the meantime, if capturing pictures in a loop, do you think you should do the preview each time, or is it only for that very first capture? Just wondering how consistent a meter it is if the camera is adjusting to the light each time.

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: PILlow, PiCamera and rogue readings

Mon Jan 29, 2018 11:32 am

You could keep the preview going continuously if you wanted, so start the preview, your main loop, stop the preview.

Return to “Astro Pi”