| Reply | « Previous Thread | Next Thread » |
|
BlueDriver
========== Here it is a first draft of a program which allows using a couple of nokia phones to take tridimensional pictures and MOVIES! ![]() It's actually a COUPLE of programs, the DRIVER and the RECEIVER. When you press a key on driver, both phones take the snapshot or the video. Then, you can merge them into a single blue/red anaglyph using this free programs, StereoPhotoMaker and StereoVideoMaker: http://stereo.jpn.org/eng/ INSTRUCTIONS: -Set clocks on two phones at same time -Install DRIVER on PHONE1 and RECEIVER on PHONE2 -Start DRIVER -Start RECEIVER -PHONE2 will look for PHONE1: select it, then select "3d photo" service Now phones are connected. Use PHONE1 to control PHONE2: 0 - take snapshot 1 - start video 2 - stop video Files are saved with timestamps, to allow easy "coupling" them on PC. Known issues: - no finder yet - possible delay among shots on 2 phones - 6600 phone raises an error upon first import of camera module: just ignore it, module will be imported twice... Video feature not tested: I only have ONE phone supporting video in python... ![]() You find attached a sample anaglyph: my working place. ![]() Feel free to extend the program as you like, don't know when I'll have time to complete it... Note: BlueDriver can actually be used to drive by bluetooth a phone to get it acting as you like! DRIVER Code:
from socket import *
import appuifw
import keycapture
from appuifw import *
import e32
from e32 import ao_sleep,Ao_lock
import time
from graphics import *
try:
import camera
except Exception, e:
print "6600 bug, camera module must be imported twice. Please ignore this error..."
import camera
sock = 0
def quit():
global sock
app.exit_key_handler = None
script_lock.signal()
capturer.stop()
sock.close()
print "PROGRAMMA TERMINATO."
print
def cb_capture(key):
global abort
if key==keycapture.EKey1:
sock.send("StartVideo\n");
start_video()
if key==keycapture.EKey3:
sock.send("StopVideo\n");
stop_video()
if key==keycapture.EKey0:
sock.send("Snapshot\n");
GetSnapshot()
# Allow time for data to be sent to work around a bug in the socket
# module.
e32.ao_sleep(1)
print "Command sent."
def video_callback(err,current_state):
pass
def finder_cb(im):
im.point((20, 20), outline = (0, 255, 0), width = 25)
def start_video():
global filename
print "starting video..."
camera.start_finder(finder_cb)
filename = "c:\\3Dvid_"+time.strftime('%d-%m-%Y_%H-%M-%S')+'.3gp'
camera.start_record(filename,video_callback)
def stop_video():
global filename
print "stopping video..."
camera.stop_record()
camera.stop_finder()
camera.release()
print "Video saved to " + filename
def GetSnapshot():
image = camera.take_photo(size = (640,480))
filename = "c:\\3Dpic_"+time.strftime('%d-%m-%Y_%H-%M-%S')+'.jpg'
image.save(filename)
print "Image saved to "+ filename
camera.release()
script_lock = Ao_lock()
app.exit_key_handler = quit
capturer=keycapture.KeyCapturer(cb_capture)
capturer.forwarding=0
capturer.keys=(keycapture.EKey1,keycapture.EKey3,keycapture.EKey7,keycapture.EKey0)
capturer.start()
server_socket = socket(AF_BT, SOCK_STREAM)
p = bt_rfcomm_get_available_server_channel(server_socket)
server_socket.bind(("", p))
print "bind done"
server_socket.listen(1)
bt_advertise_service( u"3d photo", server_socket, True, RFCOMM)
set_security(server_socket, AUTH)
print "waiting for connection..."
(sock,peer_addr) = server_socket.accept()
print "Connection estabilished with %s"%peer_addr
print "Press 0 to take snapshot on both phones"
script_lock.wait()
Code:
import socket
import appuifw
import e32
from e32db import format_time
import time
from graphics import *
try:
import camera
except Exception, e:
print "6600 bug, camera module must be imported twice. Please ignore this error..."
import camera
filename = ""
class BTReader:
def connect(self):
self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
addr,services=socket.bt_discover()
print "Discovered: %s, %s"%(addr,services)
if len(services)>0:
import appuifw
choices=services.keys()
choices.sort()
choice=appuifw.popup_menu([unicode(services[x])+": "+x
for x in choices],u'Choose port:')
port=services[choices[choice]]
else:
port=services[services.keys()[0]]
address=(addr,port)
print "Connecting to "+str(address)+"..."
self.sock.connect(address)
print "OK, connection estabilished."
def readline(self):
line=[]
while 1:
ch=self.sock.recv(1)
if(ch=='\n'):
break
line.append(ch)
return ''.join(line)
def close(self):
self.sock.close()
def video_callback(err,current_state):
pass
def finder_cb(im):
im.point((20, 20), outline = (0, 255, 0), width = 25)
def start_video():
global filename
print "starting video..."
camera.start_finder(finder_cb)
filename = "c:\\3Dvid_"+time.strftime('%d-%m-%Y_%H-%M-%S')+'.3gp'
camera.start_record(filename,video_callback)
def stop_video():
global filename
print "stopping video..."
camera.stop_record()
camera.stop_finder()
camera.release()
print "Video saved to " + filename
def GetSnapshot():
image = camera.take_photo(size = (640,480))
filename = "c:\\3Dpic_"+time.strftime('%d-%m-%Y_%H-%M-%S')+'.jpg'
image.save(filename)
print "Image saved to "+ filename
camera.release()
bt=BTReader()
bt.connect()
command=bt.readline()
while command != "end":
if command == "StartVideo":
start_video()
if command == "StopVideo":
stop_video()
if command == "Snapshot":
GetSnapshot()
command=bt.readline()
print "End."
bt.close()
Last edited by cassioli : 2008-10-26 at 14:56.
|
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
Cool, man!
![]() That seems to be a good example of bluetooth application in PyS60. ![]() I'll give it a try later. Congratulations for the application! Keep them coming! BR, Rafael. |
|
Quote:
I think it could be a good base for other applications based on cellphones synchronization in a client-server fashion: free bluetooth messaging, remote (not TOO remote...) controlling a phone, and so on. About 3d photos/movies, the actual use of this program couple is for far objetcs: naked eye is not able to actually view far objects (more than 100 meters I guess) in real 3d: we "imagine" 3d clouds or 3d mountains or 3d panoramas, but actually we "compute" third dimension by means of mist: the more the object is far, the more it is covered by mist. Try taking a 3d snapshot of a panorama when the phones are not just 10 cm apart, but 10 or more METERS apart, and you'll see what I mean. ![]() I'll try posting a screenshot tomorrow. |
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
Actually it's a good example for using camera and graphics too
![]() One of the bests client-server apps I've seen! Can't wait to get another phone for testing it ![]() You may also want to put this code in the Wiki Code Examples ![]() Thanks for contributing with the DiBo! BR, Rafael. |
|
Hello Cassioli
![]() And where is the sample ? I don't see attached file ![]() I saw also interesting project from you in googlecode ![]() BR Cyke64 pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 ! pys60 extension modules on http://cyke64.googlepages.com/ |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
hi cassioli
Great one more application in PyS60 dibo. This time the idea is really very nice i will test this with my two devices. Congrats and keep it up. Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Quote:
Swiching to imageshack: http://img201.imageshack.us/img201/8...4081845mq4.jpg ![]() |
|
Another possible use can come from "coupling" this application with this other idea of mine:
Phone2PIC Phone2PIC allows using a phone to drive a PIC processor. And if the PIC is mounted on such a board, you can use it to drive even high-power devices (by means of relais). You could turn on/off any device in your home just by using your phone! (see attachment)I also found a generic name for my 3d-photo application: BlueDriver (as it can be used not just to take couple-snaphsots, but to drive a phone by BT). |
|
Wow, impressive - except I haven't tried this yet
But it does sound like the very thing I've been looking for! Have to try, if I can create something on top of it ![]() Btw no copy right/left note, but I guess you would allow using it? With credit given etc? ![]() That import error reminds me about similar socket import error discussed earlier in this DiBo: first you get error note, next time none. However in case of sockets, it meant that _socket library was not found and the sw didn't actually work. In your case camera works ok, so it must be something else... Thanx, --jouni |
|
I don't care at all.
Do what you want with the code. Just don't forget to thank Jurgen Scheible for his great tutorial: almost all I know and write about python comes from there! Copy&Paste&Edit is the better way I know to learn programming! ![]() Next to come: SMSDriver (see an anticipation inside LCCarTrack.py, read_sms(id) function) |
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
|
Quote:
Cassioli, SMSDriver should be another great idea (I have taken a look into the sms function). LCCarTrack also seems to be espetucular! It's a good example for many modules. Keep your projects up and continue to share with the DiBo ![]() Congratulations for your great projects! BR, Rafael. |
|
Quote:
Wanna take a look to all of them? ![]() I'm always looking for additional developers to carry on my ideas... Nokia Datalogger - http://code.google.com/p/nokdat/ (PYTHON) LEDremote - SMS-controlled remote control for TV - http://code.google.com/p/ledrem/ (PYTHON) Car antitheft - http://code.google.com/p/lc-cartrack/ (PYTHON) Traffic informations (only Rome-Italy) - http://code.google.com/p/trafficlc/ (J2ME) Home intrusion detection system - http://code.google.com/p/powerwarning/ (PYTHON) Basic guitar tuner - http://code.google.com/p/freqdet/ (PYTHON) |
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Rafael T.
Offline
Forum Nokia Champion
|
|
|
Quote:
![]() I'm taking a look at them yet but all of them seem to be very good ideas. Maybe you can find people here wo want to carrie your ideas. I'll try to help as much as I can ![]() Continue if great work! BR, Rafael. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Displaying large photos, videos | Larry101 | Mobile Java General | 1 | 2008-03-18 18:00 |
| Mobypal - send highres videos and photos from the mobile | mobycator | News, Announcements and Job Listings | 0 | 2008-01-08 16:51 |