meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
maemo:python_and_n900 [2011/08/09 13:04] japskua [Using Location API] |
maemo:python_and_n900 [2011/08/11 09:56] (current) japskua [Using Microphone] |
||
---|---|---|---|
Line 71: | Line 71: | ||
sound = player.Load(" | sound = player.Load(" | ||
# Play the file | # Play the file | ||
- | | + | |
</ | </ | ||
Line 93: | Line 93: | ||
<code shell> | <code shell> | ||
sudo gainroot | sudo gainroot | ||
- | apt-get install gstreamer0.10-alsa gstreamer0.10-flac | + | apt-get install gstreamer0.10-alsa gstreamer0.10-flac |
</ | </ | ||
Line 132: | Line 132: | ||
@email: japskua@gmail.com | @email: japskua@gmail.com | ||
- | @requires: gstreamer0.10-alsa, | + | @requires: gstreamer0.10-alsa, |
""" | """ | ||
Line 199: | Line 199: | ||
===== Using Camera ===== | ===== Using Camera ===== | ||
- | Camera stuff here | + | This code uses the N900's camera to take picture. It is not very sophisticated, |
+ | so please, before running any camera python apps (at least based on my code) make sure you do | ||
+ | |||
+ | <code shell> | ||
+ | sudo gainroot | ||
+ | python camera.py | ||
+ | |||
+ | (or in scratchbox) | ||
+ | |||
+ | fakeroot | ||
+ | python2.5 camera.py | ||
+ | </ | ||
+ | |||
+ | <file python camera.py> | ||
+ | """ | ||
+ | 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 = " | ||
+ | self.front = " | ||
+ | |||
+ | def TakePicture(self, | ||
+ | """ | ||
+ | @summary: The function for taking pictures with the camera | ||
+ | @param camera: The camera to be taken pictures with | ||
+ | @type camera: String, either " | ||
+ | @param filename: The path to the file where to save the taken picture, | ||
+ | | ||
+ | @type filename: String | ||
+ | """ | ||
+ | photo = None | ||
+ | |||
+ | if camera == " | ||
+ | photo = self.front + filename + " | ||
+ | elif camera == " | ||
+ | photo = self.back + filename + " | ||
+ | else: | ||
+ | print " | ||
+ | | ||
+ | os.system(photo) | ||
+ | |||
+ | |||
+ | |||
+ | # If this program is executed as itself | ||
+ | if __name__ == " | ||
+ | camera = Camera() | ||
+ | camera.TakePicture(" | ||
+ | camera.TakePicture(" | ||
+ | </ | ||
===== Bluetooth ===== | ===== Bluetooth ===== | ||