Returns coords of a 2d box given points in sensor coords Args: cords ([type]): [description] Returns: [type]: [description]
(self, cords)
| 618 | |
| 619 | |
| 620 | def _coords_to_2d_bb(self, cords): |
| 621 | """Returns coords of a 2d box given points in sensor coords |
| 622 | |
| 623 | Args: |
| 624 | cords ([type]): [description] |
| 625 | |
| 626 | Returns: |
| 627 | [type]: [description] |
| 628 | """ |
| 629 | cords_y_minus_z_x = np.vstack((cords[1, :], -cords[2, :], cords[0, :])) |
| 630 | |
| 631 | bbox = (self._sensor_data['calibration'] @ cords_y_minus_z_x).T |
| 632 | |
| 633 | camera_bbox = np.vstack([bbox[:, 0] / bbox[:, 2], bbox[:, 1] / bbox[:, 2], bbox[:, 2]]).T |
| 634 | |
| 635 | if np.any(camera_bbox[:,2] > 0): |
| 636 | |
| 637 | camera_bbox = np.array(camera_bbox) |
| 638 | _positive_bb = camera_bbox[camera_bbox[:,2] > 0] |
| 639 | |
| 640 | min_x = int(np.clip(np.min(_positive_bb[:,0]), 0, self._sensor_data['width'])) |
| 641 | min_y = int(np.clip(np.min(_positive_bb[:,1]), 0, self._sensor_data['height'])) |
| 642 | max_x = int(np.clip(np.max(_positive_bb[:,0]), 0, self._sensor_data['width'])) |
| 643 | max_y = int(np.clip(np.max(_positive_bb[:,1]), 0, self._sensor_data['height'])) |
| 644 | |
| 645 | return [(min_x,min_y),(max_x,max_y)] |
| 646 | else: |
| 647 | return None |
| 648 | |
| 649 | |
| 650 | def _change_seg_stop(self, seg_img, depth_img, stop_signs, cam, _region_size=6): |
no outgoing calls
no test coverage detected