def get_sequence(self, num_frames, exp_time=None, interval=None): """Calls the pvc.get_frame function with the current camera settings in rapid-succession for the specified number of frames Parameter: num_frames (int): Number of frames to capture in the sequence exp_time (int): The exposure time (optional) interval (int): The time in milliseconds to wait between captures Returns: A 3D np.array containing the pixel data from the captured frames. """ x_start, x_end, y_start, y_end = self.__roi if not isinstance(exp_time, int): exp_time = self.exp_time stack = np.empty((num_frames, self.__shape[1], self.__shape[0]), dtype=np.uint16) for i in range(num_frames): stack[i] = pvc.get_frame(self.__handle, x_start, x_end - 1, self.bin_x, y_start, y_end - 1, self.bin_y, exp_time, self.__mode).reshape(self.__shape[1], self.__shape[0]) if isinstance(interval, int): time.sleep(interval/1000) return stack
def poll_frame(self): """Calls the pvc.get_frame function with the current camera settings. Parameter: None Returns: A dictionary with the frame containing available meta data and 2D np.array pixel data, frames per second and frame count. """ frame, fps, frame_count = pvc.get_frame(self.__handle, self.__shape[0], self.__shape[1], self.__bits_per_pixel) frame['pixel_data'] = frame['pixel_data'].reshape(self.__shape[1], self.__shape[0]) frame['pixel_data'] = np.copy(frame['pixel_data']) return frame, fps, frame_count
def get_vtm_sequence(self, time_list, exp_res, num_frames, interval=None): """Calls the pvc.get_frame function within a loop, setting vtm expTime between each capture. Parameter: time_list (list of ints): List of vtm timings exp_res (int): vtm exposure time resolution (0:mili, 1:micro) num_frames (int): Number of frames to capture in the sequence interval (int): The time in milliseconds to wait between captures Returns: A 3D np.array containing the pixel data from the captured sequence. """ # Checking to see if all timings are valid (max val is uint16 max) for t in time_list: if t not in range(2**16): raise ValueError( "Invalid value: {} - {} only supports vtm times " "between {} and {}".format(t, self, 0, 2**16)) x_start, x_end, y_start, y_end = self.__roi old_res = self.exp_res self.exp_res = exp_res stack = np.empty((num_frames, self.shape[1], self.shape[0]), dtype=np.uint16) t = iter( time_list) # using time_list iterator to loop through all values for i in range(num_frames): try: self.vtm_exp_time = next(t) except: t = iter(time_list) self.vtm_exp_time = next(t) stack[i] = pvc.get_frame(self.__handle, x_start, x_end - 1, self.bin_x, y_start, y_end - 1, self.bin_y, self.exp_time, self.__mode).reshape( self.__shape[1], self.__shape[0]) if isinstance(interval, int): time.sleep(interval / 1000) self.exp_res = old_res return stack
def get_frame(self, exp_time=None): """Calls the pvc.get_frame function with the current camera settings. Parameter: exp_time (int): The exposure time (optional). Returns: A 2D np.array containing the pixel data from the captured frame. """ # If there is an roi specified, use that, otherwise, use the full sensor # size. x_start, x_end, y_start, y_end = self.__roi if not isinstance(exp_time, int): exp_time = self.exp_time tmpFrame = pvc.get_frame(self.__handle, x_start, x_end - 1, self.bin_x, y_start, y_end - 1, self.bin_y, exp_time, self.__mode).reshape(self.__shape[1], self.__shape[0]) return np.copy(tmpFrame)
def poll_frame(self, timeout_ms=WAIT_FOREVER, oldestFrame=True, copyData=True): """Calls the pvc.get_frame function with the current camera settings. Parameter: oldestFrame (bool): Selects whether to return the oldest or newest frame. Only the oldest frame will be popped off the underlying queue of frames. (optional). copyData (bool): Selects whether to return a copy of the numpy frame which points to a new buffer, or the original numpy frame which points to the buffer used directly by PVCAM. Disabling this copy is not recommended for most situations. Refer to PyVCAM Wrapper.md for more details. (optional). None Returns: A dictionary with the frame containing available meta data and 2D np.array pixel data, frames per second and frame count. """ frame, fps, frame_count = pvc.get_frame(self.__handle, self.__rois, self.__dtype.num, timeout_ms, oldestFrame) num_rois = len(frame['pixel_data']) if copyData: frameTmp = {'pixel_data': [None] * num_rois} for roi_index in range(num_rois): frameTmp['pixel_data'][roi_index] = np.copy( frame['pixel_data'][roi_index]) if 'meta_data' in frame.keys(): frameTmp['meta_data'] = deepcopy(frame['meta_data']) frame = frameTmp # If using a single ROI, remove list container if num_rois == 1: frame['pixel_data'] = frame['pixel_data'][0] return frame, fps, frame_count