コード例 #1
0
ファイル: tinytitan.py プロジェクト: nesl/ecopda
 def switch_in(self):
     appuifw.app.body = self.canvas
     appuifw.app.menu = [(u"Save Image", self.save_picture)]
     appuifw.app.title = u'Image'
     self.screen_picture = camera.take_photo(size=(640, 480))
     self.running = 1
     while self.running:
         if self.save_picture_flag:
             self.running = 0
             try:
                 self.screen_picture = camera.take_photo(size=(1280, 960))
                 self.filename = self.filename_prefix + str(int(
                     time.time())) + u'.jpg'
                 self.screen_picture.save(self.filename)
                 appuifw.note(u"Picture saved to " + self.filename, "conf")
             except:
                 pass
         else:
             try:
                 self.screen_picture = camera.take_photo(size=(640, 480))
             except:
                 pass
         self.handle_redraw(())
         e32.ao_yield()
     self.handle_redraw(())
    def _process_pir_event(self, pir_event: PIREvent):
        """
        The process of a PIR event that can signal an alarm if the system is armed

        For the alarm it will be latched. A latched alarm means that once it has been activated someone has to
        manually disable it using the pin or some kind of confirmation.

        :param pir_event:
        :return:
        """

        if pir_event.event_type == PirEventType.falling:
            self._logger.debug('Falling event occurred')
            self.watson.send_movement_falling()
        elif pir_event.event_type == PirEventType.rising:
            if self.is_sensing:
                # First event that has occurred when armed, activate alarm thread
                if not self.alarm_active:
                    self.alarm_active = True
                    self._logger.info('Alarm has been activated')
                    self.watson.send_alarm_activated()
                    camera.take_photo()
                    camera.take_video()
                    sleep(1)
                    # Get the latest image taken and send that in the message
                    list_of_files = glob.glob("/home/pi/motion/camera1" +
                                              '/*-snapshot.jpg')
                    latest_file = max(list_of_files, key=os.path.getctime)
                    self.notifications.send_alert_message(latest_file)
                    camera.take_video()
            self._logger.debug('Rising event occurred')
            self.watson.send_movement_rising()
コード例 #3
0
ファイル: reactive.py プロジェクト: casassg/reactive
def take():
    id_ = str(int(time.time()))
    path = 'res/img/' + id_ + '.jpg'
    camera.take_photo(path)
    detect = vision.detect(path)
    result = {'id': id_, 'result': detect}
    return jsonify(result)
コード例 #4
0
ファイル: main.py プロジェクト: gafarchik/py-car
def photo():
    if request.method == 'POST':
        if request.form.get('Photo') == '📷':
            take_photo()
            return render_template('panel.html')
            return Response(
                gen_frames(),
                mimetype='multipart/x-mixed-replace; boundary=frame')
コード例 #5
0
def send_file():
    connect_to_server('localhost', 21)
    print("Sending photo")
    camera.take_photo()  # Take photo and store it in the /images directory
    image_list = os.listdir('images')
    most_recent = open('images/' + image_list[-1], 'rb')
    ftp.storbinary('STOR ' + most_recent.name[7:], most_recent)
    return most_recent.name
コード例 #6
0
ファイル: stream.py プロジェクト: benclark158/RaspiBirdBox
    def do_GET(self):

        global lastAccess
        global camera
        global PAGE
        lastAccess = round(time.time() * 1000)

        if self.path == '/':
            self.send_response(301)
            self.send_header('Location', '/index.html')
            self.end_headers()
        elif self.path == '/index.html':
            currentTemp, _ = c.check_CPU_temp()

            if currentTemp < 80.0:
                c.start_stream_inactive(camera)

            content = PAGE.encode('utf-8')
            self.send_response(200)
            self.send_header('Content-Type', 'text/html')
            self.send_header('Content-Length', len(content))
            self.end_headers()
            self.wfile.write(content)
        elif self.path == "/data":

            content = str.encode(c.build_json())

            self.send_response(200)
            self.send_header('Content-Type', 'text/json')
            self.send_header('Content-Length', len(content))
            self.end_headers()
            self.wfile.write(content)
        elif self.path.startswith("/api/"):
            if self.path == "/api/nightvision":
                c.toggle_mode()
                c.userSetNV = True
                self.write_success()
            elif self.path == "/api/photo":
                c.take_photo(camera, False)
                self.write_success()
            elif self.path == "/api/hqphoto":
                c.take_photo(camera, True)
                self.write_success()
            elif self.path == "/api/startvideo":
                c.start_recording(camera)
                self.write_success()
            elif self.path == "/api/endvideo":
                c.end_recording(camera)
                self.write_success()
            elif self.path == "/api/reload":
                PAGE = open("/home/pi/index.html", "r").read()
                self.write_success()
            else:
                self.send_error(404)
                self.end_headers()
        else:
            self.send_error(404)
            self.end_headers()
コード例 #7
0
ファイル: SimSyCam.py プロジェクト: sulir/simsycam
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()
 def _connection_thread(self, connection: socket.socket):
     """
     Process a connection from the system client.
     :param connection: The socket connection to utilize
     """
     try:
         data = json.loads(bytes(connection.recv(1024)).decode('utf-8'))
         if data is not None and isinstance(data, dict) and 'func' in data:
             func = data['func']
             if func == 'arm_disarm' and 'pin' in data and isinstance(
                     data['pin'], str):
                 if self.is_armed:
                     result = self._disarm(data['pin'])
                     connection.send(
                         json.dumps({
                             'result': result
                         }).encode('utf-8'))
                 else:
                     result = self._arm(data['pin'])
                     connection.send(
                         json.dumps({
                             'result': result
                         }).encode('utf-8'))
             elif func == 'set_pin' and 'current_pin' in data and isinstance(data['current_pin'], str) \
                     and 'new_pin' in data and isinstance(data['new_pin'], str):
                 result = self._set_pin(data['current_pin'],
                                        data['new_pin'])
                 connection.send(
                     json.dumps({
                         'result': result
                     }).encode('utf-8'))
             elif func == 'take_photo':
                 camera.take_photo()
                 connection.send(
                     json.dumps({
                         'result': True
                     }).encode('utf-8'))
             elif func == 'take_video':
                 camera.take_video()
                 connection.send(
                     json.dumps({
                         'result': True
                     }).encode('utf-8'))
             elif func == 'status':
                 connection.send(
                     json.dumps({
                         'armed': self.is_armed,
                         'led_color': self.led.color.name,
                         'led_enabled': self.led.enabled,
                         "is_sensing": self.is_sensing
                     }).encode('utf-8'))
     except socket.error as e:
         self._logger.error('{}'.format(e))
     except json.JSONDecodeError as e:
         self._logger.error('{}'.format(e))
     finally:
         connection.close()
コード例 #9
0
    def test_take_photo(self):
        snaps = [u'low.jpg', u'middle.jpg', u'high.jpg']
        self.delete_files_if_exist(snaps, save_path)

        try:
            low_res_picture = camera.take_photo(mode='RGB12')
            low_res_picture.save(save_path + snaps[0])
            middle_res_picture = camera.take_photo(mode='RGB16')
            middle_res_picture.save(save_path + snaps[1])
            high_res_picture = camera.take_photo(mode='RGB')
            high_res_picture.save(save_path + snaps[2])
        except RuntimeError, e:
            print >> sys.stderr, "Error taking a snap :", e
            raise
コード例 #10
0
def capture():
    global img2
    global textrect2
    global scapsz

    stop()

    bak = appuifw.app.title

    appuifw.app.menu = [(u'Exit', __exit__)]

    if scapsz == None:
        scapsz = selcapsz()

    img2.clear()
    displaytxt("capturing ...", img2, textrect2)
    appuifw.app.body.blit(img2)

    displaytxt("capturing ...", img2, textrect2)
    appuifw.app.body.blit(img2)

    IMG = camera.take_photo(size=scapsz)

    img2.clear()
    displaytxt("saving ...", img2, textrect2)
    appuifw.app.body.blit(img2)

    IMG.save(u'c:\\data\\images\\' + str(t.time()) + ".png",
             bpp=24,
             quality=100,
             compression='no')
    #IMG.save(u"d:\\tx.png",bpp=24,quality=100,compression='no')
    start()
コード例 #11
0
 def grabPhoto(self):
     try:
         img = camera.take_photo(mode="RGB", size=(160, 120))
         img.save(self._path + "_foto_.jpg")
         return img
     except:
         raise
コード例 #12
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")
コード例 #13
0
	def grabPhoto(self):
		try:
			img												= camera.take_photo(mode='RGB', size=(160, 120))
			img.save(self._path + '_foto_.jpg')
			return img
		except:
			raise
コード例 #14
0
ファイル: main.py プロジェクト: mfitzp/etchasnap
def main():
    while True:

        status_complete()

        # Wait for flip & shake.
        tilt.wait_for_press()
        time.sleep(1)

        # Setup the camera interface.
        camera.prepare()
        status_ready()

        # Wait for shutter, then take picture.
        shutter.wait_for_press()
        status_processing()
        image = camera.take_photo()
        #image.save("raw-photo-%s.jpg" % (int(time.time())))
        image = camera.process_image(image)
        #image.save("processed-photo-%s.jpg" % (int(time.time())))

        # Process the image & generate plotter moves.
        moves = graph.generate_moves(image)

        # Draw the paths.
        status_drawing()
        plotter.enqueue(moves)
コード例 #15
0
ファイル: tinytitan.py プロジェクト: nesl/ecopda
 def __init__(self):
     self.save_picture_flag = 0
     self.keyboard = Keyboard()
     self.screen_picture = camera.take_photo(size=(640, 480))
     self.img = Image.new((176, 208))
     self.canvas = appuifw.Canvas(event_callback=self.keyboard.handle_event,
                                  redraw_callback=self.handle_redraw)
     self.filename_prefix = u'e:\\Images\obs_'
     self.filename = u''
コード例 #16
0
def send_photo():
    handle_message({"note": u"Taking photo..."})
    dst = appuifw.query(u"To", "text")
    img = camera.take_photo(size=(640, 480))
    img = img.resize((320, 240))
    img.save("E:\\Images\\temp.jpg")
    jpeg = file("E:\\Images\\temp.jpg").read()
    handle_message({"note": u"Sending photo..."})
    thread_send_message({"!dst": dst, "photo": jpeg, "from": me})
コード例 #17
0
ファイル: tinytitan.py プロジェクト: nesl/ecopda
 def __init__(self):
     self.save_picture_flag = 0
     self.keyboard = Keyboard()
     self.screen_picture = camera.take_photo(size = (640,480))
     self.img = Image.new((176,208))
     self.canvas = appuifw.Canvas(event_callback=self.keyboard.handle_event,
                 redraw_callback=self.handle_redraw)
     self.filename_prefix = u'e:\\Images\obs_'
     self.filename = u''
コード例 #18
0
 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))
コード例 #19
0
ファイル: pycamera_example.py プロジェクト: MIT-EPROM/EPROM
	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))
コード例 #20
0
 def get_motion(self,mark = False):
     im = camera.take_photo(mode = "RGB", size = scan_res, flash = "none",position = 0)
     chg_pixels, chg_area = self.check_motion(im)
     im.rectangle(self.square, width = 1, outline = (0,0,255))
     if chg_pixels > self.max_pixels:
         if mark:
             im.rectangle(chg_area, width = 1, outline = (255,0,0))
         return (im,True)
     else:
         return (im,False)
コード例 #21
0
ファイル: daemon.py プロジェクト: BGCX261/zhe-trunk-hg-to-git
def take_photo():
    resolution=(1024,768)
    zoom=1
    img=camera.take_photo('RGB', resolution, zoom)
    picture_path = os.path.join(ROOT_PATH, 'picture.jpg')
    logging.debug(picture_path)
    img.save(picture_path, quality=100)
    logging.info("Photo took!")
    upload_picture()
    logging.info('Photo uploaded!')
コード例 #22
0
def take_photo():
    resolution = (1024, 768)
    zoom = 1
    img = camera.take_photo('RGB', resolution, zoom)
    picture_path = os.path.join(ROOT_PATH, 'picture.jpg')
    logging.debug(picture_path)
    img.save(picture_path, quality=100)
    logging.info("Photo took!")
    upload_picture()
    logging.info('Photo uploaded!')
コード例 #23
0
def take_picture(aFilename, picSize, aFlash='none'):
	#Take the photo
	print "Taking photo .. ", picSize, " flash=", aFlash
	#photo = camera.take_photo('JPEG_Exif', (2048,1536), flash='none', exposure='auto', white_balance='auto')
	photo = camera.take_photo('JPEG_Exif', picSize, flash=aFlash, exposure='auto', white_balance='auto')	
	#Save it
	print "Saving photo to %s."%(aFilename)
	F=open(aFilename, "wb")
	F.write(photo)
	F.close()			
コード例 #24
0
def start():
    image = camera.take_photo()
    appuifw.app.body = c = appuifw.Canvas()
    c.blit(image, scale=1)
    file = u"e:\\Images\\Image.jpg"
    image.save(file)
    device = socket.bt_obex_discover()
    address = device[0]
    channel = device[1][u"OBEX Object Push"]
    socket.bt_obex_send_file(address, channel, file)
    appuifw.note(u"Picture sent", "info")
コード例 #25
0
def start():
    image= camera.take_photo()
    appuifw.app.body=c=appuifw.Canvas()
    c.blit(image,scale=1)
    file=(u'e:\\Images\\picture1.jpg')
    image.save(file)
    device=socket.bt_obex_discover()
    address=device[0]
    channel=device[1][u'OBEX Object Push']
    socket.bt_obex_send_file(address,channel,file)
    appuifw.note(u"Picture sent","info")
コード例 #26
0
ファイル: snap.py プロジェクト: mfitzp/etchasnap
def main():
    while True:

        # Setup the camera interface.
        camera.prepare()
        status_ready()

        # Wait for shutter, then take picture.
        shutter.wait_for_press()
        status_processing()
        image = camera.take_photo()
        image.save("photo-%s.jpg" % (int(time.time())))
コード例 #27
0
ファイル: imageTagger.py プロジェクト: nesl/soundscape
	def captureImageLoop(self):
		if self.captureImage == 1:
			if ((self.userName != u'None') and (self.userName != u'') and (self.locationTag != u'None') and (self.activityTag != u'None') and (self.imagerOn == 0)):
				photoCaptured = camera.take_photo('RGB', (1280, 960), 0, 'auto', 'auto', 'auto', 0)
				photoName = unicode("E:\\Images\\")
				photoName += unicode(self.userName) + unicode("_")
				photoName += unicode(self.locationTag) + unicode("_")
				photoName += unicode(self.activityTag) + unicode("_")
				photoName += unicode(time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime()))
				photoName += unicode(".jpg")
				photoCaptured.save(photoName, None, 'JPEG', 100, 24, 'no')
			e32.ao_sleep(0, self.captureImageLoop)
コード例 #28
0
def shutter():
    ss = request.args.get('shutter_speed')
    wb = request.args.get('white_balance')
    # Get the last image stored to the database;
    query = ImageStore.query.order_by('-id').first()
    # If this query exists, increment its id
    # and use it to name the next file
    if query is not None:
        next_id = query.id + 1
        name = "snap" + str(next_id) + ".jpg"
    else:
        name = "snapX"
    # build camera command with variables and send to camera
    take_photo(build_command(name, ss, wb))
    # Add new photo info to database:
    session = db.session()
    img = ImageStore()
    img.filename = name
    session.add(img)
    session.commit()
    return name
コード例 #29
0
def take_blob(blob_type, timeout_ms):
    filename = ""
    filepath = ""

    if blob_type == "PHOTO":
        # Takes photo
        filename, filepath = camera.take_photo(timeout_ms)
    elif blob_type == "VIDEO":
        # Take video
        filename, filepath = camera.take_video(timeout_ms)

    # Upload image or video to Azure
    # View blobs in storage account easily using: http://storageexplorer.com/
    upload_blob(filename, filepath)
コード例 #30
0
ファイル: httpd_pic.py プロジェクト: Ilia1/PyS60CameraScripts
def take_picture(aFilename, picSize, aFlash='none'):
    #Take the photo
    print "Taking photo .. ", picSize, " flash=", aFlash
    #photo = camera.take_photo('JPEG_Exif', (2048,1536), flash='none', exposure='auto', white_balance='auto')
    photo = camera.take_photo('JPEG_Exif',
                              picSize,
                              flash=aFlash,
                              exposure='auto',
                              white_balance='auto')
    #Save it
    print "Saving photo to %s." % (aFilename)
    F = open(aFilename, "wb")
    F.write(photo)
    F.close()
    def get_and_process_user_entry(self):
        user_entry = input("Enter action: ")

        if user_entry == "00":
            self.print_actions()
        elif user_entry == "11":
            print("Sending Rising event")
            self.system.event_queue.put(
                PIREvent(time=time.time(), event_type=PirEventType.rising))
        elif user_entry == "12":
            print("Sending Falling event")
            self.system.event_queue.put(
                PIREvent(time=time.time(), event_type=PirEventType.falling))
        elif user_entry == "0" or user_entry == "1" or user_entry == "2" or user_entry == "3" or user_entry == "4" \
                or user_entry == "5" or user_entry == "6" or user_entry == "7" or user_entry == "8" \
                or user_entry == "9" or user_entry == "#":
            print("Sending key event: ", user_entry)
            self.system.keypad.keypress_queue.put(user_entry[0])
        elif user_entry == "20":
            print("Clearing LED")
            self.system.led.clear_led()
        elif user_entry == "30":
            print("Armed: ", self.system.is_armed)
            print("LED Enabled: ", self.system.led.enabled)
            print("LED Color: ", self.system.led.color.name)
            print("Alarm active: ", self.system.alarm_active)
            print("System Locked: ", self.system.system_locked)
            print("Armed: ", self.system.is_armed)
        elif user_entry == "40":
            self.system.is_armed = True
        elif user_entry == "41":
            self.system.is_armed = False
        elif user_entry == "50":
            camera.take_photo()
        elif user_entry == "":
            pass
        return int(user_entry)
コード例 #32
0
def cb(event):

    global counter
    counter = counter + 1

    t = int(time.time())
    sat = event["satellites"]
    tm = sat["time"]
    tot = sat["satellites"]
    used = sat["used_satellites"]
    pos = event["position"]
    lat = pos["latitude"]
    lng = pos["longitude"]
    alt = pos["altitude"]
    vdop = pos["vertical_accuracy"]
    hdop = pos["horizontal_accuracy"]
    crse = event["course"]
    hdg = crse["heading"]
    hdgacc = crse["heading_accuracy"]
    spd = crse["speed"]

    sdb = sysinfo.signal_dbm()
    loc = location.gsm_location()
    sloc = str(loc)
    sloc = sloc.replace(',', '/')

    global S
    sndtime = int(S.current_position() / 1000)

    s = "gps:" + str(t) + "," + str(sndtime) + ',' + str(tm) + "," + str(
        tot) + "," + str(used) + "," + str(lat) + "," + str(lng) + "," + str(
            alt)
    s = s + "," + str(vdop) + "," + str(hdop) + "," + str(hdg) + "," + str(
        hdgacc) + "," + str(spd) + "gsm:" + str(sloc) + "," + str(sdb)
    fncSavedata(s)

    pic = camera.take_photo('RGB', (320, 240), 0, 'none', 'auto', 'auto', 1)
    sp = "e:\\datalogger\\pic" + str(t) + '.jpg'
    pic.save(sp)

    img.clear()
    img.text((40, 34), u'Log ID: ' + str(counter), 0xff0000, font='normal')
    img.text((40, 64),
             u'Sats: ' + str(used) + "/" + str(tot),
             0xff0000,
             font='normal')
    img.text((40, 94), u'Spd: ' + str(int(spd)), 0xff0000, font='normal')
    img.text((40, 124), u'Snd: ' + str(sndtime), 0xff0000, font='normal')
    handle_redraw(())
コード例 #33
0
ファイル: posts.py プロジェクト: bohwaz/wordmobi
 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
コード例 #34
0
ファイル: tinytitan.py プロジェクト: nesl/ecopda
 def switch_in(self):
     appuifw.app.body = self.canvas
     appuifw.app.menu =[(u"Save Image", self.save_picture)]
     appuifw.app.title = u'Image'
     self.screen_picture = camera.take_photo(size = (640,480))
     self.running = 1
     while self.running:
           if self.save_picture_flag:
              self.running = 0
              try:
                  self.screen_picture = camera.take_photo(size = (1280,960))
                  self.filename = self.filename_prefix + str(int(time.time())) + u'.jpg'
                  self.screen_picture.save(self.filename)
                  appuifw.note(u"Picture saved to " + self.filename, "conf")
              except:
                     pass
           else:
                try:
                    self.screen_picture = camera.take_photo(size = (640,480))
                except:
                       pass
           self.handle_redraw(())
           e32.ao_yield()
     self.handle_redraw(())
コード例 #35
0
ファイル: imageTaggerThread.py プロジェクト: nesl/soundscape
	def captureImageLoop(self):
		while 1:
			if self.captureImage == 1:
				if ((self.userName != u'None') and (self.userName != u'') and (self.locationTag != u'None') and (self.activityTag != u'None') and (self.imagerOn == 0)):
					photoCaptured = camera.take_photo('RGB')
					#photoName = unicode("E:\\Others\\")
					#photoName += unicode(self.userName) + unicode("_")
					#photoName += unicode(self.locationTag) + unicode("_")
					#photoName += unicode(self.activityTag) + unicode("_")
					#photoName += unicode(time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))
					#photoName += unicode(".jpg")
					#photoCaptured.save(photoName, None, 'JPEG', 100, 24, 'no')
					time.sleep(5)
				else:
					time.sleep(5)
			elif self.captureImage == 0:
				time.sleep(5)
コード例 #36
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
コード例 #37
0
 def take_picture(self, captureORM):
     self.screen_picture = camera.take_photo(size=(1280, 960))
     self.img = Image.new((176, 208))
     self.canvas = appuifw.Canvas(redraw_callback=self.handle_redraw)
     self.filename_prefix = u'e:\\Images\obs_'
     self.filename = u''
     self.old_body = appuifw.app.body
     appuifw.app.body = self.canvas
     #appuifw.app.menu =[(u"Save Image", self.save_picture)]
     appuifw.app.title = u'Image'
     self.filename = self.filename_prefix + str(int(time.time())) + u'.jpg'
     data = appuifw.query(u"Save this image to " + self.filename, "query")
     if data:
         self.screen_picture.save(self.filename)
         captureORM.picture_filename = self.filename
         appuifw.note(u"Saved.", "conf")
     self.handle_redraw(())
     appuifw.app.body = self.old_body
コード例 #38
0
ファイル: GpsCam.py プロジェクト: nyra/JavaCodeFromSVN
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)
コード例 #39
0
ファイル: capture.py プロジェクト: nesl/ecopda
 def take_picture(self, captureORM):
     self.screen_picture = camera.take_photo(size = (1280, 960))
     self.img = Image.new((176,208))
     self.canvas = appuifw.Canvas(redraw_callback=self.handle_redraw)
     self.filename_prefix = u'e:\\Images\obs_'
     self.filename = u''
     self.old_body = appuifw.app.body
     appuifw.app.body = self.canvas
     #appuifw.app.menu =[(u"Save Image", self.save_picture)]
     appuifw.app.title = u'Image'
     self.filename = self.filename_prefix + str(int(time.time())) + u'.jpg'
     data = appuifw.query(u"Save this image to " + self.filename,"query")
     if data:
         self.screen_picture.save(self.filename)
         captureORM.picture_filename = self.filename
         appuifw.note(u"Saved." , "conf")
     self.handle_redraw(())
     appuifw.app.body = self.old_body
コード例 #40
0
ファイル: APlurk.py プロジェクト: cgvarela/plurk-s60app
	def save(self, pos = (0, 0)):
		self.canvas.bind(key_codes.EButton1Down, None)
		img = camera.take_photo(mode = 'JPEG_Exif', flash = self.mod, size = (640, 480))
		
		save_p = self.__filename_gen()
		f = open(save_p, 'wb')
		f.write(img)
		f.close()
		
		#img = camera.take_photo(mode = 'RGB', flash = self.mod, size = (640, 480))
		#img.save(self.path + 'test.jpg', quality = 100, compression = 'no')
		
		self.close()
		
		global limg, limg_path
		limg_path = save_p
		limg = Image.open(save_p)
		limg = limg.resize((320, 240), callback = None, keepaspect = 1)
		handle_redraw()
コード例 #41
0
ファイル: SimSyCam.py プロジェクト: sulir/simsycam
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()
コード例 #42
0
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()
コード例 #43
0
ファイル: imageTaggerThread.py プロジェクト: nesl/soundscape
 def captureImageLoop(self):
     while 1:
         if self.captureImage == 1:
             if ((self.userName != u'None') and (self.userName != u'')
                     and (self.locationTag != u'None')
                     and (self.activityTag != u'None')
                     and (self.imagerOn == 0)):
                 photoCaptured = camera.take_photo('RGB')
                 #photoName = unicode("E:\\Others\\")
                 #photoName += unicode(self.userName) + unicode("_")
                 #photoName += unicode(self.locationTag) + unicode("_")
                 #photoName += unicode(self.activityTag) + unicode("_")
                 #photoName += unicode(time.strftime("%Y-%m-%d %H-%M-%S", time.localtime()))
                 #photoName += unicode(".jpg")
                 #photoCaptured.save(photoName, None, 'JPEG', 100, 24, 'no')
                 time.sleep(5)
             else:
                 time.sleep(5)
         elif self.captureImage == 0:
             time.sleep(5)
コード例 #44
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")
コード例 #45
0
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()
コード例 #46
0
def take_photo():

    global stop
    global interval
    global directory
    global filename
    global counter
    global quality
    global size

    if (stop == 1):
        counter = counter + 1

        name = filename + str(counter) + u'.png'

        texto.add(u'Taking photo : ' + name + u'\n')

        imagedir = directory + name

        if (quality == 'high'): mode = 'RGB'
        elif (quality == 'medium'): mode = 'RGB16'
        elif (quality == 'low'): mode = 'RGB12'

        if (size == '640'): size = (640, 480)
        elif (size == '160'): size = (160, 120)

        #image = camera.take_photo(mode='RGB',  size=(640,480))
        image = camera.take_photo(mode, size)
        image.save(imagedir)

        #if ((counter % 10) == 0 ):
        #    show_free_space()
        #    if interval > 5 : interval = interval - 5 #Compensamos la perdida de tiempo de la funcion anterior

        show_time()
        e32.ao_sleep(interval, take_photo)
コード例 #47
0
ファイル: imageTester.py プロジェクト: nesl/soundscape
# 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')

コード例 #48
0
sense = SenseHat()
mot = MotionSensor(4)
sense.set_rotation(180)
time_since_pic = 0
pic_interval = 10
pic_count = 0

while True:
	if mot.motion_detected:
		# Yes motion
		sense.set_pixels(led_images.green_dot)

		# Take a pic every x seconds
		if time_since_pic == 0 or time_since_pic >= pic_interval:
			imagepath = 'public/photo' + str(pic_count) + '.jpg'
			pic_count += 1
			sense.set_pixels(led_images.flash)
			camera.take_photo(imagepath)
			sense.set_pixels(led_images.green_dot)
			# Reset counter
			time_since_pic = 0
	else: 
		# No motion
		sense.set_pixels(led_images.red_dot)
		time_since_pic = pic_interval

	# Keep the clock ticking
	time.sleep(1)
	time_since_pic += 1
コード例 #49
0
def getphoto_callback():
    global photo
    photo=camera.take_photo(size=(160,120))
    # release the active object scheduler
    lock.signal()
コード例 #50
0
ファイル: AIOTorch.py プロジェクト: pipacs/etc
	window.background_color = 0xFFFFFF
 
	def exit():
		window.hide()
		app_lock.signal()
 
	app_lock = e32.Ao_lock()
	window.show()
	light_on()
 	
	appuifw.app.exit_key_handler = exit
	app_lock.wait()
	appuifw.note(u"For updates and more info, visit series-sixty.blogspot.com","conf")

if picked==1:
	running=1
	def quit():
    		global running
		appuifw.note(u"StrobeLight OFF")
		appuifw.note(u"For updates and more info, visit series-sixty.blogspot.com","conf")
    		running=0
	appuifw.app.exit_key_handler=quit
	appuifw.note(u"StrobeLight ON")

	while running:
		image = camera.take_photo(exposure='night', flash='red_eye_reduce')

if picked==2:
	appuifw.note(u"ScreenTorch blanks the screen and makes the backlight stay on until it is manually terminated") 
	appuifw.note(u"StrobeLight Pro utilizes the camera hardware to continuously flash the LED at regular intervals")
	appuifw.note(u"For updates and more info, visit series-sixty.blogspot.com")
コード例 #51
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')
コード例 #52
0
ファイル: APlurk.py プロジェクト: cgvarela/plurk-s60app
	def take_picture(pos = (0, 0)): # For touch events support
		pic = camera.take_photo(size = (640, 480))
		save_picture(pic)
コード例 #53
0
ファイル: timelapse.py プロジェクト: tominsam/timelapse
nameOfProject = appuifw.query(u"Name of project:", "text")

numImages = 1000000 # Just fill the card.
#numImages = appuifw.query(u"Number of images:", "number")

delay = appuifw.query(u"Delay in seconds (0 for 'as fast as possible'):", "number")

print "Starting..."

x = 0
while x < numImages:
    start = time()

    try:
        print "Snapping image number: " + str(x)
        image = camera.take_photo(size=(640,480))
        filename="e:\\timelapse\\%s_%04d.jpg"%( nameOfProject, x )
        print "Saving image %s"%filename
        image.save(filename)
    except Exception, e:
        print("Error taking photo: %s", e)
    
    # work out how long taking the photo took. Sleep long enough
    # to maintain a constant frame rate.
    finish = time()
    sleeptime = delay - ( finish - start )
    if sleeptime >= 0:
        sleep(sleeptime)
    elif delay > 0:
        # nothing we can do, but might as well warn about it.
        print("Warning: Photo took %f seconds to take, which is longer than the photo delay."%( finish - start ) )
コード例 #54
0
ファイル: reactive.py プロジェクト: casassg/reactive
def react(id_):
    path = 'res/img/' + id_ + '_react.jpg'
    camera.take_photo(path)
    detect = vision.detect(path)
    result = {'id': id_, 'result': detect}
    return jsonify(result)
コード例 #55
0
ファイル: ex_camera_descr.py プロジェクト: MIT-EPROM/EPROM
    running=0
    appuifw.app.set_exit()

# define the redraw function (redraws the screen)
def handle_redraw(rect):
    canvas.blit(img)

# define the canvas including key scanning fucntion as callback and also the redraw handler as callback
canvas=appuifw.Canvas(event_callback=keyboard.handle_event, redraw_callback=handle_redraw)
# set the application body to canvas
appuifw.app.body=canvas

app.exit_key_handler=quit

# take a photo in of the size 160x120 pixels
screen_picture = camera.take_photo(size = (160,120))


# create a loop to get stuff handled that needs to be done again and again
while running:
    # activate the camera again taking in pictures again and again (till key 2 is pressed)
    if switch == 1:
        screen_picture = camera.take_photo(size = (160,120))
    # draw the new picture on the canvas in the upper part -> numbers are coordinates of the location of the picture on the canvas
    img.blit(screen_picture,target=(8,10,168,130),scale=1)
    # redraw the canvas
    handle_redraw(())
    e32.ao_yield()
    # scann for left softkey to switch on the camera again
    if keyboard.pressed(EScancodeLeftSoftkey):
        switch = 1
コード例 #56
0
ファイル: pycamera_example.py プロジェクト: MIT-EPROM/EPROM
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()
コード例 #57
0
ファイル: test.py プロジェクト: CloudCray/PiQuickSnap
def upload_photo():
	timestamp = datetime.now().isoformat().replace("T","_")
	fn = "/home/pi/photos/" + timestamp + ".jpg"
	camera.take_photo(fn)
	ui = upload.upload_image(fn, title=timestamp)
	print(fn + " - " + ui.link)