Exemplo n.º 1
0
def set_photo_cb():
    def save_hook(f):
        config.set("photo","flash",int(f[0][2][1]))
        config.set("photo","zoom",int(f[1][2]))
        config.set("photo","exposure",int(f[2][2][1]))
        config.set("photo","balance",int(f[3][2][1]))
        config.set("photo","resolution",int(f[4][2][1]))
        config.save()
        return True

    flash_modes = []
    for x in camera.flash_modes():
        flash_modes.append(x.decode())
    exposure_modes = []
    for x in camera.exposure_modes():
        exposure_modes.append(x.decode())
    balance_modes = []
    for x in camera.white_balance_modes():
        balance_modes.append(x.decode())
    image_sizes = []
    for x in camera.image_sizes():
        image_sizes.append(u"%sx%s" % x)
        
    flash = config.get("photo","flash",0)
    zoom = config.get("photo","zoom",0)
    exposure = config.get("photo","exposure",0)
    balance = config.get("photo","balance",0)
    resolution = config.get("photo","resolution",0)
    fields = [(_("M_flash"),"combo",(flash_modes,flash)),(_("M_zoom"),"number",zoom),
              (_("M_exposure"),"combo",(exposure_modes,exposure)),
              (_("M_balance"),"combo",(balance_modes,balance)),
              (_("M_resolution"),"combo",(image_sizes,resolution))]
    form = appuifw.Form(fields)
    form.save_hook = save_hook
    form.execute()    
Exemplo n.º 2
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.º 3
0
def selcapsz():
    iitems = camera.image_sizes()
    uitems = []
    for i in iitems:
        uitems.append(unicode(i))
    index = appuifw.selection_list(uitems)

    if index == None:
        index = 0
    return iitems[index]
Exemplo n.º 4
0
    def redraw(self, img):
        def center(a,b):
            m = int((a - b)/2)
            if m < 0: m = 0
            return m

        xm = center(app.body.size[0],img.size[0])
        ym = center(app.body.size[1],img.size[1])
        
        self.scr_buf.clear((255,255,255))
        self.scr_buf.blit(img,target=(xm,ym))
        app.body.blit(self.scr_buf)
        #app.body.clear((255,255,255))
        #app.body.blit(img,target=(xm,ym))
        app.title = unicode(camera.image_sizes()[self.setup['image_size']])
Exemplo n.º 5
0
 def take_photo(self):
     try:
         img = camera.take_photo(size = camera.image_sizes()[self.setup['image_size']],
                                 flash = camera.flash_modes()[self.setup['flash_mode']],
                                 exposure = camera.exposure_modes()[self.setup['exp_mode']],
                                 white_balance = camera.white_balance_modes()[self.setup['white_mode']])
         self.filename = time.strftime("%Y%m%d_%H%M%S", time.localtime()) + ".jpg"
         self.filename = os.path.join(DEFDIR, "images", self.filename)
         img.save(self.filename)            
     except:
         note(LABELS.loc.pt_err_cant_take_pic,"error")
         self.cancel_app()
         return
     
     self.taken = True
Exemplo n.º 6
0
def take_photo(desired_size, position = 0):
    global last_photo
    img = last_photo
    if img == None:
        flash = camera.flash_modes()[config.get("photo","flash",0)]
        zoom = config.get("photo","zoom",0)
        exposure = camera.exposure_modes()[config.get("photo","exposure",0)]
        balance = camera.white_balance_modes()[config.get("photo","balance",0)]
        resolution = camera.image_sizes()[config.get("photo","resolution",0)]
        img = camera.take_photo(mode="RGB", size=resolution, flash=flash, zoom=zoom,
                                exposure=exposure, white_balance=balance, position=position) 
        last_photo = img

    if img.size > desired_size:
        img = img.resize(desired_size,keepaspect=1)  
    img.text((10,img.size[1]-25),get_datetime_str(),font=u"LatinBold19",fill=(255,255,0))
    return img
Exemplo n.º 7
0
def RemoveAccessPointSelection():
    if os.path.exists(apidFile):
        os.remove(apidFile)


#Define the exit function
def Quit():
    stopServer
    app_lock.signal()
    appuifw.app.orientation = 'portrait'
    appuifw.app.set_exit()


#
# try it out
print camera.image_sizes("JPEG_Exif")

ap = RetrieveAccessPointSelection()

appuifw.app.exit_key_handler = quit
appuifw.app.menu = [(u"Stop server", stopServer),
                    (u"Remove saved AP", RemoveAccessPointSelection),
                    (u"Exit", Quit)]

#startup()
handle_request_in_UI_thread = e32.ao_callgate(_handle_request_in_UI_thread)
thread.start_new_thread(startupInThread, ())

app_lock.wait()
Exemplo n.º 8
0
		sleep(delay)
		x +=1
	print "Done!" 

#Function for taking the picture
def take_picture(aFilename):
	#Take the photo
	print "Taking photo .."
	photo = camera.take_photo('JPEG_Exif', (2592, 1944), flash='forced', exposure='auto', white_balance='auto')
	#Save it
	print "Saving photo to %s."%(aFilename)
	F=open(aFilename, "wb")
	F.write(photo)
	F.close()	
	#Upload it
	F=open(aFilename,'rb')
	ftp = FTP('192.168.123.1')
	ftp.set_pasv('false')
	ftp.login('o','o')	
	ftp.cwd('/shares/USB_Storage')
	now = datetime.datetime.now()
	uploadFilename = "%i%i%i_%i%i%i.jpg" % (now.year, now.month, now.day, now.hour, now.minute, now.second)
	ftp.storbinary('STOR '+uploadFilename,F,8192)
	ftp.quit()
	F.close()

print camera.image_sizes("JPEG_Exif")
appuifw.app.menu=[(u"Take photo", loop)]
 
#Wait for the user to request the exit
app_lock.wait()
Exemplo n.º 9
0
 def test_image_sizes(self):
     self._test_util('image_sizes', camera.image_sizes())
Exemplo n.º 10
0
# Sasank Reddy
# [email protected]
# -------------------

# This program is designed to get a sample of sound data from the phone.
# Then the program will get the power value from the sample.  Finally, this information
# will be logged to SensorBase.

import appuifw, e32, sys, os, struct, math, audio, time, sysinfo, urllib, httplib, thread, camera, graphics

#photoCaptured = camera.take_photo('RGB', (1280, 960), 'auto', 1, 'auto', 'auto', 0)
photoCaptured = camera.take_photo('RGB', (1280, 960), 0, 'auto', 'auto',
                                  'auto', 0)

print camera.image_modes()
print camera.image_sizes()
print camera.flash_modes()
print camera.max_zoom()
print camera.exposure_modes()
print camera.white_balance_modes()
#photoCaptured = camera.take_photo()

photoName = unicode("E:\\Others\\")
photoName += unicode(time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))
photoName += unicode(".jpg")
photoCaptured.save(photoName, None, 'JPEG', 100, 24, 'no')
Exemplo n.º 11
0
# Sasank Reddy
# [email protected]
# -------------------

# This program is designed to get a sample of sound data from the phone.
# Then the program will get the power value from the sample.  Finally, this information
# will be logged to SensorBase.

import appuifw, e32, sys, os, struct, math, audio, time, sysinfo, urllib, httplib, thread, camera, graphics

#photoCaptured = camera.take_photo('RGB', (1280, 960), 'auto', 1, 'auto', 'auto', 0)
photoCaptured = camera.take_photo('RGB', (1280, 960), 0, 'auto', 'auto', 'auto', 0)

print camera.image_modes()
print camera.image_sizes()
print camera.flash_modes()
print camera.max_zoom()
print camera.exposure_modes()
print camera.white_balance_modes() 
#photoCaptured = camera.take_photo()

photoName = unicode("E:\\Others\\")
photoName += unicode(time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))
photoName += unicode(".jpg")
photoCaptured.save(photoName, None, 'JPEG', 100, 24, 'no')

Exemplo n.º 12
0
 def __init__(self):
     self.image_mode=camera.image_modes()
     self.image_size=camera.image_sizes()
     self.flash_mode=camera.flash_modes()
     self.exp_mode=camera.exposure_modes()
     self.wbalance=camera.white_balance_modes()
Exemplo n.º 13
0
def _handle_request_in_UI_thread(self, channel, method, path, header):
	try:
		try:
			# this is not safe!
			params = (string.join(path.split("?")[1:], "?")).split("&")
			path = path.split("?")[0]
			while path[:1] == "/":
				path = path[1:]
			if path == 'quit':
				print "Exiting ..."
				self.shutdown = 1
				self.close()
				ap.stop()	
				appuifw.app.orientation = 'portrait'				
				appuifw.app.set_exit()
				filename = ""
			elif path == 'takepicture.jpg':			
				print "[camera] => takepicture.jpg ..."					
				e32.reset_inactivity()
				if appuifw.app.orientation == 'portrait':
					print "switching to landscape"
					appuifw.app.orientation = 'landscape'
				size = max(camera.image_sizes("JPEG_Exif"))	
				filename = os.path.join("D:\\", path)
				flash = "none"
				if "&flash=forced" in "&"+"&".join(params):
					flash = "forced"
				appuifw.app.orientation = 'landscape'
				take_picture(filename, size, flash)
				file = open(filename, "rb")
			elif os.path.splitext(path)[1] == '.jpg':
				filename = os.path.join(ROOT, path)
				print path, "=>", filename
				file = open(filename, "rb")				
			else:
				filename = os.path.join(ROOT, path)
				print path, "=>", filename
				file = open(filename, "rb")		
		except IOError:
			print "404 not found"
			channel.pushstatus(404, "Not found")
			channel.push("Content-type: text/html\r\n")
			channel.push("\r\n")
			channel.push("<html><body>File not found.</body></html>\r\n")
		else:
			print "200 OK"
			channel.pushstatus(200, "OK")
			if os.path.splitext(filename)[1] == '.jpg':
				channel.push("Content-type: image/jpeg\r\n")
			elif os.path.splitext(filename)[1] == '.zip':
				channel.push("Content-type: application/x-zip-compressed\r\n")
			else:
				channel.push("Content-type: text/html\r\n")
			fileSize = os.lstat(filename).st_size
			print "sending %d bytes" % (fileSize,)
			channel.push("Content-length: %d\r\n" % (fileSize,))
			channel.push("\r\n")
			channel.push_with_producer(FileProducer(file))
	finally:
		#print "done doing stuff in UI thread"
		self.handle_request_in_UI_thread_executing = 1  # let HTTP server's handle_request() know we're done
Exemplo n.º 14
0
 def img_size_menu(self):
     img_sizes_str = [u"%dx%d" % (x[0],x[1]) for x in camera.image_sizes()]
     res = popup_menu(img_sizes_str,LABELS.loc.pt_pmenu_res)
     if res is not None:
         self.setup['image_size'] = res
Exemplo n.º 15
0
   
running = True   
pause = True
snd = None
pause_timer = 0
storage_timer = 0
sms_timer = 0
mms_timer = 0
email_timer = 0
call_timer = 0
presence_timer = 0
last_motion_check = 0
tmp_dir = "D:\\system\\temp" 
last_photo = None
resolutions=((160,120),(320,240),(480,360),(640,480),(800,600),(1024,768),(1600,1200))
scan_res = min(camera.image_sizes())
sections = ("language","audio","video","photo","alarm","presence","email","sms","mms","call","storage","internet")

config = Config("C:\\system\\data\\pyspy.ini")
config.load()
for section in sections:
    config.update_section(section)

motion = Motion(square=(0,0,160,120), thresold=4000, max_pixels=25, step=4)
refresh_motion()

appuifw.app.exit_key_handler = quit
 
load_sound()
set_ap()
cv=appuifw.Canvas()
Exemplo n.º 16
0
def _handle_request_in_UI_thread(self, channel, method, path, header):
    try:
        try:
            # this is not safe!
            params = (string.join(path.split("?")[1:], "?")).split("&")
            path = path.split("?")[0]
            while path[:1] == "/":
                path = path[1:]
            if path == 'quit':
                print "Exiting ..."
                self.shutdown = 1
                self.close()
                ap.stop()
                appuifw.app.orientation = 'portrait'
                appuifw.app.set_exit()
                filename = ""
            elif path == 'takepicture.jpg':
                print "[camera] => takepicture.jpg ..."
                e32.reset_inactivity()
                if appuifw.app.orientation == 'portrait':
                    print "switching to landscape"
                    appuifw.app.orientation = 'landscape'
                size = max(camera.image_sizes("JPEG_Exif"))
                filename = os.path.join("D:\\", path)
                flash = "none"
                if "&flash=forced" in "&" + "&".join(params):
                    flash = "forced"
                if "&picSize=1600" in "&" + "&".join(params):
                    size = (1600, 1200)
                if "&picSize=1024" in "&" + "&".join(params):
                    size = (1024, 768)
                if "&picSize=640" in "&" + "&".join(params):
                    size = (640, 480)
                appuifw.app.orientation = 'landscape'
                take_picture(filename, size, flash)
                file = open(filename, "rb")
            elif os.path.splitext(path)[1] == '.jpg':
                filename = os.path.join(ROOT, path)
                print path, "=>", filename
                file = open(filename, "rb")
            else:
                filename = os.path.join(ROOT, path)
                print path, "=>", filename
                file = open(filename, "rb")
        except IOError:
            print "404 not found"
            channel.pushstatus(404, "Not found")
            channel.push("Content-type: text/html\r\n")
            channel.push("\r\n")
            channel.push("<html><body>File not found.</body></html>\r\n")
        else:
            print "200 OK"
            channel.pushstatus(200, "OK")
            if os.path.splitext(filename)[1] == '.jpg':
                channel.push("Content-type: image/jpeg\r\n")
            elif os.path.splitext(filename)[1] == '.zip':
                channel.push("Content-type: application/x-zip-compressed\r\n")
            else:
                channel.push("Content-type: text/html\r\n")
            fileSize = os.lstat(filename).st_size
            print "sending %d bytes" % (fileSize, )
            channel.push("Content-length: %d\r\n" % (fileSize, ))
            channel.push("\r\n")
            channel.push_with_producer(FileProducer(file))
    finally:
        #print "done doing stuff in UI thread"
        self.handle_request_in_UI_thread_executing = 1  # let HTTP server's handle_request() know we're done
Exemplo n.º 17
0
def get_resolutions():
    return camera.image_sizes()
Exemplo n.º 18
0
def get_resolutions():
    return camera.image_sizes()