DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

New Camera Module

06.19.2005
| 8717 views |
  • submit to reddit
        A few days ago, I posted an example of how to take
a photo with py_s60 1.1.0. But now, a new and better
version (1.1.3) is released. The camera module has
improved significantly.

Now it can
- use different sizes (640x480 and 160x120 in my case)
- use zoom (0 or 1 in my case)
- take photos at 12, 16 or 24-bit color ('RGB12', 'RGB16', 'RGB')
- using flash ('none', 'auto', 'forced', 'fill_in', 'red_eye_reduce')
- set white-balance and exposure (I use 'auto' for both,
  but sometimes I may use 'night' exposure)
- return an image object which can save in 'jpg' or 'png' format

You can see that these have good default values
 # copy from camera.py
def take_photo(
  mode='RGB16',
  size=(640, 480),
  zoom=0,
  flash='none',
  exposure='auto',
  white_balance='auto'):
So the simplest example is
import camera
im = camera.take_photo()  # use all default values
im.save(u'C:\\test.jpg')
You can see what you can set on your phone
from camera import *
print image_modes()
print image_sizes()
print max_zoom()
print flash_modes()
print exposure_modes()
print white_balance_modes()
    

Comments

Snippets Manager replied on Wed, 2009/09/30 - 11:37pm

Where do I find camera.py? I have to find a way to adjust focal length and exposure time in web cams through python. Does anybody have experience with that??