def get_image(self):
     """
     Grab a frame from the camera. The cameraCommunicator is the caller,
     and is responsible for lighting and location. The filename of the
     image is returned. 
     
     Raises:
         FatalCameraException: An image was not taken successfully.
     """
     
     #create the systematic filename
     timestamp = datetime.datetime.now()
     filename = utils.get_image_dir() + str(timestamp.date()) + \
                 str(timestamp.hour) + str(timestamp.minute) + \
                 str(timestamp.second) + '.jpg'
     
     #A series of reads to allow the camera to adjust to lighting
     self.cam.read()
     self.cam.read()
     self.cam.read()
     self.cam.read()
     
     #only the last is saved
     success, image = self.cam.read()
     
     if not success:
         raise FatalCameraException()
     else:
         imwrite(filename, image)
         
     return timestamp, filename
Exemple #2
0
    def get_image(self):
        """
        Grab a frame from the camera. The cameraCommunicator is the caller,
        and is responsible for lighting and location. The filename of the
        image is returned. 
        
        Raises:
            FatalCameraException: An image was not taken successfully.
        """

        #create the systematic filename
        timestamp = datetime.datetime.now()
        filename = utils.get_image_dir() + str(timestamp.date()) + \
                    str(timestamp.hour) + str(timestamp.minute) + \
                    str(timestamp.second) + '.jpg'

        #A series of reads to allow the camera to adjust to lighting
        self.cam.read()
        self.cam.read()
        self.cam.read()
        self.cam.read()

        #only the last is saved
        success, image = self.cam.read()

        if not success:
            raise FatalCameraException()
        else:
            imwrite(filename, image)

        return timestamp, filename
 def __init__(self, router, r_id):
     """
     Creates the camera communicator and ensures the image directory exists.
     
     Args:
         router: A reference to the router that this receiver is associated with.
         r_id: The string that the router refers to this receiver with.
     """
     
     super(CameraReceiver, self).__init__(router, r_id)
     
     self._photo_dir = utils.get_image_dir()
     
     self._camera_comm = CameraCommunicator()
     
     if not os.path.isdir(self._photo_dir):
         self.router.create_transaction(origin = self.r_id, 
                                        to_id = "filemanager", 
                                        command = "mkdir", 
                                        command_args = self._photo_dir)
 def __init__(self, router, r_id,
              app_name = "My super-duper Flickr app", flickr_auth = None):
     """
     Initialize the image directory name, and ensure it exists. Sets up the
     interface with the Flickr API.
     
     Args:
         router: A reference to the router that this receiver is associated with.
         r_id: The string that the router refers to this receiver with.
     """
     super(FlickrReceiver, self).__init__(router, r_id)
     
     self._photo_dir = utils.get_image_dir()
     
     self.flickr = FlickrCommunicator()
                                             
     if not os.path.isdir(self._photo_dir):
         self.router.create_transaction(origin = self.r_id, 
                                        to_id = "filemanager", 
                                        command = "mkdir", 
                                        command_args = self._photo_dir)