5.4. Camera

For using the built-in camera of an S60 phone, PyS60 offers a module named camera. We think that this is one of the most fun modules in PyS60, as it can give your programs a new view of the surrounding world.

Because of our enthusiasm for the camera module, this book includes seven examples that are based on taking photos. Being able to use the camera programmatically – even in the most esoteric ways – may change your relationship with camera phones in a profound manner. For instance, see Section 11.2 for a description of a large-scale urban photo hunt that was implemented using the camera module! The camera module includes three types of functions: to query features of the camera; to open and close the viewfinder; and to take photos.

Note that the camera consumes a lot of energy. If you have an application that uses the viewfinder or takes photos frequently, in many cases it is necessary to recharge the battery after four or five hours.

5.4.1. Querying Features of the Camera

The following functions are available in the camera module to query camera-related features of your phone:

  • cameras_available() returns the number of cameras available in the device.

  • image_modes() returns the image modes supported by the device as a list of strings, for example: [RGB12, RGB16, RGB] (the last one corresponds to full-color images).

  • image_sizes() returns the image resolutions supported by the device as a list of (w, h) tuples, for example: [(640, 480), (160, 120)].

  • flash_modes() returns ...

Get Mobile Python: Rapid Prototyping of Applications on the Mobile Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.