Archived:How to take a picture and send it over Bluetooth using PySymbian
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.
All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
Article Metadata
Tested with
Devices(s): Nokia N96
Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition
Article
Keywords: camera
Created: giaperrucci
(07 Jun 2007)
Last edited: hamishwillee
(08 May 2013)
Contents |
Overview
This Python code shows how to take a picture and send it using Bluetooth (OBEX). The script uses camera, e32, socket and graphics modules.
Code Snippet
# import modules
import appuifw, camera, e32
from graphics import *
from socket import *
# Create menu
def main_menu():
appuifw.app.menu=[(u"Take photo", take_picture),
(u"Send", Send),
(u"Exit",app_exit)]
# Application body
appuifw.app.body=canvas=appuifw.Canvas()
# Function for the viewfinder
def vf(im):
appuifw.app.body.blit(im)
# Start viewfinder
camera.start_finder(vf)
# Function for taking the picture
def take_picture():
# Take the photo
photo = camera.take_photo('RGB', (1024, 768))
# Save it at maximum quality
photo.save(u"e:\\photo.jpg", quality = 100)
# Stop the viewfinder
camera.stop_finder()
# Display image
canvas.blit(photo)
# Function to send Image
def Send():
file=(u'e:\\photo.jpg')
device=bt_obex_discover()
address=device[0]
channel=bt_obex_discover(address)[1][u'OBEX Object Push']
bt_obex_send_file(address,channel,file)
def app_exit():
camera.release() #Release the camera so other applications may use it
appuifw.app.set_exit()
lock=e32.Ao_lock()
appuifw.app.title=u"BT example"
main_menu()
lock.wait()
Screenshots
The following screenshots are the outcome.






20 Sep
2009
23 Sep
2009