cameratools¶
NOTE: This module is a feature under developement.
- class pyvale.cameratools.CameraTools[source]¶
Bases:
object
- static blender_FOV(cam_data: CameraData) tuple[float, float] [source]¶
A method to calculate the camera's field of view in mm using Blender's method. This method differs due to one simplification.
- Parameters:
cam_data (CameraData) -- A dataclass containing the camera parameters
- Returns:
tuple[float, float] -- A tuple containing the FOV in x and y directions
- static blender_camera_from_resolution(pixels_num: ndarray, pixels_size: ndarray, working_dist: float, resolution: float) CameraData [source]¶
A convenience function to create a camera object in Blender from its pixels, the pixel size, the working distance and desired resolution.
- Parameters:
pixels_num (np.ndarray) -- The number of pixels in the camera, in the x and y directions.
pixels_size (np.ndarray) -- The camera pixels size in mm, in the x and y directions.
working_dist (float) -- The working distance of the camera.
resolution (float) -- The desired mm/px resolution
- Returns:
CameraData -- A dataclass containing the created camera's parameters.
- static build_sensor_data_from_camera_2d(cam_data: CameraData2D) SensorData [source]¶
- static calc_resolution_from_sim_2d(pixels_count: ndarray, coords: ndarray, pixels_border: int, view_plane_axes: tuple[int, int] = (0, 1)) float [source]¶
- static calculate_FOV(cam_data: CameraData) tuple[float, float] [source]¶
A method to calulate the camera's field of view in mm
- Parameters:
cam_data (CameraData) -- A dataclass containing the camera parameters
- Returns:
tuple[float, float] -- A tuple containing the field of view in mm in both x and y directions
- static calculate_mm_px_resolution(cam_data: CameraData) float [source]¶
Function to calculate the mm/px resolution of a camera
- Parameters:
cam_data (CameraData) -- A dataclass containing the camera parameters
- Returns:
float -- The mm/px resolution
- static crop_image_rectangle(image: ndarray, pixels_count: ndarray, corner: tuple[int, int] = (0, 0)) ndarray [source]¶
- static faceon_stereo_cameras(cam_data_0: CameraData, stereo_angle: float) CameraStereo [source]¶
A convenience function to set up a face-on stereo camera system, given an initial CameraData dataclass and a stereo angle. This assumes the basic camera parameters are the same.
- Parameters:
cam_data_0 (CameraData) -- A dataclass containing the camera parameters for a single camera, which will be camera 0.
stereo_angle (float) -- The stereo angle between the two cameras.
- Returns:
CameraStereo -- An instance of the CameraStereo class. This class contains information about each of the cameras, as well as the extrinsic parameters between them.
- static focal_length_from_resolution(pixels_size: ndarray, working_dist: float, resolution: float) float [source]¶
A method to calculate the required focal length to achieve a certain resolution. This is calculated given the pixel size and working distance. This method can be used for a 2D setup or for camera 0 for a stereo setup.
- Parameters:
pixels_size (np.ndarray) -- The camera pixel size in the x and y directions (in mm).
working_dist (float) -- The working distance of the camera to the sample.
resolution (float) -- The desired resolution in mm/px.
- Returns:
float -- The focal length required to obtain the desired image resolution.
- static image_dist_from_fov_3d(pixel_num: ndarray, pixel_size: ndarray, focal_leng: float, fov_leng: ndarray) ndarray [source]¶
- static pixel_grid_leng(field_of_view: ndarray, leng_per_px: float) tuple[ndarray, ndarray] [source]¶
- static pos_fill_frame(coords_world: ndarray, pixel_num: ndarray, pixel_size: ndarray, focal_leng: float, cam_rot: Rotation, frame_fill: float = 1.0) tuple[ndarray, ndarray] [source]¶
- static pos_fill_frame_all(coords_world_list: list[ndarray], pixel_num: ndarray, pixel_size: ndarray, focal_leng: float, cam_rot: Rotation, frame_fill: float = 1.0) tuple[ndarray, ndarray] [source]¶
- static subpixel_grid_leng(field_of_view: ndarray, leng_per_px: float, subsample: int = 2) tuple[ndarray, ndarray] [source]¶
- static subpixel_grid_px(pixels_count: ndarray, subsample: int = 2) tuple[ndarray, ndarray] [source]¶
- static subpixel_vec_leng(field_of_view: ndarray, leng_per_px: float, subsample: int = 2) tuple[ndarray, ndarray] [source]¶
- static symmetric_stereo_cameras(cam_data_0: CameraData, stereo_angle: float) CameraStereo [source]¶
A convenience function to set up a symmetric stereo camera system, given an initial CameraData dataclass and a stereo angle. This assumes the basic camera parameters are the same.
- Parameters:
cam_data_0 (CameraData) -- A dataclass containing the camera parameters for a single camera, which will be camera 0.
stereo_angle (float) -- The stereo angle between the two cameras.
- Returns:
CameraStereo -- An instance of the CameraStereo class. This class contains information about each of the cameras, as well as the extrinsic parameters between them.
- static vectorise_pixel_grid_leng(field_of_view: ndarray, leng_per_px: float) tuple[ndarray, ndarray] [source]¶