whack_a_mole.mole_detection module
Python library for CV operations for the Whack-a-Mole game.
- class whack_a_mole.mole_detection.OpenCVClient(freq=30.0, clipping_distance=1400, crop=[(1, 1), (1, 1)])
Bases:
object
A class to handle the OpenCV operations for the mole detection.
Attributes
clipping_distance (int): The clipping distance for the depth image.
crop (list): The crop region for the image.
- _running_avg (dict): A dictionary to store the running average of the
centroids.
_camera_intrinsics (np.array): The camera intrinsics.
_color_image (np.array): The color image.
_depth_image (np.array): The depth image.
Functions:
- find_centroid_cropped(masked_image, crop_indices):
Find the centroid of the largest contour within a specified crop region.
- find_color_centroid(lower_HSV, higher_HSV):
Returns the pixel indecies of the centroid of a color defined in lower_HSV , higher_HSV range
- get_3d_coordinates_at_pixel(x, y, frame_name):
Convert the pixel coordinates (x, y) to 3D camera coordinates in meters.
- property camera_intrinsics
Getter for the camera intrinsics.
- property color_image
Getter for the color image.
- property depth_image
Getter for the depth image.
- detect_illumination(color: str)
Detect the illumination of the mole.
- find_centroid_cropped(masked_image, crop_indices)
Find the centroid of the largest contour in specified crop region.
Args:
masked_image (np.array): The masked image to process.
- crop_indices (tuple): A tuple (x1, y1, x2, y2) specifying the crop
region.
Returns
- (int, int): The (x, y) coordinates of the centroid in the original
image.
- get_3d_coordinates_at_pixel(x, y, frame_name='')
Convert the pixel coordinates (x, y) to 3D coordinates in meters.
- property running_avg
Getter for the running average.