repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
BerkeleyAutomation/perception
perception/weight_sensor.py
WeightSensor._weights_callback
def _weights_callback(self, msg): """Callback for recording weights from sensor. """ # Read weights weights = np.array(msg.data) # If needed, initialize indiv_weight_buffers if len(self._weight_buffers) == 0: self._weight_buffers = [[] for i in range(len(weig...
python
def _weights_callback(self, msg): """Callback for recording weights from sensor. """ # Read weights weights = np.array(msg.data) # If needed, initialize indiv_weight_buffers if len(self._weight_buffers) == 0: self._weight_buffers = [[] for i in range(len(weig...
Callback for recording weights from sensor.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/weight_sensor.py#L107-L121
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.vec
def vec(self): """:obj:`numpy.ndarray` : Vector representation for this camera. """ return np.r_[self.fx, self.fy, self.cx, self.cy, self.skew, self.height, self.width]
python
def vec(self): """:obj:`numpy.ndarray` : Vector representation for this camera. """ return np.r_[self.fx, self.fy, self.cx, self.cy, self.skew, self.height, self.width]
:obj:`numpy.ndarray` : Vector representation for this camera.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L136-L139
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.rosmsg
def rosmsg(self): """:obj:`sensor_msgs.CamerInfo` : Returns ROS CamerInfo msg """ from sensor_msgs.msg import CameraInfo, RegionOfInterest from std_msgs.msg import Header msg_header = Header() msg_header.frame_id = self._frame msg_roi = RegionOfInterest() ...
python
def rosmsg(self): """:obj:`sensor_msgs.CamerInfo` : Returns ROS CamerInfo msg """ from sensor_msgs.msg import CameraInfo, RegionOfInterest from std_msgs.msg import Header msg_header = Header() msg_header.frame_id = self._frame msg_roi = RegionOfInterest() ...
:obj:`sensor_msgs.CamerInfo` : Returns ROS CamerInfo msg
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L142-L171
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.crop
def crop(self, height, width, crop_ci, crop_cj): """ Convert to new camera intrinsics for crop of image from original camera. Parameters ---------- height : int height of crop window width : int width of crop window crop_ci : int row o...
python
def crop(self, height, width, crop_ci, crop_cj): """ Convert to new camera intrinsics for crop of image from original camera. Parameters ---------- height : int height of crop window width : int width of crop window crop_ci : int row o...
Convert to new camera intrinsics for crop of image from original camera. Parameters ---------- height : int height of crop window width : int width of crop window crop_ci : int row of crop window center crop_cj : int col of...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L184-L212
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.resize
def resize(self, scale): """ Convert to new camera intrinsics with parameters for resized image. Parameters ---------- scale : float the amount to rescale the intrinsics Returns ------- :obj:`CameraIntrinsics` camera intri...
python
def resize(self, scale): """ Convert to new camera intrinsics with parameters for resized image. Parameters ---------- scale : float the amount to rescale the intrinsics Returns ------- :obj:`CameraIntrinsics` camera intri...
Convert to new camera intrinsics with parameters for resized image. Parameters ---------- scale : float the amount to rescale the intrinsics Returns ------- :obj:`CameraIntrinsics` camera intrinsics for resized image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L214-L243
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.project
def project(self, point_cloud, round_px=True): """Projects a point cloud onto the camera image plane. Parameters ---------- point_cloud : :obj:`autolab_core.PointCloud` or :obj:`autolab_core.Point` A PointCloud or Point to project onto the camera image plane. round_...
python
def project(self, point_cloud, round_px=True): """Projects a point cloud onto the camera image plane. Parameters ---------- point_cloud : :obj:`autolab_core.PointCloud` or :obj:`autolab_core.Point` A PointCloud or Point to project onto the camera image plane. round_...
Projects a point cloud onto the camera image plane. Parameters ---------- point_cloud : :obj:`autolab_core.PointCloud` or :obj:`autolab_core.Point` A PointCloud or Point to project onto the camera image plane. round_px : bool If True, projections are rounded to ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L245-L284
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.deproject_to_image
def deproject_to_image(self, depth_image): """Deprojects a DepthImage into a PointCloudImage. Parameters ---------- depth_image : :obj:`DepthImage` The 2D depth image to projet into a point cloud. Returns ------- :obj:`PointCloudImage` A ...
python
def deproject_to_image(self, depth_image): """Deprojects a DepthImage into a PointCloudImage. Parameters ---------- depth_image : :obj:`DepthImage` The 2D depth image to projet into a point cloud. Returns ------- :obj:`PointCloudImage` A ...
Deprojects a DepthImage into a PointCloudImage. Parameters ---------- depth_image : :obj:`DepthImage` The 2D depth image to projet into a point cloud. Returns ------- :obj:`PointCloudImage` A point cloud image created from the depth image. ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L372-L394
BerkeleyAutomation/perception
perception/camera_intrinsics.py
CameraIntrinsics.load
def load(filename): """Load a CameraIntrinsics object from a file. Parameters ---------- filename : :obj:`str` The .intr file to load the object from. Returns ------- :obj:`CameraIntrinsics` The CameraIntrinsics object loaded from the fil...
python
def load(filename): """Load a CameraIntrinsics object from a file. Parameters ---------- filename : :obj:`str` The .intr file to load the object from. Returns ------- :obj:`CameraIntrinsics` The CameraIntrinsics object loaded from the fil...
Load a CameraIntrinsics object from a file. Parameters ---------- filename : :obj:`str` The .intr file to load the object from. Returns ------- :obj:`CameraIntrinsics` The CameraIntrinsics object loaded from the file. Raises ----...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/camera_intrinsics.py#L450-L482
BerkeleyAutomation/perception
tools/finetune_classification_cnn.py
finetune_classification_cnn
def finetune_classification_cnn(config): """ Main function. """ # read params dataset = config['dataset'] x_names = config['x_names'] y_name = config['y_name'] model_dir = config['model_dir'] debug = config['debug'] num_classes = None if 'num_classes' in config.keys(): num_c...
python
def finetune_classification_cnn(config): """ Main function. """ # read params dataset = config['dataset'] x_names = config['x_names'] y_name = config['y_name'] model_dir = config['model_dir'] debug = config['debug'] num_classes = None if 'num_classes' in config.keys(): num_c...
Main function.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/tools/finetune_classification_cnn.py#L38-L202
BerkeleyAutomation/perception
perception/kinect2_sensor.py
load_images
def load_images(cfg): """Helper function for loading a set of color images, depth images, and IR camera intrinsics. The config dictionary must have these keys: - prestored_data -- If 1, use the virtual sensor, else use a real sensor. - prestored_data_dir -- A path to the prestored data dir ...
python
def load_images(cfg): """Helper function for loading a set of color images, depth images, and IR camera intrinsics. The config dictionary must have these keys: - prestored_data -- If 1, use the virtual sensor, else use a real sensor. - prestored_data_dir -- A path to the prestored data dir ...
Helper function for loading a set of color images, depth images, and IR camera intrinsics. The config dictionary must have these keys: - prestored_data -- If 1, use the virtual sensor, else use a real sensor. - prestored_data_dir -- A path to the prestored data dir for a virtual sensor. ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L760-L802
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2Sensor.color_intrinsics
def color_intrinsics(self): """:obj:`CameraIntrinsics` : The camera intrinsics for the Kinect's color camera. """ if self._device is None: raise RuntimeError('Kinect2 device %s not runnning. Cannot return color intrinsics') camera_params = self._device.getColorCameraParams() ...
python
def color_intrinsics(self): """:obj:`CameraIntrinsics` : The camera intrinsics for the Kinect's color camera. """ if self._device is None: raise RuntimeError('Kinect2 device %s not runnning. Cannot return color intrinsics') camera_params = self._device.getColorCameraParams() ...
:obj:`CameraIntrinsics` : The camera intrinsics for the Kinect's color camera.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L123-L130
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2Sensor.ir_intrinsics
def ir_intrinsics(self): """:obj:`CameraIntrinsics` : The camera intrinsics for the Kinect's IR camera. """ if self._device is None: raise RuntimeError('Kinect2 device %s not runnning. Cannot return IR intrinsics') camera_params = self._device.getIrCameraParams() retu...
python
def ir_intrinsics(self): """:obj:`CameraIntrinsics` : The camera intrinsics for the Kinect's IR camera. """ if self._device is None: raise RuntimeError('Kinect2 device %s not runnning. Cannot return IR intrinsics') camera_params = self._device.getIrCameraParams() retu...
:obj:`CameraIntrinsics` : The camera intrinsics for the Kinect's IR camera.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L133-L142
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2Sensor.start
def start(self): """Starts the Kinect v2 sensor stream. Raises ------ IOError If the Kinect v2 is not detected. """ # open packet pipeline if self._packet_pipeline_mode == Kinect2PacketPipelineMode.OPENGL: self._pipeline = lf2.OpenGLPacket...
python
def start(self): """Starts the Kinect v2 sensor stream. Raises ------ IOError If the Kinect v2 is not detected. """ # open packet pipeline if self._packet_pipeline_mode == Kinect2PacketPipelineMode.OPENGL: self._pipeline = lf2.OpenGLPacket...
Starts the Kinect v2 sensor stream. Raises ------ IOError If the Kinect v2 is not detected.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L168-L213
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2Sensor.stop
def stop(self): """Stops the Kinect2 sensor stream. Returns ------- bool True if the stream was stopped, False if the device was already stopped or was not otherwise available. """ # check that everything is running if not self._running or...
python
def stop(self): """Stops the Kinect2 sensor stream. Returns ------- bool True if the stream was stopped, False if the device was already stopped or was not otherwise available. """ # check that everything is running if not self._running or...
Stops the Kinect2 sensor stream. Returns ------- bool True if the stream was stopped, False if the device was already stopped or was not otherwise available.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L215-L234
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2Sensor.frames
def frames(self, skip_registration=False): """Retrieve a new frame from the Kinect and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns -------...
python
def frames(self, skip_registration=False): """Retrieve a new frame from the Kinect and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns -------...
Retrieve a new frame from the Kinect and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj:`tuple` of :obj:`ColorImage`, :obj:`Dept...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L236-L256
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2Sensor._frames_and_index_map
def _frames_and_index_map(self, skip_registration=False): """Retrieve a new frame from the Kinect and return a ColorImage, DepthImage, IrImage, and a map from depth pixels to color pixel indices. Parameters ---------- skip_registration : bool If True, the registratio...
python
def _frames_and_index_map(self, skip_registration=False): """Retrieve a new frame from the Kinect and return a ColorImage, DepthImage, IrImage, and a map from depth pixels to color pixel indices. Parameters ---------- skip_registration : bool If True, the registratio...
Retrieve a new frame from the Kinect and return a ColorImage, DepthImage, IrImage, and a map from depth pixels to color pixel indices. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj:`tup...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L279-L339
BerkeleyAutomation/perception
perception/kinect2_sensor.py
KinectSensorBridged._process_image_msg
def _process_image_msg(self, msg): """ Process an image message and return a numpy array with the image data Returns ------- :obj:`numpy.ndarray` containing the image in the image message Raises ------ CvBridgeError If the bridge is not able to conver...
python
def _process_image_msg(self, msg): """ Process an image message and return a numpy array with the image data Returns ------- :obj:`numpy.ndarray` containing the image in the image message Raises ------ CvBridgeError If the bridge is not able to conver...
Process an image message and return a numpy array with the image data Returns ------- :obj:`numpy.ndarray` containing the image in the image message Raises ------ CvBridgeError If the bridge is not able to convert the image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L389-L405
BerkeleyAutomation/perception
perception/kinect2_sensor.py
KinectSensorBridged._color_image_callback
def _color_image_callback(self, image_msg): """ subscribe to image topic and keep it up to date """ color_arr = self._process_image_msg(image_msg) self._cur_color_im = ColorImage(color_arr[:,:,::-1], self._frame)
python
def _color_image_callback(self, image_msg): """ subscribe to image topic and keep it up to date """ color_arr = self._process_image_msg(image_msg) self._cur_color_im = ColorImage(color_arr[:,:,::-1], self._frame)
subscribe to image topic and keep it up to date
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L407-L411
BerkeleyAutomation/perception
perception/kinect2_sensor.py
KinectSensorBridged._depth_image_callback
def _depth_image_callback(self, image_msg): """ subscribe to depth image topic and keep it up to date """ encoding = image_msg.encoding try: depth_arr = self._bridge.imgmsg_to_cv2(image_msg, encoding) import pdb; pdb.set_trace() except CvBridgeError as e:...
python
def _depth_image_callback(self, image_msg): """ subscribe to depth image topic and keep it up to date """ encoding = image_msg.encoding try: depth_arr = self._bridge.imgmsg_to_cv2(image_msg, encoding) import pdb; pdb.set_trace() except CvBridgeError as e:...
subscribe to depth image topic and keep it up to date
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L413-L424
BerkeleyAutomation/perception
perception/kinect2_sensor.py
KinectSensorBridged.start
def start(self): """ Start the sensor """ # initialize subscribers self._image_sub = rospy.Subscriber(self.topic_image_color, sensor_msgs.msg.Image, self._color_image_callback) self._depth_sub = rospy.Subscriber(self.topic_image_depth, sensor_msgs.msg.Image, self._depth_image_callback) ...
python
def start(self): """ Start the sensor """ # initialize subscribers self._image_sub = rospy.Subscriber(self.topic_image_color, sensor_msgs.msg.Image, self._color_image_callback) self._depth_sub = rospy.Subscriber(self.topic_image_depth, sensor_msgs.msg.Image, self._depth_image_callback) ...
Start the sensor
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L449-L470
BerkeleyAutomation/perception
perception/kinect2_sensor.py
KinectSensorBridged.stop
def stop(self): """ Stop the sensor """ # check that everything is running if not self._running: logging.warning('Kinect not running. Aborting stop') return False # stop subs self._image_sub.unregister() self._depth_sub.unregister() self._...
python
def stop(self): """ Stop the sensor """ # check that everything is running if not self._running: logging.warning('Kinect not running. Aborting stop') return False # stop subs self._image_sub.unregister() self._depth_sub.unregister() self._...
Stop the sensor
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L472-L485
BerkeleyAutomation/perception
perception/kinect2_sensor.py
KinectSensorBridged.frames
def frames(self): """Retrieve a new frame from the Ensenso and convert it to a ColorImage, a DepthImage, IrImage is always none for this type Returns ------- :obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray` The ColorImage, De...
python
def frames(self): """Retrieve a new frame from the Ensenso and convert it to a ColorImage, a DepthImage, IrImage is always none for this type Returns ------- :obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray` The ColorImage, De...
Retrieve a new frame from the Ensenso and convert it to a ColorImage, a DepthImage, IrImage is always none for this type Returns ------- :obj:`tuple` of :obj:`ColorImage`, :obj:`DepthImage`, :obj:`IrImage`, :obj:`numpy.ndarray` The ColorImage, DepthImage, and IrImage of the ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L487-L513
BerkeleyAutomation/perception
perception/kinect2_sensor.py
VirtualKinect2Sensor.frames
def frames(self): """Retrieve the next frame from the image directory and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj...
python
def frames(self): """Retrieve the next frame from the image directory and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj...
Retrieve the next frame from the image directory and convert it to a ColorImage, a DepthImage, and an IrImage. Parameters ---------- skip_registration : bool If True, the registration step is skipped. Returns ------- :obj:`tuple` of :obj:`ColorImage`...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L673-L709
BerkeleyAutomation/perception
perception/kinect2_sensor.py
Kinect2SensorFactory.sensor
def sensor(sensor_type, cfg): """ Creates a Kinect2 sensor of the specified type. Parameters ---------- sensor_type : :obj:`str` the type of the sensor (real or virtual) cfg : :obj:`YamlConfig` dictionary of parameters for sensor initialization ""...
python
def sensor(sensor_type, cfg): """ Creates a Kinect2 sensor of the specified type. Parameters ---------- sensor_type : :obj:`str` the type of the sensor (real or virtual) cfg : :obj:`YamlConfig` dictionary of parameters for sensor initialization ""...
Creates a Kinect2 sensor of the specified type. Parameters ---------- sensor_type : :obj:`str` the type of the sensor (real or virtual) cfg : :obj:`YamlConfig` dictionary of parameters for sensor initialization
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/kinect2_sensor.py#L736-L758
BerkeleyAutomation/perception
ros_nodes/weight_publisher.py
WeightPublisher._connect
def _connect(self, id_mask): """Connects to all of the load cells serially. """ # Get all devices attached as USB serial all_devices = glob.glob('/dev/ttyUSB*') # Identify which of the devices are LoadStar Serial Sensors sensors = [] for device in all_devices: ...
python
def _connect(self, id_mask): """Connects to all of the load cells serially. """ # Get all devices attached as USB serial all_devices = glob.glob('/dev/ttyUSB*') # Identify which of the devices are LoadStar Serial Sensors sensors = [] for device in all_devices: ...
Connects to all of the load cells serially.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/ros_nodes/weight_publisher.py#L69-L100
BerkeleyAutomation/perception
ros_nodes/weight_publisher.py
WeightPublisher._flush
def _flush(self): """Flushes all of the serial ports. """ for ser in self._serials: ser.flush() ser.flushInput() ser.flushOutput() time.sleep(0.02)
python
def _flush(self): """Flushes all of the serial ports. """ for ser in self._serials: ser.flush() ser.flushInput() ser.flushOutput() time.sleep(0.02)
Flushes all of the serial ports.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/ros_nodes/weight_publisher.py#L103-L110
BerkeleyAutomation/perception
ros_nodes/weight_publisher.py
WeightPublisher._tare
def _tare(self): """Zeros out (tare) all of the load cells. """ for ser in self._serials: ser.write('TARE\r') ser.flush() ser.flushInput() ser.flushOutput() time.sleep(0.02)
python
def _tare(self): """Zeros out (tare) all of the load cells. """ for ser in self._serials: ser.write('TARE\r') ser.flush() ser.flushInput() ser.flushOutput() time.sleep(0.02)
Zeros out (tare) all of the load cells.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/ros_nodes/weight_publisher.py#L113-L121
BerkeleyAutomation/perception
ros_nodes/weight_publisher.py
WeightPublisher._read_weights
def _read_weights(self): """Reads weights from each of the load cells. """ weights = [] grams_per_pound = 453.592 # Read from each of the sensors for ser in self._serials: ser.write('W\r') ser.flush() time.sleep(0.02) for ser in s...
python
def _read_weights(self): """Reads weights from each of the load cells. """ weights = [] grams_per_pound = 453.592 # Read from each of the sensors for ser in self._serials: ser.write('W\r') ser.flush() time.sleep(0.02) for ser in s...
Reads weights from each of the load cells.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/ros_nodes/weight_publisher.py#L124-L150
BerkeleyAutomation/perception
perception/video_recorder.py
_Camera.run
def run(self): """ Continually write images to the filename specified by a command queue. """ if not self.camera.is_running: self.camera.start() while True: if not self.cmd_q.empty(): cmd = self.cmd_q.get() if cmd[0] == 'stop': ...
python
def run(self): """ Continually write images to the filename specified by a command queue. """ if not self.camera.is_running: self.camera.start() while True: if not self.cmd_q.empty(): cmd = self.cmd_q.get() if cmd[0] == 'stop': ...
Continually write images to the filename specified by a command queue.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/video_recorder.py#L48-L75
BerkeleyAutomation/perception
perception/video_recorder.py
VideoRecorder.start
def start(self): """ Starts the camera recording process. """ self._started = True self._camera = _Camera(self._actual_camera, self._cmd_q, self._res, self._codec, self._fps, self._rate) self._camera.start()
python
def start(self): """ Starts the camera recording process. """ self._started = True self._camera = _Camera(self._actual_camera, self._cmd_q, self._res, self._codec, self._fps, self._rate) self._camera.start()
Starts the camera recording process.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/video_recorder.py#L114-L118
BerkeleyAutomation/perception
perception/video_recorder.py
VideoRecorder.start_recording
def start_recording(self, output_file): """ Starts recording to a given output video file. Parameters ---------- output_file : :obj:`str` filename to write video to """ if not self._started: raise Exception("Must start the video recorder first by ...
python
def start_recording(self, output_file): """ Starts recording to a given output video file. Parameters ---------- output_file : :obj:`str` filename to write video to """ if not self._started: raise Exception("Must start the video recorder first by ...
Starts recording to a given output video file. Parameters ---------- output_file : :obj:`str` filename to write video to
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/video_recorder.py#L120-L133
BerkeleyAutomation/perception
perception/video_recorder.py
VideoRecorder.stop_recording
def stop_recording(self): """ Stops writing video to file. """ if not self._recording: raise Exception("Cannot stop a video recording when it's not recording!") self._cmd_q.put(('stop',)) self._recording = False
python
def stop_recording(self): """ Stops writing video to file. """ if not self._recording: raise Exception("Cannot stop a video recording when it's not recording!") self._cmd_q.put(('stop',)) self._recording = False
Stops writing video to file.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/video_recorder.py#L135-L140
BerkeleyAutomation/perception
perception/video_recorder.py
VideoRecorder.stop
def stop(self): """ Stop the camera process. """ if not self._started: raise Exception("Cannot stop a video recorder before starting it!") self._started = False if self._actual_camera.is_running: self._actual_camera.stop() if self._camera is not None: ...
python
def stop(self): """ Stop the camera process. """ if not self._started: raise Exception("Cannot stop a video recorder before starting it!") self._started = False if self._actual_camera.is_running: self._actual_camera.stop() if self._camera is not None: ...
Stop the camera process.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/video_recorder.py#L142-L153
BerkeleyAutomation/perception
perception/image.py
Image._preprocess_data
def _preprocess_data(self, data): """Converts a data array to the preferred 3D structure. Parameters ---------- data : :obj:`numpy.ndarray` The data to process. Returns ------- :obj:`numpy.ndarray` The data re-formatted (if needed) as a 3...
python
def _preprocess_data(self, data): """Converts a data array to the preferred 3D structure. Parameters ---------- data : :obj:`numpy.ndarray` The data to process. Returns ------- :obj:`numpy.ndarray` The data re-formatted (if needed) as a 3...
Converts a data array to the preferred 3D structure. Parameters ---------- data : :obj:`numpy.ndarray` The data to process. Returns ------- :obj:`numpy.ndarray` The data re-formatted (if needed) as a 3D matrix Raises ------ ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L77-L103
BerkeleyAutomation/perception
perception/image.py
Image.rosmsg
def rosmsg(self): """:obj:`sensor_msgs.Image` : ROS Image """ from cv_bridge import CvBridge, CvBridgeError cv_bridge = CvBridge() try: return cv_bridge.cv2_to_imgmsg(self._data, encoding=self._encoding) except CvBridgeError as cv_bridge_exception: ...
python
def rosmsg(self): """:obj:`sensor_msgs.Image` : ROS Image """ from cv_bridge import CvBridge, CvBridgeError cv_bridge = CvBridge() try: return cv_bridge.cv2_to_imgmsg(self._data, encoding=self._encoding) except CvBridgeError as cv_bridge_exception: ...
:obj:`sensor_msgs.Image` : ROS Image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L186-L194
BerkeleyAutomation/perception
perception/image.py
Image.can_convert
def can_convert(x): """ Returns True if x can be converted to an image, False otherwise. """ if len(x.shape) < 2 or len(x.shape) > 3: return False dtype = x.dtype height = x.shape[0] width = x.shape[1] channels = 1 if len(x.shape) == 3: cha...
python
def can_convert(x): """ Returns True if x can be converted to an image, False otherwise. """ if len(x.shape) < 2 or len(x.shape) > 3: return False dtype = x.dtype height = x.shape[0] width = x.shape[1] channels = 1 if len(x.shape) == 3: cha...
Returns True if x can be converted to an image, False otherwise.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L237-L249
BerkeleyAutomation/perception
perception/image.py
Image.from_array
def from_array(x, frame='unspecified'): """ Converts an array of data to an Image based on the values in the array and the data format. """ if not Image.can_convert(x): raise ValueError('Cannot convert array to an Image!') dtype = x.dtype height = x.shape[0] width =...
python
def from_array(x, frame='unspecified'): """ Converts an array of data to an Image based on the values in the array and the data format. """ if not Image.can_convert(x): raise ValueError('Cannot convert array to an Image!') dtype = x.dtype height = x.shape[0] width =...
Converts an array of data to an Image based on the values in the array and the data format.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L252-L291
BerkeleyAutomation/perception
perception/image.py
Image.transform
def transform(self, translation, theta, method='opencv'): """Create a new image by translating and rotating the current image. Parameters ---------- translation : :obj:`numpy.ndarray` of float The XY translation vector. theta : float Rotation angle in rad...
python
def transform(self, translation, theta, method='opencv'): """Create a new image by translating and rotating the current image. Parameters ---------- translation : :obj:`numpy.ndarray` of float The XY translation vector. theta : float Rotation angle in rad...
Create a new image by translating and rotating the current image. Parameters ---------- translation : :obj:`numpy.ndarray` of float The XY translation vector. theta : float Rotation angle in radians, with positive meaning counter-clockwise. method : :obj:...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L293-L330
BerkeleyAutomation/perception
perception/image.py
Image.align
def align(self, scale, center, angle, height, width): """ Create a thumbnail from the original image that is scaled by the given factor, centered on the center pixel, oriented along the grasp angle, and cropped to the desired height and width. Parameters ---------- scale : float...
python
def align(self, scale, center, angle, height, width): """ Create a thumbnail from the original image that is scaled by the given factor, centered on the center pixel, oriented along the grasp angle, and cropped to the desired height and width. Parameters ---------- scale : float...
Create a thumbnail from the original image that is scaled by the given factor, centered on the center pixel, oriented along the grasp angle, and cropped to the desired height and width. Parameters ---------- scale : float scale factor to apply center : 2D array ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L332-L362
BerkeleyAutomation/perception
perception/image.py
Image.gradients
def gradients(self): """Return the gradient as a pair of numpy arrays. Returns ------- :obj:`tuple` of :obj:`numpy.ndarray` of float The gradients of the image along each dimension. """ g = np.gradient(self.data.astype(np.float32)) return g
python
def gradients(self): """Return the gradient as a pair of numpy arrays. Returns ------- :obj:`tuple` of :obj:`numpy.ndarray` of float The gradients of the image along each dimension. """ g = np.gradient(self.data.astype(np.float32)) return g
Return the gradient as a pair of numpy arrays. Returns ------- :obj:`tuple` of :obj:`numpy.ndarray` of float The gradients of the image along each dimension.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L364-L373
BerkeleyAutomation/perception
perception/image.py
Image.linear_to_ij
def linear_to_ij(self, linear_inds): """Converts linear indices to row and column coordinates. Parameters ---------- linear_inds : :obj:`numpy.ndarray` of int A list of linear coordinates. Returns ------- :obj:`numpy.ndarray` of int A 2D ...
python
def linear_to_ij(self, linear_inds): """Converts linear indices to row and column coordinates. Parameters ---------- linear_inds : :obj:`numpy.ndarray` of int A list of linear coordinates. Returns ------- :obj:`numpy.ndarray` of int A 2D ...
Converts linear indices to row and column coordinates. Parameters ---------- linear_inds : :obj:`numpy.ndarray` of int A list of linear coordinates. Returns ------- :obj:`numpy.ndarray` of int A 2D ndarray whose first entry is the list of row ind...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L393-L407
BerkeleyAutomation/perception
perception/image.py
Image.is_same_shape
def is_same_shape(self, other_im, check_channels=False): """ Checks if two images have the same height and width (and optionally channels). Parameters ---------- other_im : :obj:`Image` image to compare check_channels : bool whether or not to check equali...
python
def is_same_shape(self, other_im, check_channels=False): """ Checks if two images have the same height and width (and optionally channels). Parameters ---------- other_im : :obj:`Image` image to compare check_channels : bool whether or not to check equali...
Checks if two images have the same height and width (and optionally channels). Parameters ---------- other_im : :obj:`Image` image to compare check_channels : bool whether or not to check equality of the channels Returns ------- bool ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L409-L428
BerkeleyAutomation/perception
perception/image.py
Image.mask_by_ind
def mask_by_ind(self, inds): """Create a new image by zeroing out data at locations not in the given indices. Parameters ---------- inds : :obj:`numpy.ndarray` of int A 2D ndarray whose first entry is the list of row indices and whose second entry is the ...
python
def mask_by_ind(self, inds): """Create a new image by zeroing out data at locations not in the given indices. Parameters ---------- inds : :obj:`numpy.ndarray` of int A 2D ndarray whose first entry is the list of row indices and whose second entry is the ...
Create a new image by zeroing out data at locations not in the given indices. Parameters ---------- inds : :obj:`numpy.ndarray` of int A 2D ndarray whose first entry is the list of row indices and whose second entry is the list of column indices. The ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L430-L450
BerkeleyAutomation/perception
perception/image.py
Image.mask_by_linear_ind
def mask_by_linear_ind(self, linear_inds): """Create a new image by zeroing out data at locations not in the given indices. Parameters ---------- linear_inds : :obj:`numpy.ndarray` of int A list of linear coordinates. Returns ------- :obj:`Im...
python
def mask_by_linear_ind(self, linear_inds): """Create a new image by zeroing out data at locations not in the given indices. Parameters ---------- linear_inds : :obj:`numpy.ndarray` of int A list of linear coordinates. Returns ------- :obj:`Im...
Create a new image by zeroing out data at locations not in the given indices. Parameters ---------- linear_inds : :obj:`numpy.ndarray` of int A list of linear coordinates. Returns ------- :obj:`Image` A new Image of the same type, with da...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L452-L468
BerkeleyAutomation/perception
perception/image.py
Image.median_images
def median_images(images): """Create a median Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the median of al...
python
def median_images(images): """Create a median Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the median of al...
Create a median Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the median of all of the images' data.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L493-L514
BerkeleyAutomation/perception
perception/image.py
Image.min_images
def min_images(images): """Create a min Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the min of all of ...
python
def min_images(images): """Create a min Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the min of all of ...
Create a min Image from a list of Images. Parameters ---------- :obj:`list` of :obj:`Image` A list of Image objects. Returns ------- :obj:`Image` A new Image of the same type whose data is the min of all of the images' data.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L517-L540
BerkeleyAutomation/perception
perception/image.py
Image.apply
def apply(self, method, *args, **kwargs): """Create a new image by applying a function to this image's data. Parameters ---------- method : :obj:`function` A function to call on the data. This takes in a ndarray as its first argument and optionally takes other ar...
python
def apply(self, method, *args, **kwargs): """Create a new image by applying a function to this image's data. Parameters ---------- method : :obj:`function` A function to call on the data. This takes in a ndarray as its first argument and optionally takes other ar...
Create a new image by applying a function to this image's data. Parameters ---------- method : :obj:`function` A function to call on the data. This takes in a ndarray as its first argument and optionally takes other arguments. It should return a modified data...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L600-L623
BerkeleyAutomation/perception
perception/image.py
Image.crop
def crop(self, height, width, center_i=None, center_j=None): """Crop the image centered around center_i, center_j. Parameters ---------- height : int The height of the desired image. width : int The width of the desired image. center_i : int ...
python
def crop(self, height, width, center_i=None, center_j=None): """Crop the image centered around center_i, center_j. Parameters ---------- height : int The height of the desired image. width : int The width of the desired image. center_i : int ...
Crop the image centered around center_i, center_j. Parameters ---------- height : int The height of the desired image. width : int The width of the desired image. center_i : int The center height point at which to crop. If not specified, the...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L635-L683
BerkeleyAutomation/perception
perception/image.py
Image.focus
def focus(self, height, width, center_i=None, center_j=None): """Zero out all of the image outside of a crop box. Parameters ---------- height : int The height of the desired crop box. width : int The width of the desired crop box. center_i : in...
python
def focus(self, height, width, center_i=None, center_j=None): """Zero out all of the image outside of a crop box. Parameters ---------- height : int The height of the desired crop box. width : int The width of the desired crop box. center_i : in...
Zero out all of the image outside of a crop box. Parameters ---------- height : int The height of the desired crop box. width : int The width of the desired crop box. center_i : int The center height point of the crop box. If not specified, ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L685-L723
BerkeleyAutomation/perception
perception/image.py
Image.center_nonzero
def center_nonzero(self): """Recenters the image on the mean of the coordinates of nonzero pixels. Returns ------- :obj:`Image` A new Image of the same type and size that is re-centered at the mean location of the non-zero pixels. """ # get the ce...
python
def center_nonzero(self): """Recenters the image on the mean of the coordinates of nonzero pixels. Returns ------- :obj:`Image` A new Image of the same type and size that is re-centered at the mean location of the non-zero pixels. """ # get the ce...
Recenters the image on the mean of the coordinates of nonzero pixels. Returns ------- :obj:`Image` A new Image of the same type and size that is re-centered at the mean location of the non-zero pixels.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L725-L759
BerkeleyAutomation/perception
perception/image.py
Image.nonzero_pixels
def nonzero_pixels(self): """ Return an array of the nonzero pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the nonzero pixels """ nonzero_px = np.where(np.sum(self.raw_data, axis=2) > 0) nonzero_px = np.c_[nonzero_px[0], nonzero_px[1]] ...
python
def nonzero_pixels(self): """ Return an array of the nonzero pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the nonzero pixels """ nonzero_px = np.where(np.sum(self.raw_data, axis=2) > 0) nonzero_px = np.c_[nonzero_px[0], nonzero_px[1]] ...
Return an array of the nonzero pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the nonzero pixels
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L761-L771
BerkeleyAutomation/perception
perception/image.py
Image.zero_pixels
def zero_pixels(self): """ Return an array of the zero pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the zero pixels """ zero_px = np.where(np.sum(self.raw_data, axis=2) == 0) zero_px = np.c_[zero_px[0], zero_px[1]] return zero_px
python
def zero_pixels(self): """ Return an array of the zero pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the zero pixels """ zero_px = np.where(np.sum(self.raw_data, axis=2) == 0) zero_px = np.c_[zero_px[0], zero_px[1]] return zero_px
Return an array of the zero pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the zero pixels
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L773-L783
BerkeleyAutomation/perception
perception/image.py
Image.nan_pixels
def nan_pixels(self): """ Return an array of the NaN pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the NaN pixels """ nan_px = np.where(np.isnan(np.sum(self.raw_data, axis=2))) nan_px = np.c_[nan_px[0], nan_px[1]] return nan_px
python
def nan_pixels(self): """ Return an array of the NaN pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the NaN pixels """ nan_px = np.where(np.isnan(np.sum(self.raw_data, axis=2))) nan_px = np.c_[nan_px[0], nan_px[1]] return nan_px
Return an array of the NaN pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the NaN pixels
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L785-L795
BerkeleyAutomation/perception
perception/image.py
Image.finite_pixels
def finite_pixels(self): """ Return an array of the finite pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the finite pixels """ finite_px = np.where(np.isfinite(self.data)) finite_px = np.c_[finite_px[0], finite_px[1]] return finit...
python
def finite_pixels(self): """ Return an array of the finite pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the finite pixels """ finite_px = np.where(np.isfinite(self.data)) finite_px = np.c_[finite_px[0], finite_px[1]] return finit...
Return an array of the finite pixels. Returns ------- :obj:`numpy.ndarray` Nx2 array of the finite pixels
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L797-L807
BerkeleyAutomation/perception
perception/image.py
Image.replace_zeros
def replace_zeros(self, val, zero_thresh=0.0): """ Replaces all zeros in the image with a specified value Returns ------- image dtype value to replace zeros with """ new_data = self.data.copy() new_data[new_data <= zero_thresh] = val return t...
python
def replace_zeros(self, val, zero_thresh=0.0): """ Replaces all zeros in the image with a specified value Returns ------- image dtype value to replace zeros with """ new_data = self.data.copy() new_data[new_data <= zero_thresh] = val return t...
Replaces all zeros in the image with a specified value Returns ------- image dtype value to replace zeros with
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L820-L830
BerkeleyAutomation/perception
perception/image.py
Image.save
def save(self, filename): """Writes the image to a file. Parameters ---------- filename : :obj:`str` The file to save the image to. Must be one of .png, .jpg, .npy, or .npz. Raises ------ ValueError If an unsupported file type...
python
def save(self, filename): """Writes the image to a file. Parameters ---------- filename : :obj:`str` The file to save the image to. Must be one of .png, .jpg, .npy, or .npz. Raises ------ ValueError If an unsupported file type...
Writes the image to a file. Parameters ---------- filename : :obj:`str` The file to save the image to. Must be one of .png, .jpg, .npy, or .npz. Raises ------ ValueError If an unsupported file type is specified.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L832-L864
BerkeleyAutomation/perception
perception/image.py
Image.savefig
def savefig(self, output_path, title, dpi=400, format='png', cmap=None): """Write the image to a file using pyplot. Parameters ---------- output_path : :obj:`str` The directory in which to place the file. title : :obj:`str` The title of the file in which...
python
def savefig(self, output_path, title, dpi=400, format='png', cmap=None): """Write the image to a file using pyplot. Parameters ---------- output_path : :obj:`str` The directory in which to place the file. title : :obj:`str` The title of the file in which...
Write the image to a file using pyplot. Parameters ---------- output_path : :obj:`str` The directory in which to place the file. title : :obj:`str` The title of the file in which to save the image. dpi : int The resolution in dots per inch. ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L866-L899
BerkeleyAutomation/perception
perception/image.py
Image.load_data
def load_data(filename): """Loads a data matrix from a given file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. Returns ------- :obj:`numpy.ndarray` The ...
python
def load_data(filename): """Loads a data matrix from a given file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. Returns ------- :obj:`numpy.ndarray` The ...
Loads a data matrix from a given file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. Returns ------- :obj:`numpy.ndarray` The data array read from the file.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L902-L926
BerkeleyAutomation/perception
perception/image.py
ColorImage._check_valid_data
def _check_valid_data(self, data): """Checks that the given data is a uint8 array with one or three channels. Parameters ---------- data : :obj:`numpy.ndarray` The data to check. Raises ------ ValueError If the data is invalid. ...
python
def _check_valid_data(self, data): """Checks that the given data is a uint8 array with one or three channels. Parameters ---------- data : :obj:`numpy.ndarray` The data to check. Raises ------ ValueError If the data is invalid. ...
Checks that the given data is a uint8 array with one or three channels. Parameters ---------- data : :obj:`numpy.ndarray` The data to check. Raises ------ ValueError If the data is invalid.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L973-L993
BerkeleyAutomation/perception
perception/image.py
ColorImage.bgr2rgb
def bgr2rgb(self): """ Converts data using the cv conversion. """ new_data = cv2.cvtColor(self.raw_data, cv2.COLOR_BGR2RGB) return ColorImage(new_data, frame=self.frame, encoding='rgb8')
python
def bgr2rgb(self): """ Converts data using the cv conversion. """ new_data = cv2.cvtColor(self.raw_data, cv2.COLOR_BGR2RGB) return ColorImage(new_data, frame=self.frame, encoding='rgb8')
Converts data using the cv conversion.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1024-L1027
BerkeleyAutomation/perception
perception/image.py
ColorImage.rgb2bgr
def rgb2bgr(self): """ Converts data using the cv conversion. """ new_data = cv2.cvtColor(self.raw_data, cv2.COLOR_RGB2BGR) return ColorImage(new_data, frame=self.frame, encoding='bgr8')
python
def rgb2bgr(self): """ Converts data using the cv conversion. """ new_data = cv2.cvtColor(self.raw_data, cv2.COLOR_RGB2BGR) return ColorImage(new_data, frame=self.frame, encoding='bgr8')
Converts data using the cv conversion.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1029-L1032
BerkeleyAutomation/perception
perception/image.py
ColorImage.swap_channels
def swap_channels(self, channel_swap): """ Swaps the two channels specified in the tuple. Parameters ---------- channel_swap : :obj:`tuple` of int the two channels to swap Returns ------- :obj:`ColorImage` color image with cols swapped ...
python
def swap_channels(self, channel_swap): """ Swaps the two channels specified in the tuple. Parameters ---------- channel_swap : :obj:`tuple` of int the two channels to swap Returns ------- :obj:`ColorImage` color image with cols swapped ...
Swaps the two channels specified in the tuple. Parameters ---------- channel_swap : :obj:`tuple` of int the two channels to swap Returns ------- :obj:`ColorImage` color image with cols swapped
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1034-L1056
BerkeleyAutomation/perception
perception/image.py
ColorImage.find_chessboard
def find_chessboard(self, sx=6, sy=9): """Finds the corners of an sx X sy chessboard in the image. Parameters ---------- sx : int Number of chessboard corners in x-direction. sy : int Number of chessboard corners in y-direction. Returns -...
python
def find_chessboard(self, sx=6, sy=9): """Finds the corners of an sx X sy chessboard in the image. Parameters ---------- sx : int Number of chessboard corners in x-direction. sy : int Number of chessboard corners in y-direction. Returns -...
Finds the corners of an sx X sy chessboard in the image. Parameters ---------- sx : int Number of chessboard corners in x-direction. sy : int Number of chessboard corners in y-direction. Returns ------- :obj:`list` of :obj:`numpy.ndarray`...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1080-L1124
BerkeleyAutomation/perception
perception/image.py
ColorImage.foreground_mask
def foreground_mask( self, tolerance, ignore_black=True, use_hsv=False, scale=8, bgmodel=None): """Creates a binary image mask for the foreground of an image against a uniformly colored background. The background is assumed to be th...
python
def foreground_mask( self, tolerance, ignore_black=True, use_hsv=False, scale=8, bgmodel=None): """Creates a binary image mask for the foreground of an image against a uniformly colored background. The background is assumed to be th...
Creates a binary image mask for the foreground of an image against a uniformly colored background. The background is assumed to be the mode value of the histogram for each of the color channels. Parameters ---------- tolerance : int A +/- level from the detected mean...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1147-L1205
BerkeleyAutomation/perception
perception/image.py
ColorImage.background_model
def background_model(self, ignore_black=True, use_hsv=False, scale=8): """Creates a background model for the given image. The background color is given by the modes of each channel's histogram. Parameters ---------- ignore_black : bool If True, the zero pixels will b...
python
def background_model(self, ignore_black=True, use_hsv=False, scale=8): """Creates a background model for the given image. The background color is given by the modes of each channel's histogram. Parameters ---------- ignore_black : bool If True, the zero pixels will b...
Creates a background model for the given image. The background color is given by the modes of each channel's histogram. Parameters ---------- ignore_black : bool If True, the zero pixels will be ignored when computing the background model. use_hsv : bool...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1207-L1260
BerkeleyAutomation/perception
perception/image.py
ColorImage.draw_box
def draw_box(self, box): """Draw a white box on the image. Parameters ---------- :obj:`autolab_core.Box` A 2D box to draw in the image. Returns ------- :obj:`ColorImage` A new image that is the same as the current one, but with ...
python
def draw_box(self, box): """Draw a white box on the image. Parameters ---------- :obj:`autolab_core.Box` A 2D box to draw in the image. Returns ------- :obj:`ColorImage` A new image that is the same as the current one, but with ...
Draw a white box on the image. Parameters ---------- :obj:`autolab_core.Box` A 2D box to draw in the image. Returns ------- :obj:`ColorImage` A new image that is the same as the current one, but with the white box drawn in.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1262-L1292
BerkeleyAutomation/perception
perception/image.py
ColorImage.nonzero_hsv_data
def nonzero_hsv_data(self): """ Computes non zero hsv values. Returns ------- :obj:`numpy.ndarray` array of the hsv values for the image """ hsv_data = cv2.cvtColor(self.data, cv2.COLOR_BGR2HSV) nonzero_px = self.nonzero_pixels() return hsv_da...
python
def nonzero_hsv_data(self): """ Computes non zero hsv values. Returns ------- :obj:`numpy.ndarray` array of the hsv values for the image """ hsv_data = cv2.cvtColor(self.data, cv2.COLOR_BGR2HSV) nonzero_px = self.nonzero_pixels() return hsv_da...
Computes non zero hsv values. Returns ------- :obj:`numpy.ndarray` array of the hsv values for the image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1294-L1304
BerkeleyAutomation/perception
perception/image.py
ColorImage.segment_kmeans
def segment_kmeans(self, rgb_weight, num_clusters, hue_weight=0.0): """ Segment a color image using KMeans based on spatial and color distances. Black pixels will automatically be assigned to their own 'background' cluster. Parameters ---------- rgb_weight : float ...
python
def segment_kmeans(self, rgb_weight, num_clusters, hue_weight=0.0): """ Segment a color image using KMeans based on spatial and color distances. Black pixels will automatically be assigned to their own 'background' cluster. Parameters ---------- rgb_weight : float ...
Segment a color image using KMeans based on spatial and color distances. Black pixels will automatically be assigned to their own 'background' cluster. Parameters ---------- rgb_weight : float weighting of RGB distance relative to spatial and hue distance num_cluster...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1306-L1346
BerkeleyAutomation/perception
perception/image.py
ColorImage.inpaint
def inpaint(self, win_size=3, rescale_factor=1.0): """ Fills in the zero pixels in the image. Parameters ---------- win_size : int size of window to use for inpainting rescale_factor : float amount to rescale the image for inpainting, smaller numbers incr...
python
def inpaint(self, win_size=3, rescale_factor=1.0): """ Fills in the zero pixels in the image. Parameters ---------- win_size : int size of window to use for inpainting rescale_factor : float amount to rescale the image for inpainting, smaller numbers incr...
Fills in the zero pixels in the image. Parameters ---------- win_size : int size of window to use for inpainting rescale_factor : float amount to rescale the image for inpainting, smaller numbers increase speed Returns ------- :obj:`Color...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1348-L1380
BerkeleyAutomation/perception
perception/image.py
ColorImage.to_grayscale
def to_grayscale(self): """Converts the color image to grayscale using OpenCV. Returns ------- :obj:`GrayscaleImage` Grayscale image corresponding to original color image. """ gray_data = cv2.cvtColor(self.data, cv2.COLOR_RGB2GRAY) return GrayscaleIma...
python
def to_grayscale(self): """Converts the color image to grayscale using OpenCV. Returns ------- :obj:`GrayscaleImage` Grayscale image corresponding to original color image. """ gray_data = cv2.cvtColor(self.data, cv2.COLOR_RGB2GRAY) return GrayscaleIma...
Converts the color image to grayscale using OpenCV. Returns ------- :obj:`GrayscaleImage` Grayscale image corresponding to original color image.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1393-L1402
BerkeleyAutomation/perception
perception/image.py
ColorImage.open
def open(filename, frame='unspecified'): """Creates a ColorImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the f...
python
def open(filename, frame='unspecified'): """Creates a ColorImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the f...
Creates a ColorImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the frame of reference in which the new image ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1405-L1424
BerkeleyAutomation/perception
perception/image.py
DepthImage._check_valid_data
def _check_valid_data(self, data): """Checks that the given data is a float array with one channel. Parameters ---------- data : :obj:`numpy.ndarray` The data to check. Raises ------ ValueError If the data is invalid. """ ...
python
def _check_valid_data(self, data): """Checks that the given data is a float array with one channel. Parameters ---------- data : :obj:`numpy.ndarray` The data to check. Raises ------ ValueError If the data is invalid. """ ...
Checks that the given data is a float array with one channel. Parameters ---------- data : :obj:`numpy.ndarray` The data to check. Raises ------ ValueError If the data is invalid.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1457-L1477
BerkeleyAutomation/perception
perception/image.py
DepthImage._image_data
def _image_data(self, normalize=False, min_depth=MIN_DEPTH, max_depth=MAX_DEPTH, twobyte=False): """Returns the data in image format, with scaling and conversion to uint8 types. Parameters ---------- normalize : bool ...
python
def _image_data(self, normalize=False, min_depth=MIN_DEPTH, max_depth=MAX_DEPTH, twobyte=False): """Returns the data in image format, with scaling and conversion to uint8 types. Parameters ---------- normalize : bool ...
Returns the data in image format, with scaling and conversion to uint8 types. Parameters ---------- normalize : bool whether or not to normalize by the min and max depth of the image min_depth : float minimum depth value for the normalization max_depth : ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1479-L1524
BerkeleyAutomation/perception
perception/image.py
DepthImage.threshold
def threshold(self, front_thresh=0.0, rear_thresh=100.0): """Creates a new DepthImage by setting all depths less than front_thresh and greater than rear_thresh to 0. Parameters ---------- front_thresh : float The lower-bound threshold. rear_thresh : float ...
python
def threshold(self, front_thresh=0.0, rear_thresh=100.0): """Creates a new DepthImage by setting all depths less than front_thresh and greater than rear_thresh to 0. Parameters ---------- front_thresh : float The lower-bound threshold. rear_thresh : float ...
Creates a new DepthImage by setting all depths less than front_thresh and greater than rear_thresh to 0. Parameters ---------- front_thresh : float The lower-bound threshold. rear_thresh : float The upper bound threshold. Returns -------...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1548-L1568
BerkeleyAutomation/perception
perception/image.py
DepthImage.threshold_gradients
def threshold_gradients(self, grad_thresh): """Creates a new DepthImage by zeroing out all depths where the magnitude of the gradient at that point is greater than grad_thresh. Parameters ---------- grad_thresh : float A threshold for the gradient magnitude. ...
python
def threshold_gradients(self, grad_thresh): """Creates a new DepthImage by zeroing out all depths where the magnitude of the gradient at that point is greater than grad_thresh. Parameters ---------- grad_thresh : float A threshold for the gradient magnitude. ...
Creates a new DepthImage by zeroing out all depths where the magnitude of the gradient at that point is greater than grad_thresh. Parameters ---------- grad_thresh : float A threshold for the gradient magnitude. Returns ------- :obj:`DepthIma...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1570-L1593
BerkeleyAutomation/perception
perception/image.py
DepthImage.threshold_gradients_pctile
def threshold_gradients_pctile(self, thresh_pctile, min_mag=0.0): """Creates a new DepthImage by zeroing out all depths where the magnitude of the gradient at that point is greater than some percentile of all gradients. Parameters ---------- thresh_pctile : float ...
python
def threshold_gradients_pctile(self, thresh_pctile, min_mag=0.0): """Creates a new DepthImage by zeroing out all depths where the magnitude of the gradient at that point is greater than some percentile of all gradients. Parameters ---------- thresh_pctile : float ...
Creates a new DepthImage by zeroing out all depths where the magnitude of the gradient at that point is greater than some percentile of all gradients. Parameters ---------- thresh_pctile : float percentile to threshold all gradients above min_mag : float ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1595-L1623
BerkeleyAutomation/perception
perception/image.py
DepthImage.inpaint
def inpaint(self, rescale_factor=1.0): """ Fills in the zero pixels in the image. Parameters ---------- rescale_factor : float amount to rescale the image for inpainting, smaller numbers increase speed Returns ------- :obj:`DepthImage` de...
python
def inpaint(self, rescale_factor=1.0): """ Fills in the zero pixels in the image. Parameters ---------- rescale_factor : float amount to rescale the image for inpainting, smaller numbers increase speed Returns ------- :obj:`DepthImage` de...
Fills in the zero pixels in the image. Parameters ---------- rescale_factor : float amount to rescale the image for inpainting, smaller numbers increase speed Returns ------- :obj:`DepthImage` depth image with zero pixels filled in
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1625-L1668
BerkeleyAutomation/perception
perception/image.py
DepthImage.invalid_pixel_mask
def invalid_pixel_mask(self): """ Returns a binary mask for the NaN- and zero-valued pixels. Serves as a mask for invalid pixels. Returns ------- :obj:`BinaryImage` Binary image where a pixel value greater than zero indicates an invalid pixel. """ # i...
python
def invalid_pixel_mask(self): """ Returns a binary mask for the NaN- and zero-valued pixels. Serves as a mask for invalid pixels. Returns ------- :obj:`BinaryImage` Binary image where a pixel value greater than zero indicates an invalid pixel. """ # i...
Returns a binary mask for the NaN- and zero-valued pixels. Serves as a mask for invalid pixels. Returns ------- :obj:`BinaryImage` Binary image where a pixel value greater than zero indicates an invalid pixel.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1670-L1687
BerkeleyAutomation/perception
perception/image.py
DepthImage.pixels_farther_than
def pixels_farther_than(self, depth_im, filter_equal_depth=False): """ Returns the pixels that are farther away than those in the corresponding depth image. Parameters ---------- depth_im : :obj:`DepthImage` depth image to query replacement with filte...
python
def pixels_farther_than(self, depth_im, filter_equal_depth=False): """ Returns the pixels that are farther away than those in the corresponding depth image. Parameters ---------- depth_im : :obj:`DepthImage` depth image to query replacement with filte...
Returns the pixels that are farther away than those in the corresponding depth image. Parameters ---------- depth_im : :obj:`DepthImage` depth image to query replacement with filter_equal_depth : bool whether or not to mark depth values that are equal ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1710-L1733
BerkeleyAutomation/perception
perception/image.py
DepthImage.combine_with
def combine_with(self, depth_im): """ Replaces all zeros in the source depth image with the value of a different depth image Parameters ---------- depth_im : :obj:`DepthImage` depth image to combine with Returns ------- :obj:`DepthImage` ...
python
def combine_with(self, depth_im): """ Replaces all zeros in the source depth image with the value of a different depth image Parameters ---------- depth_im : :obj:`DepthImage` depth image to combine with Returns ------- :obj:`DepthImage` ...
Replaces all zeros in the source depth image with the value of a different depth image Parameters ---------- depth_im : :obj:`DepthImage` depth image to combine with Returns ------- :obj:`DepthImage` the combined depth image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1735-L1755
BerkeleyAutomation/perception
perception/image.py
DepthImage.to_binary
def to_binary(self, threshold=0.0): """Creates a BinaryImage from the depth image. Points where the depth is greater than threshold are converted to ones, and all other points are zeros. Parameters ---------- threshold : float The depth threshold. Re...
python
def to_binary(self, threshold=0.0): """Creates a BinaryImage from the depth image. Points where the depth is greater than threshold are converted to ones, and all other points are zeros. Parameters ---------- threshold : float The depth threshold. Re...
Creates a BinaryImage from the depth image. Points where the depth is greater than threshold are converted to ones, and all other points are zeros. Parameters ---------- threshold : float The depth threshold. Returns ------- :obj:`BinaryImage...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1757-L1774
BerkeleyAutomation/perception
perception/image.py
DepthImage.to_color
def to_color(self, normalize=False): """ Convert to a color image. Parameters ---------- normalize : bool whether or not to normalize by the maximum depth Returns ------- :obj:`ColorImage` color image corresponding to the depth image ...
python
def to_color(self, normalize=False): """ Convert to a color image. Parameters ---------- normalize : bool whether or not to normalize by the maximum depth Returns ------- :obj:`ColorImage` color image corresponding to the depth image ...
Convert to a color image. Parameters ---------- normalize : bool whether or not to normalize by the maximum depth Returns ------- :obj:`ColorImage` color image corresponding to the depth image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1776-L1790
BerkeleyAutomation/perception
perception/image.py
DepthImage.to_float
def to_float(self): """ Converts to 32-bit data. Returns ------- :obj:`DepthImage` depth image with 32 bit float data """ return DepthImage(self.data.astype(np.float32), frame=self.frame)
python
def to_float(self): """ Converts to 32-bit data. Returns ------- :obj:`DepthImage` depth image with 32 bit float data """ return DepthImage(self.data.astype(np.float32), frame=self.frame)
Converts to 32-bit data. Returns ------- :obj:`DepthImage` depth image with 32 bit float data
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1792-L1800
BerkeleyAutomation/perception
perception/image.py
DepthImage.point_normal_cloud
def point_normal_cloud(self, camera_intr): """Computes a PointNormalCloud from the depth image. Parameters ---------- camera_intr : :obj:`CameraIntrinsics` The camera parameters on which this depth image was taken. Returns ------- :obj:`autolab_core....
python
def point_normal_cloud(self, camera_intr): """Computes a PointNormalCloud from the depth image. Parameters ---------- camera_intr : :obj:`CameraIntrinsics` The camera parameters on which this depth image was taken. Returns ------- :obj:`autolab_core....
Computes a PointNormalCloud from the depth image. Parameters ---------- camera_intr : :obj:`CameraIntrinsics` The camera parameters on which this depth image was taken. Returns ------- :obj:`autolab_core.PointNormalCloud` A PointNormalCloud creat...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1802-L1822
BerkeleyAutomation/perception
perception/image.py
DepthImage.open
def open(filename, frame='unspecified'): """Creates a DepthImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the f...
python
def open(filename, frame='unspecified'): """Creates a DepthImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the f...
Creates a DepthImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the frame of reference in which the new image ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1825-L1847
BerkeleyAutomation/perception
perception/image.py
IrImage._image_data
def _image_data(self): """Returns the data in image format, with scaling and conversion to uint8 types. Returns ------- :obj:`numpy.ndarray` of uint8 A 3D matrix representing the image. The first dimension is rows, the second is columns, and the third is simply t...
python
def _image_data(self): """Returns the data in image format, with scaling and conversion to uint8 types. Returns ------- :obj:`numpy.ndarray` of uint8 A 3D matrix representing the image. The first dimension is rows, the second is columns, and the third is simply t...
Returns the data in image format, with scaling and conversion to uint8 types. Returns ------- :obj:`numpy.ndarray` of uint8 A 3D matrix representing the image. The first dimension is rows, the second is columns, and the third is simply the IR entry scaled to between 0 an...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1897-L1906
BerkeleyAutomation/perception
perception/image.py
IrImage.resize
def resize(self, size, interp='bilinear'): """Resize the image. Parameters ---------- size : int, float, or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : :obj:`str...
python
def resize(self, size, interp='bilinear'): """Resize the image. Parameters ---------- size : int, float, or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : :obj:`str...
Resize the image. Parameters ---------- size : int, float, or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : :obj:`str`, optional Interpolation to use for re-si...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1908-L1928
BerkeleyAutomation/perception
perception/image.py
IrImage.open
def open(filename, frame='unspecified'): """Creates an IrImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the fra...
python
def open(filename, frame='unspecified'): """Creates an IrImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the fra...
Creates an IrImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the frame of reference in which the new image l...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L1931-L1951
BerkeleyAutomation/perception
perception/image.py
GrayscaleImage.resize
def resize(self, size, interp='bilinear'): """Resize the image. Parameters ---------- size : int, float, or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : :obj:`str...
python
def resize(self, size, interp='bilinear'): """Resize the image. Parameters ---------- size : int, float, or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : :obj:`str...
Resize the image. Parameters ---------- size : int, float, or tuple * int - Percentage of current size. * float - Fraction of current size. * tuple - Size of the output image. interp : :obj:`str`, optional Interpolation to use for re-si...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2014-L2034
BerkeleyAutomation/perception
perception/image.py
GrayscaleImage.to_color
def to_color(self): """Convert the grayscale image to a ColorImage. Returns ------- :obj:`ColorImage` A color image equivalent to the grayscale one. """ color_data = np.repeat(self.data[:,:,np.newaxis], 3, axis=2) return ColorImage(color_data, self._f...
python
def to_color(self): """Convert the grayscale image to a ColorImage. Returns ------- :obj:`ColorImage` A color image equivalent to the grayscale one. """ color_data = np.repeat(self.data[:,:,np.newaxis], 3, axis=2) return ColorImage(color_data, self._f...
Convert the grayscale image to a ColorImage. Returns ------- :obj:`ColorImage` A color image equivalent to the grayscale one.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2036-L2045
BerkeleyAutomation/perception
perception/image.py
GrayscaleImage.open
def open(filename, frame='unspecified'): """Creates a GrayscaleImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing t...
python
def open(filename, frame='unspecified'): """Creates a GrayscaleImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing t...
Creates a GrayscaleImage from a file. Parameters ---------- filename : :obj:`str` The file to load the data from. Must be one of .png, .jpg, .npy, or .npz. frame : :obj:`str` A string representing the frame of reference in which the new image ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2048-L2067
BerkeleyAutomation/perception
perception/image.py
BinaryImage.pixelwise_or
def pixelwise_or(self, binary_im): """ Takes OR operation with other binary image. Parameters ---------- binary_im : :obj:`BinaryImage` binary image for and operation Returns ------- :obj:`BinaryImage` OR of this binary image and other im...
python
def pixelwise_or(self, binary_im): """ Takes OR operation with other binary image. Parameters ---------- binary_im : :obj:`BinaryImage` binary image for and operation Returns ------- :obj:`BinaryImage` OR of this binary image and other im...
Takes OR operation with other binary image. Parameters ---------- binary_im : :obj:`BinaryImage` binary image for and operation Returns ------- :obj:`BinaryImage` OR of this binary image and other image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2179-L2195
BerkeleyAutomation/perception
perception/image.py
BinaryImage.inverse
def inverse(self): """ Inverts image (all nonzeros become zeros and vice verse) Returns ------- :obj:`BinaryImage` inverse of this binary image """ data = np.zeros(self.shape).astype(np.uint8) ind = np.where(self.data == 0) data[ind[0], ind[1],...
python
def inverse(self): """ Inverts image (all nonzeros become zeros and vice verse) Returns ------- :obj:`BinaryImage` inverse of this binary image """ data = np.zeros(self.shape).astype(np.uint8) ind = np.where(self.data == 0) data[ind[0], ind[1],...
Inverts image (all nonzeros become zeros and vice verse) Returns ------- :obj:`BinaryImage` inverse of this binary image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2197-L2207
BerkeleyAutomation/perception
perception/image.py
BinaryImage.prune_contours
def prune_contours(self, area_thresh=1000.0, dist_thresh=20, preserve_topology=True): """Removes all white connected components with area less than area_thresh. Parameters ---------- area_thresh : float The minimum area for which a white connected compo...
python
def prune_contours(self, area_thresh=1000.0, dist_thresh=20, preserve_topology=True): """Removes all white connected components with area less than area_thresh. Parameters ---------- area_thresh : float The minimum area for which a white connected compo...
Removes all white connected components with area less than area_thresh. Parameters ---------- area_thresh : float The minimum area for which a white connected component will not be zeroed out. dist_thresh : int If a connected component is within dist_t...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2209-L2290
BerkeleyAutomation/perception
perception/image.py
BinaryImage.find_contours
def find_contours(self, min_area=0.0, max_area=np.inf): """Returns a list of connected components with an area between min_area and max_area. Parameters ---------- min_area : float The minimum area for a contour max_area : float The maximum area fo...
python
def find_contours(self, min_area=0.0, max_area=np.inf): """Returns a list of connected components with an area between min_area and max_area. Parameters ---------- min_area : float The minimum area for a contour max_area : float The maximum area fo...
Returns a list of connected components with an area between min_area and max_area. Parameters ---------- min_area : float The minimum area for a contour max_area : float The maximum area for a contour Returns ------- :obj:`list` of ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2292-L2327
BerkeleyAutomation/perception
perception/image.py
BinaryImage.contour_mask
def contour_mask(self, contour): """ Generates a binary image with only the given contour filled in. """ # fill in new data new_data = np.zeros(self.data.shape) num_boundary = contour.boundary_pixels.shape[0] boundary_px_ij_swapped = np.zeros([num_boundary, 1, 2]) boundar...
python
def contour_mask(self, contour): """ Generates a binary image with only the given contour filled in. """ # fill in new data new_data = np.zeros(self.data.shape) num_boundary = contour.boundary_pixels.shape[0] boundary_px_ij_swapped = np.zeros([num_boundary, 1, 2]) boundar...
Generates a binary image with only the given contour filled in.
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2329-L2344
BerkeleyAutomation/perception
perception/image.py
BinaryImage.boundary_map
def boundary_map(self): """ Computes the boundary pixels in the image and sets them to nonzero values. Returns ------- :obj:`BinaryImage` binary image with nonzeros on the boundary of the original image """ # compute contours contours = self.find_cont...
python
def boundary_map(self): """ Computes the boundary pixels in the image and sets them to nonzero values. Returns ------- :obj:`BinaryImage` binary image with nonzeros on the boundary of the original image """ # compute contours contours = self.find_cont...
Computes the boundary pixels in the image and sets them to nonzero values. Returns ------- :obj:`BinaryImage` binary image with nonzeros on the boundary of the original image
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2346-L2362
BerkeleyAutomation/perception
perception/image.py
BinaryImage.closest_pixel_to_set
def closest_pixel_to_set(self, start, pixel_set, direction, w=13, t=0.5): """Starting at pixel, moves start by direction * t until there is a pixel from pixel_set within a radius w of start. Then, returns start. Parameters ---------- start : :obj:`numpy.ndarray` of float ...
python
def closest_pixel_to_set(self, start, pixel_set, direction, w=13, t=0.5): """Starting at pixel, moves start by direction * t until there is a pixel from pixel_set within a radius w of start. Then, returns start. Parameters ---------- start : :obj:`numpy.ndarray` of float ...
Starting at pixel, moves start by direction * t until there is a pixel from pixel_set within a radius w of start. Then, returns start. Parameters ---------- start : :obj:`numpy.ndarray` of float The initial pixel location at which to start. pixel_set : set of 2-tupl...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2364-L2426
BerkeleyAutomation/perception
perception/image.py
BinaryImage.closest_allzero_pixel
def closest_allzero_pixel(self, pixel, direction, w=13, t=0.5): """Starting at pixel, moves pixel by direction * t until all zero pixels within a radius w of pixel. Then, returns pixel. Parameters ---------- pixel : :obj:`numpy.ndarray` of float The initial pixel loc...
python
def closest_allzero_pixel(self, pixel, direction, w=13, t=0.5): """Starting at pixel, moves pixel by direction * t until all zero pixels within a radius w of pixel. Then, returns pixel. Parameters ---------- pixel : :obj:`numpy.ndarray` of float The initial pixel loc...
Starting at pixel, moves pixel by direction * t until all zero pixels within a radius w of pixel. Then, returns pixel. Parameters ---------- pixel : :obj:`numpy.ndarray` of float The initial pixel location at which to start. direction : :obj:`numpy.ndarray` of float...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2484-L2542
BerkeleyAutomation/perception
perception/image.py
BinaryImage.add_frame
def add_frame( self, left_boundary, right_boundary, upper_boundary, lower_boundary): """ Adds a frame to the image, e.g. turns the boundaries white Parameters ---------- left_boundary : int the leftmost boundary of ...
python
def add_frame( self, left_boundary, right_boundary, upper_boundary, lower_boundary): """ Adds a frame to the image, e.g. turns the boundaries white Parameters ---------- left_boundary : int the leftmost boundary of ...
Adds a frame to the image, e.g. turns the boundaries white Parameters ---------- left_boundary : int the leftmost boundary of the frame right_boundary : int the rightmost boundary of the frame (must be greater than left_boundary) upper_boundary : int ...
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2544-L2587