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
RECEIVERCode: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()![]()




Reply With Quote








