vision_utils
RandomScale
Rescale the input PIL.Image to the given size.
Args:
minsize (sequence or int): Desired min output size. If size is a sequence like
(w, h), output size will be matched to this. If size is an int,
smaller edge of the image will be matched to this number.
i.e, if height > width, then image will be rescaled to
(size * height / width, size)
maxsize (sequence or int): Desired max output size. If size is a sequence like
(w, h), output size will be matched to this. If size is an int,
smaller edge of the image will be matched to this number.
i.e, if height > width, then image will be rescaled to
(size * height / width, size)
interpolation (int, optional): Desired interpolation. Default is PIL.Image.BILINEAR
Source code in omnigibson/utils/vision_utils.py
__call__(img)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
Image
|
Image to be scaled. |
required |
Returns:
Type | Description |
---|---|
Image
|
Rescaled image. |
Source code in omnigibson/utils/vision_utils.py
Remapper
Remaps values in an image from old_mapping to new_mapping using an efficient key_array. See more details in the remap method.
Source code in omnigibson/utils/vision_utils.py
clear()
remap(old_mapping, new_mapping, image, image_keys=None)
Remaps values in the given image from old_mapping to new_mapping using an efficient key_array. If the image contains values that are not in old_mapping, they are remapped to the value in new_mapping that corresponds to 'unlabelled'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
old_mapping
|
dict
|
The old mapping dictionary that maps a set of image values to labels e.g. {1: 'desk', 2: 'chair'}. |
required |
new_mapping
|
dict
|
The new mapping dictionary that maps another set of image values to labels, e.g. {5: 'desk', 7: 'chair', 100: 'unlabelled'}. |
required |
image
|
tensor
|
The 2D image to remap, e.g. [[1, 3], [1, 2]]. |
required |
image_keys
|
tensor
|
The unique keys in the image, e.g. [1, 2, 3]. |
None
|
Returns:
Type | Description |
---|---|
tensor
|
The remapped image, e.g. [[5,100],[5,7]]. |
dict
|
The remapped labels dictionary, e.g. {5: 'desk', 7: 'chair', 100: 'unlabelled'}. |
Source code in omnigibson/utils/vision_utils.py
colorize_bboxes_3d(bbox_3d_data, rgb_image, camera_params)
Project 3D bounding box data onto 2D and colorize the bounding boxes for visualization. Reference: https://forums.developer.nvidia.com/t/mathematical-definition-of-3d-bounding-boxes-annotator-nvidia-omniverse-isaac-sim/223416
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bbox_3d_data
|
tensor
|
3D bounding box data |
required |
rgb_image
|
tensor
|
RGB image |
required |
camera_params
|
dict
|
Camera parameters |
required |
Returns:
Type | Description |
---|---|
tensor
|
RGB image with 3D bounding boxes drawn |
Source code in omnigibson/utils/vision_utils.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
randomize_colors(N, bright=True)
Modified from https://github.com/matterport/Mask_RCNN/blob/master/mrcnn/visualize.py#L59 Generate random colors. To get visually distinct colors, generate them in HSV space then convert to RGB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N
|
int
|
Number of colors to generate |
required |
Returns:
Type | Description |
---|---|
bright (bool
|
whether to increase the brightness of the colors or not |
Source code in omnigibson/utils/vision_utils.py
segmentation_to_rgb(seg_im, N, colors=None)
Helper function to visualize segmentations as RGB frames. NOTE: assumes that geom IDs go up to N at most - if not, multiple geoms might be assigned to the same color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seg_im
|
W, H)-array
|
Segmentation image |
required |
N
|
int
|
Maximum segmentation ID from @seg_im |
required |
colors
|
None or list of 3-array
|
If specified, colors to apply to different segmentation IDs. Otherwise, will be generated randomly |
None
|