Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to watch camera events on Maemo or MeeGo using Python?

From Wiki
Jump to: navigation, search

Archived.pngArchived: 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.


This article provides a code snippet showing how to watch for camera events using Python on the Maemo platform.

Article Metadata
Article
Created: hozano (29 Aug 2008)
Last edited: lpvalente (20 Apr 2013)

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:

  1. camera_out: when the camera is pulled-out
  2. camera_in: when the camera is pulled-in
  3. camera_turned_out: when the camera is targeted to back
  4. 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()
This page was last modified on 20 April 2013, at 22:32.
41 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×