""" August 9, 2011 @author: Janne Parkkila @email: japskua@gmail.com @summary: This file contains code for taking pictures with the front or the back camera of the nokia N900. The file provides python access to the camera but really just uses command line to take picture. @note: PyMaemo has no possiblity to capture pictures, thus this gstreamer capture is used via command line. This requires super user rights, so if you are using this file you can only take pictures with as a sudoer. ALSO! MAKE SURE THE CAMERA LID IS OPEN WHEN TAKING THE PICTURE!!! :-P """ import sys import gst import os class Camera(object): """ @summmary: This is the camera object that is capable of capturing pictures with either the front or the back camera of the device """ back = None front = None def __init__(self): """ @summary: The Constructor """ self.back = "gst-launch v4l2src device=/dev/video0 num-buffers=1 ! ffmpegcolorspace ! jpegenc ! filesink location=" self.front = "gst-launch v4l2src device=/dev/video1 num-buffers=1 ! ffmpegcolorspace ! jpegenc ! filesink location=" def TakePicture(self, camera, filename): """ @summary: The function for taking pictures with the camera @param camera: The camera to be taken pictures with @type camera: String, either "FRONT" or "BACK" @param filename: The path to the file where to save the taken picture, without the filetype suffix. @type filename: String """ photo = None if camera == "FRONT": photo = self.front + filename + ".jpg" elif camera == "BACK": photo = self.back + filename + ".jpg" else: print "Error, camera should be either FRONT or BACK" os.system(photo) # If this program is executed as itself if __name__ == "__main__": camera = Camera() camera.TakePicture("FRONT", "frontcam") camera.TakePicture("BACK", "backcam")