Exemplo n.º 1
0
def take_photo():
    global photo
    canvas.bind(key_codes.EKeySelect, None)
    camera.stop_finder()
    photo = camera.take_photo(size=(640, 480))
    handle_redraw(None)
    photo.save(fname + ".jpg")
def quit():
    global running
    running = 0
    camera.stop_finder()  #Close the viewfinder
    camera.release()  #Release the camera so that other programs can use it
    app_lock.signal()
    appuifw.app.set_exit()
def videocamera():
    global keyboard

    i = len(os.listdir("E:\\Videos\\"))
    video_savepath = u"E:\\Videos\\vid%d.mp4" % i

    canvas = appuifw.Canvas(event_callback=keyboard.handle_event,
                            redraw_callback=None)
    appuifw.app.body = canvas

    camera.stop_finder()
    camera.start_finder(vf, size=(240, 196))

    recording = False
    running = True
    while running:
        if keyboard.pressed(EScancodeSelect):
            if not recording:
                vid = camera.start_record(
                    video_savepath, video_callback)  #Start recording the video
                recording = True
            else:
                camera.stop_record()  #Stop recording
                videocamera()  #Restart the camera in video mode
        if keyboard.pressed(EScancodeRightSoftkey) and recording:
            camera.stop_record()
            quit()
        appuifw.app.menu = [(u"Exit", quit)]
        e32.ao_yield()
Exemplo n.º 4
0
	def camquit():
		camera.stop_finder()
		camera.release()
		# get main menu back
		appuifw.app.menu = menu_list
		# clean all bindings
		canvas.bind(key_codes.EKeySelect, None)
Exemplo n.º 5
0
def quit():
	global running
	running=0
	camera.stop_finder()   #Close the viewfinder
	camera.release()       #Release the camera so that other programs can use it
	app_lock.signal()
	appuifw.app.set_exit()
Exemplo n.º 6
0
def videocamera():
	global keyboard
 
	i=len(os.listdir("E:\\Videos\\"))
	video_savepath=u"E:\\Videos\\vid%d.mp4" % i
 
	canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=None)
	appuifw.app.body=canvas
 
	camera.stop_finder()
	camera.start_finder(vf, size=(240,196))
 
	recording=False
	running=True
	while running:
		if keyboard.pressed(EScancodeSelect):
			if not recording:
				vid=camera.start_record(video_savepath, video_callback)   #Start recording the video
				recording=True
			else:
				camera.stop_record()    #Stop recording
				videocamera()	        #Restart the camera in video mode
		if keyboard.pressed(EScancodeRightSoftkey) and recording:
			camera.stop_record()
			quit()
		appuifw.app.menu=[(u"Exit", quit)]
		e32.ao_yield()
Exemplo n.º 7
0
    def test_start_record(self):
        def video_cb(err, code):
            self.failIf(err, "Error while recording")
            if self.counter:
                self.failUnlessEqual(code, camera.EPrepareComplete,
                                     "State is not proper")
            else:
                self.failUnlessEqual(code, camera.EOpenComplete,
                                     "State is not proper")
            self.counter += 1

        def finder_cb(im):
            appuifw.app.body.blit(im)

        self.counter = 0
        video_filename = 'test_video.3gp'
        appuifw.app.body = appuifw.Canvas()
        self.delete_files_if_exist([video_filename], save_path)

        try:
            camera.start_finder(finder_cb)
            camera.start_record(save_path + video_filename, video_cb)
            e32.ao_sleep(5)
            camera.stop_record()
            camera.stop_finder()
        except RuntimeError, e:
            print >> sys.stderr, "Error recording a video :", e
            raise
Exemplo n.º 8
0
	def close(self, pos = (0, 0)):
		self.canvas.bind(key_codes.EButton1Down, None)
		
		appuifw.app.screen = 'normal'
		appuifw.app.orientation = 'portrait'
		
		camera.stop_finder()
		camera.release()
Exemplo n.º 9
0
def stop():
    global stopp
    global stopr
    stopp = True
    stopr = True
    camera.stop_finder()
    cnvCallback()
    appuifw.app.menu = mainmenu_stopped
 def set_zoom_half_max():
     global zoom, z1, z2, z3
     zoom = camera.max_zoom() / 2
     z1 = "0"
     z2 = str(camera.max_zoom() / 4)
     z3 = "X " + str(camera.max_zoom() / 2)
     pic = camera.take_photo('RGB', resolution, zoom)
     camera.stop_finder()
     camera.start_finder(vf, size=(240, 180))
Exemplo n.º 11
0
	def set_zoom_0():
		global zoom, z1, z2, z3
		zoom=0
		z1="X 0"
		z2=str(camera.max_zoom()/4)
		z3=str(camera.max_zoom()/2)
		pic=camera.take_photo('RGB', resolution, zoom)
		camera.stop_finder()
		camera.start_finder(vf, size=(240,180))
Exemplo n.º 12
0
def new_view():
	camera.stop_finder()
	message(appuifw.app.body)
	camera.take_photo(
		mode="JPEG_Exif",
		size=camera.image_sizes()[-1], # should be the smallest available
		exposure=exposure_modes[exposure_mode],
		white_balance=white_modes[white_mode])
	start_view()
Exemplo n.º 13
0
	def handleTabs(self, tabIndex):
		if tabIndex == 0:
			if(self.imagerOn == 1):
				camera.stop_finder()
				self.imagerOn = 0		
			self.displayGUI()
		elif tabIndex == 1:
			self.initImager()
		else:
			self.displayGUI()
Exemplo n.º 14
0
def shoot():
    global state
    camera.stop_finder()
    pic_time = time.ctime()
    pos_string = u"Lat: " + str(pos['latitude']) + u"      Long: " + str(pos['longitude'])
    pos_string = pos_string + "      " + pic_time
    photo = camera.take_photo(size = (640, 480))
    w, h = photo.size
    photo.rectangle((0, 0, w, 15), fill = (255,0,255))
    photo.text((5,12), pos_string, fill = (255, 255, 255))
    
    w, h = canvas.size
    canvas.rectangle((0,0,w,h), fill=(255,255,255))
    canvas.text((20,h - 20), u"Picture ready", fill = (0,0,0))
    canvas.blit(photo, target = (0, 0, w, 0.75 * w), scale = 1)
    pic_time = pic_time.replace(":","-")
    filename = "E:\\Images\\" + pic_time.replace(" ", "_") + ".jpg"
    photo.save(filename)
Exemplo n.º 15
0
    def run(self):
        Dialog.refresh(self)

        try:
            camera.start_finder(self.redraw)
        except:
            note(LABELS.loc.pt_err_cant_start_viewf,"error")
            return None
        
        while (not self.taken) and (not self.cancel):
            e32.ao_yield()
            
        try:
            camera.stop_finder()
            camera.release()
        except:
            note(LABELS.loc.pt_err_cant_stop_viewf,"error")
        
        return self.filename
 def run(self):
     # setup screen
     appuifw.app.screen = 'large'
     appuifw.app.title = u'Magic Video'
     appuifw.app.exit_key_handler = self.stop
     appuifw.app.body = appuifw.Canvas(event_callback=self.event)
     appuifw.app.menu = [(u"Effortless (2x2)", lambda: self.new_game(4)),
                         (u"Easy (3x3)", lambda: self.new_game(9)),
                         (u"Medium (4x4)", lambda: self.new_game(16)),
                         (u"Hard (5x5)", lambda: self.new_game(25)),
                         (u"Impossible (6x6)", lambda: self.new_game(36)),
                         (u"Help", self.help),
                         (u"About Magic Video", self.about)]
     self.prerender_text()
     camera.start_finder(self.draw)  # start camera
     self.lock = e32.Ao_lock()
     self.lock.wait()
     camera.stop_finder()
     camera.release()
Exemplo n.º 17
0
def photo():
	global info
	info = u"Taking photo..."
	start_time = time.time()
	camera.stop_finder()
	message(appuifw.app.body)
	p = camera.take_photo(
		mode="JPEG_Exif",
		size=(1600, 1200),
		flash=flash_modes[flash_mode],
		exposure=exposure_modes[exposure_mode],
		white_balance=white_modes[white_mode])
	filename = time.strftime("E:\\Images\\%d%m%y-%H%M%S.jpg")
	f = open(filename, "w")
	f.write(p)
	f.close()
	appuifw.app.body.blit(graphics.Image.open(filename), scale=1)
	time.sleep(2)
	start_time = 0
	start_view()
Exemplo n.º 18
0
def take_photo():
        canvas.bind(key_codes.EKeySelect, None)
        camera.stop_finder()
        
        show_text(u"Hold still!")
        image = camera.take_photo(size = (640, 480))

        s = canvas.size
        canvas.blit(image,target=(0,0,s[0],(s[0]/4*3)), scale=1)
        show_text(u"Uploading to Flickr...")
        
        image.save(IMG_FILE)
        jpeg = file(IMG_FILE, "r").read()

        params = {'api_key': API_KEY, 'title': 'InstaFlickr', 
                  'auth_token': flickr_token,\
                  'photo': jpeg}
        ret = flickr_signed_call(params)
        canvas.clear((255, 255, 255))
        if ret:
                show_text(u"Photo sent ok!")
        else:
                show_text(u"Network error")
Exemplo n.º 19
0
def quit():
	camera.stop_finder()
	camera.release()
	app_lock.signal()
 def exit_key_handler(self):
     camera.stop_finder()
     self.canvas = None
     appuifw.app.exit_key_handler = None
     self.script_lock.signal()
 def stop_finder(self):
     camera.stop_finder()
     self.finder_on = 0
     appuifw.note(u"Viewfinder stopped")
def photocamera():
    global keyboard, z1, z2, z3, zoom, r1, r2, resolution, q, q1, q2

    #We set the tabs of the application
    def handle_tabs(index):
        global lb, videocamera
        if index == 0: photocamera()
        if index == 1: videocamera()

    appuifw.app.set_tabs([u"Photo", u"Video"], handle_tabs)

    #In order to be able to take several pictures and videos, we add a number to the end of their filenames.
    #This number is obtained by checking how many files of that type are saved on the device
    i = len(os.listdir("E:\\Images\\"))
    photo_savepath = u"E:\\Images\\pic%d.jpg" % i

    #Make the background a canvas; needed for key capturing
    canvas = appuifw.Canvas(event_callback=keyboard.handle_event,
                            redraw_callback=None)
    appuifw.app.body = canvas

    #The default resolution is 0.8 megapixels and the default zoom level is 0
    resolution = (1024, 768)
    r1 = "X 1024x768"
    r2 = "640x480"
    zoom = 0
    z1 = "X 0"
    z2 = str(camera.max_zoom() / 4)
    z3 = str(camera.max_zoom() / 2)

    #These functions set the resolution, zoom and image quality to the selected value
    def set_res_vga():
        global resolution, r1, r2
        resolution = (640, 480)
        r1 = "1024x768"
        r2 = "X 640x480"

    def set_res_08():
        global resolution, r1, r2
        resolution = (1024, 768)
        r1 = "X 1024x768"
        r2 = "640x480"

    def set_zoom_0():
        global zoom, z1, z2, z3
        zoom = 0
        z1 = "X 0"
        z2 = str(camera.max_zoom() / 4)
        z3 = str(camera.max_zoom() / 2)
        pic = camera.take_photo('RGB', resolution, zoom)
        camera.stop_finder()
        camera.start_finder(vf, size=(240, 180))

    def set_zoom_quarter_max():
        global zoom, z1, z2, z3
        zoom = camera.max_zoom() / 4
        z1 = "0"
        z2 = "X " + str(camera.max_zoom() / 4)
        z3 = str(camera.max_zoom() / 2)
        pic = camera.take_photo('RGB', resolution, zoom)
        camera.stop_finder()
        camera.start_finder(vf, size=(240, 180))

    def set_zoom_half_max():
        global zoom, z1, z2, z3
        zoom = camera.max_zoom() / 2
        z1 = "0"
        z2 = str(camera.max_zoom() / 4)
        z3 = "X " + str(camera.max_zoom() / 2)
        pic = camera.take_photo('RGB', resolution, zoom)
        camera.stop_finder()
        camera.start_finder(vf, size=(240, 180))

    def set_qual_50():
        global q, q1, q2
        q = 50
        q1 = "High"
        q2 = "X Low"

    def set_qual_100():
        global q, q1, q2
        q = 100
        q1 = "X High"
        q2 = "Low"

    #In order for the viewfinder to correspond to the zoom level, we must take a picture (without saving it), close and open the viewfinder
    #These steps are necessary because of the way the functions are currently defined in PyS60, and have a slight impact on performance
    #Future releases of PyS60 may have optimized functions
    pic = camera.take_photo('RGB', resolution, zoom)
    camera.stop_finder()
    camera.start_finder(vf, size=(240, 180))

    #We now create a loop that "waits" for keys to be pressed
    running = True
    while running:
        if keyboard.pressed(EScancodeSelect):
            pic = camera.take_photo('RGB', resolution, zoom)  #Take the picture
            pic.save(photo_savepath, quality=q)  #Save it
            photocamera()  #Restart camera in photo mode
        if keyboard.pressed(EScancodeRightSoftkey): quit()
        appuifw.app.menu = [(u"Zoom", ((u"%s" % z1, set_zoom_0),
                                       (u"%s" % z2, set_zoom_quarter_max),
                                       (u"%s" % z3, set_zoom_half_max))),
                            (u"Resolution", ((u"%s" % r1, set_res_08),
                                             (u"%s" % r2, set_res_vga))),
                            (u"Quality", ((u"%s" % q1, set_qual_100),
                                          (u"%s" % q2, set_qual_50))),
                            (u"Exit", quit)]
        e32.ao_yield()
Exemplo n.º 23
0
def stop():
    camera.stop_finder()
    cnvCallback()
    appuifw.app.menu = [(u'Start', start), (u'Exit', __exit__)]
Exemplo n.º 24
0
def take_picture():
    camera.stop_finder()
    pic = camera.take_photo(size = (640,480))
    w,h = canvas.size
    canvas.blit(pic,target=(0, 0, w, 0.75 * w), scale = 1)
    pic.save('e:\\Images\\picture1.jpg')
Exemplo n.º 25
0
def capture( ):
    camera.stop_finder( )
    cnvCallback( )
    appuifw.app.menu = [(u'Start', start), (u'Exit', __exit__)]
    img.save(u'E:\\Images\\viewfinder.png')
    appuifw.note(u'Saved', 'info')
Exemplo n.º 26
0
def shoot():
    camera.stop_finder()
    photo = camera.take_photo(size=(640, 480))
    w, h = canvas.size
    canvas.blit(photo, target=(0, 0, w, 0.75 * w), scale=1)
    photo.save('e:\\Images\\photo.jpg')
Exemplo n.º 27
0
def quit():
    camera.stop_finder()
    app_lock.signal()
Exemplo n.º 28
0
 def stop_finder(self):
     camera.stop_finder()
     self.finder_on=0
     appuifw.note(u"Viewfinder stopped")
Exemplo n.º 29
0
 def exit_key_handler(self):
     camera.stop_finder()
     self.canvas=None
     appuifw.app.exit_key_handler = None
     self.script_lock.signal()
Exemplo n.º 30
0
def exit():
    camera.stop_finder()
    app_lock.signal()
Exemplo n.º 31
0
def capture_cb():
    global photo
    photo=camera.take_photo()
    camera.stop_finder()
    lock.signal()
Exemplo n.º 32
0
def take_picture():
    camera.stop_finder()
    pic = camera.take_photo(size = (640,480))
    w,h = canvas.size
    canvas.blit(pic,target=(0, 0, w, 0.75 * w), scale = 1)
    pic.save('e:\\Images\\picture1.jpg')
Exemplo n.º 33
0
def quit():
  camera.stop_finder()
  camera.release()
  myLock.signal()
Exemplo n.º 34
0
def photocamera():
	global keyboard, z1, z2, z3, zoom, r1, r2, resolution, q, q1, q2
 
	#We set the tabs of the application
	def handle_tabs(index):
		global lb, videocamera
		if index==0:photocamera()
		if index==1:videocamera()
	appuifw.app.set_tabs([u"Photo", u"Video"], handle_tabs)
 
	#In order to be able to take several pictures and videos, we add a number to the end of their filenames.
	#This number is obtained by checking how many files of that type are saved on the device
	i=len(os.listdir("E:\\Images\\"))
	photo_savepath=u"E:\\Images\\pic%d.jpg" % i
 
	#Make the background a canvas; needed for key capturing
	canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=None)
	appuifw.app.body=canvas
 
	#The default resolution is 0.8 megapixels and the default zoom level is 0
	resolution=(1024, 768)
	r1="X 1024x768"
	r2="640x480"
	zoom=0
	z1="X 0"
	z2=str(camera.max_zoom()/4)
	z3=str(camera.max_zoom()/2)
 
	#These functions set the resolution, zoom and image quality to the selected value
	def set_res_vga():
		global resolution, r1, r2
		resolution=(640, 480)
		r1="1024x768"
		r2="X 640x480"
	def set_res_08():
		global resolution, r1, r2
		resolution=(1024, 768)
		r1="X 1024x768"
		r2="640x480"
 
	def set_zoom_0():
		global zoom, z1, z2, z3
		zoom=0
		z1="X 0"
		z2=str(camera.max_zoom()/4)
		z3=str(camera.max_zoom()/2)
		pic=camera.take_photo('RGB', resolution, zoom)
		camera.stop_finder()
		camera.start_finder(vf, size=(240,180))
	def set_zoom_quarter_max():
		global zoom, z1, z2, z3
		zoom=camera.max_zoom()/4
		z1="0"
		z2="X " + str(camera.max_zoom()/4)
		z3=str(camera.max_zoom()/2)
		pic=camera.take_photo('RGB', resolution, zoom)
		camera.stop_finder()
		camera.start_finder(vf, size=(240,180))
	def set_zoom_half_max():
		global zoom, z1, z2, z3
		zoom=camera.max_zoom()/2
		z1="0"
		z2=str(camera.max_zoom()/4)
		z3="X " + str(camera.max_zoom()/2)
		pic=camera.take_photo('RGB', resolution, zoom)
		camera.stop_finder()
		camera.start_finder(vf, size=(240,180))
 
	def set_qual_50():
		global q, q1, q2
		q=50
		q1="High"
		q2="X Low"
	def set_qual_100():
		global q, q1, q2
		q=100
		q1="X High"
		q2="Low"
 
	#In order for the viewfinder to correspond to the zoom level, we must take a picture (without saving it), close and open the viewfinder
	#These steps are necessary because of the way the functions are currently defined in PyS60, and have a slight impact on performance
	#Future releases of PyS60 may have optimized functions
	pic=camera.take_photo('RGB', resolution, zoom)
	camera.stop_finder()
	camera.start_finder(vf, size=(240,180))
 
	#We now create a loop that "waits" for keys to be pressed
	running=True
	while running:
		if keyboard.pressed(EScancodeSelect):
			pic=camera.take_photo('RGB', resolution, zoom)  #Take the picture
			pic.save(photo_savepath, quality=q)             #Save it
			photocamera()                                   #Restart camera in photo mode
		if keyboard.pressed(EScancodeRightSoftkey):quit()
		appuifw.app.menu=[(u"Zoom", ((u"%s" % z1, set_zoom_0), (u"%s" % z2, set_zoom_quarter_max), (u"%s" % z3, set_zoom_half_max))), (u"Resolution", ((u"%s" % r1, set_res_08), (u"%s" % r2, set_res_vga))), (u"Quality", ((u"%s" % q1, set_qual_100), (u"%s" % q2, set_qual_50))), (u"Exit", quit)]
		e32.ao_yield()
Exemplo n.º 35
0
def stop( ):
    camera.stop_finder( )
    cnvCallback( )
    appuifw.app.menu = [(u'Start', start), (u'Exit', __exit__)]
Exemplo n.º 36
0
def capture():
    camera.stop_finder()
    cnvCallback()
    appuifw.app.menu = [(u'Start', start), (u'Exit', __exit__)]
    img.save(u'E:\\Images\\viewfinder.png')
    appuifw.note(u'Saved', 'info')