def click_picture_from_arlo( ctx, folder, filetag, username, password): # Instantiating the Arlo object automatically calls Login(), # which returns an oAuth token that gets cached. # Subsequent successful calls to login will update the oAuth token. arlo = Arlo(username, password) # Get the list of devices and filter on device type to only get the basestation. # This will return an array which includes all of the basestation's associated metadata. basestations = arlo.GetDevices('basestation') # Get the list of devices and filter on device type to only get the camera. # This will return an array which includes all of the camera's associated metadata. cameras = arlo.GetDevices('camera') # Tells the Arlo basestation to trigger a snapshot on the given camera. # This snapshot is not instantaneous, so this method waits for the response and returns the url # for the snapshot, which is stored on the Amazon AWS servers. snapshot_url = arlo.TriggerFullFrameSnapshot(basestations[0], cameras[0]) # This method requests the snapshot for the given url and writes the image data to the location specified. # Note: Snapshots are in .jpg format. timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S') filename = filetag + '_' + str(timestamp) + '.jpg' filepath = folder + '\\' + filename arlo.DownloadSnapshot(snapshot_url, filepath) ctx.obj['path-to-picture'] = filepath ctx.obj['filename'] = filename print('Downloaded snapshot to ' + filepath)
def _capture(self): print(f'Starting capture.') try: arlo = Arlo(self._username, self._password) base_stations = arlo.GetDevices('basestation') cameras = arlo.GetDevices('camera', filter_provisioned=True) for camera in cameras: name = camera['deviceName'] if self._camera_names is not None and name not in self._camera_names: continue print(f'- Taking snapshot from {name}') url = arlo.TriggerFullFrameSnapshot(base_stations[0], camera) if url is not None: file_name = name + '_' + str(time.time()) file_name = file_name.replace(' ', '_') arlo.DownloadSnapshot( url, f'{self._snapshot_dir }/{file_name}.jpg') else: print(f'-- Snapshot failed from {name}.') except HTTPError as e: print(f'Error during capture: {e}.')
def get_snapshot(): while True: try: snapshot_url = camera_selenium.get_url_selenium() # print(snapshot_url) username, password = util.get_creds() # print(username) arlo = Arlo(username, password) arlo.DownloadSnapshot(snapshot_url, 'temp.jpg') img = cv2.imread('temp.jpg') img = cv2.resize(img, (1000, 500)) return img except Exception as e: print(e)
USERNAME = '******' PASSWORD = '******' try: # Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached. # Subsequent successful calls to login will update the oAuth token. arlo = Arlo(USERNAME, PASSWORD) # At this point you're logged into Arlo. # Get the list of devices and filter on device type to only get the basestation. # This will return an array which includes all of the basestation's associated metadata. basestations = arlo.GetDevices('basestation') # Get the list of devices and filter on device type to only get the camera. # This will return an array which includes all of the camera's associated metadata. cameras = arlo.GetDevices('camera') # Tells the Arlo basestation to trigger a snapshot on the given camera. # This snapshot is not instantaneous, so this method waits for the response and returns the url # for the snapshot, which is stored on the Amazon AWS servers. snapshot_url = arlo.TriggerFullFrameSnapshot(basestations[0], cameras[0]) # This method requests the snapshot for the given url and writes the image data to the location specified. # In this case, to the current directory as a file named "snapshot.jpg" # Note: Snapshots are in .jpg format. arlo.DownloadSnapshot(snapshot_url, 'snapshot.jpg') except Exception as e: print(e)
# Get the list of devices and filter on device type to only get the basestation. # This will return an array which includes all of the basestation's associated metadata. basestations = arlo.GetDevices('basestation') # Get the list of devices and filter on device type to only get the camera. # This will return an array which includes all of the camera's associated metadata. cameras = arlo.GetDevices('camera') for camera in list( filter(lambda camera: camera['deviceName'] == 'muis', cameras)): # Tells the Arlo basestation to trigger a snapshot on the given camera. # This snapshot is not instantaneous, so this method waits for the response and returns the url # for the snapshot, which is stored on the Amazon AWS servers. snapshot_url = arlo.TriggerFullFrameSnapshot(basestations[0], camera) datetime = strftime("%Y%m%d_%H%M%S", gmtime()) directory = './timelaps/' + camera['deviceName'] + '/' # create dir if not exists if not os.path.exists(directory): os.makedirs(directory) # This method requests the snapshot for the given url and writes the image data to the location specified. # In this case, to the current directory as a file named "snapshot.jpg" # Note: Snapshots are in .jpg format. arlo.DownloadSnapshot(snapshot_url, directory + datetime + '.jpg') time.sleep(20) except Exception as e: print(e)