trifinger_cameras.utils module¶
Utility functions.
- trifinger_cameras.utils.check_image_sharpness(image: ndarray, canny_threshold1: float = 25.0, canny_threshold2: float = 250.0) Tuple[float, ndarray] [source]¶
Estimate sharpness of the given image, using edge detection.
Uses Canny edge detection to estimate how sharp the images are (more edges = sharper). If the mean value of the edge image is below a certain threshold, this might mean that the corresponding camera is out of focus and should be checked.
See https://stackoverflow.com/a/66557408
- Parameters:
image – Input image.
canny_threshold1 – See
cv2.Canny
.canny_threshold2 – See
cv2.Canny
.
- Returns:
Tuple (edge_mean, edge_image). Where edge_mean is the mean value of the edge image. A higher mean value means more edges and thus indicates a sharper image. edge_image shows the detected edges. It is returned mostly for debugging and visualisation purposes.
- trifinger_cameras.utils.convert_image(raw_image, format: str = 'bgr') ndarray [source]¶
Convert raw image from camera observation.
- Parameters:
raw_image – Raw image from camera observation.
format (str) – Format of the output image. One of “bgr”, “rgb”, “gray”. Defaults to “bgr” which is the default format of OpenCV.
- Returns:
The converted image as NumPy array.
- trifinger_cameras.utils.print_tricamera_sensor_info(tricamera_info: TriCameraInfo) None [source]¶
Pretty-print the sensor info struct of the TriCamera driver.
- trifinger_cameras.utils.rodrigues_to_matrix(rvec)[source]¶
Convert Rodrigues vector to homogeneous transformation matrix.
- Parameters:
rvec (array-like) – Rotation in Rodrigues format as returned by OpenCV.
- Returns:
Given rotation as a 4x4 homogeneous transformation matrix.
- Return type:
quaternion (array-like)