How to watch camera events on Maemo or MeeGo using Python?
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
The article is believed to be still valid for the original topic scope.
The article is believed to be still valid for the original topic scope.
This article provides a code snippet showing how to watch for camera events using Python on the Maemo platform.
The N800 and N810 devices have a integrated camera that sends signals according to her events. These signals are sent to dbus, and can be watched by applications that watch it. For instance, the Maemo camera application displays a mirrored image ever that the camera is rotated to back, watching the "camera_turned_out/in" signals.
In this case, four camera signals can be watched:
- camera_out: when the camera is pulled-out
- camera_in: when the camera is pulled-in
- camera_turned_out: when the camera is targeted to back
- camera_turned_in: when the camera is targeted to front
The simple python example below shows how to watch the camera signals.
# function called when Maemo camera is closed
def camera_out_cb(*args):
print "-- *camera out signal* received --"
# function called when Maemo camera is opened
def camera_in_cb(*args):
print "-- *camera in signal* received --"
# function called when Maemo camera is turned out
def camera_turned_out_cb(*args):
print "-- *camera turned out signal* received --"
# function called when Maemo camera is turned in
def camera_turned_in_cb(*args):
print "-- *camera turned in signal* received --"
# setting dbus main loop (dbus requires a main loop)
import dbus
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)
# getting bus
bus = dbus.SystemBus()
# Connecting the camera signals to callback functions
bus.add_signal_receiver(camera_out_cb, dbus_interface="com.nokia.ke_recv.camera_out")
bus.add_signal_receiver(camera_in_cb, dbus_interface="com.nokia.ke_recv.camera_in")
bus.add_signal_receiver(camera_turned_out_cb, dbus_interface="com.nokia.ke_recv.camera_turned_out")
bus.add_signal_receiver(camera_turned_in_cb, dbus_interface="com.nokia.ke_recv.camera_turned_in")
# Running the main loop
import gobject
loop = gobject.MainLoop()
loop.run()


(no comments yet)