Core

Module to connect the stitching and mapping from image coordinates to world coordinates.

class Surveyor(config=None)[source][source]

Bases: object

Class to determine the relationship between two images of one comb side .

The Surveyor determines all needed data to stitch two images from different areas of one comb side to a complete view of the comb. On this basis the Surveyor can also be used to map the coordinates from these images to hive coordinates.

load(path)[source][source]

Load saved parameters for mapping from file.

Parameters:path (str) – Path of the file, which holds the needed data.
save(path)[source][source]

Save parameters of the Surveyor needed for later stitching to a file.

Parameters:path (str) – Path of the output file. The extension must be ‘.npz’ or ‘.csv’.

See also

determine_mapping_parameters(path_l, path_r, angl_l, angl_r, cam_id_l, cam_id_r, stitcher_type)[source][source]

Determine the parameters for mapping of images and coordinates.

This functions is used to calculate all needed data to stitch two images and to map image coordinates/angels to hive coordinates/angles.

Parameters:
  • path_l (str) – Path to the left image.
  • path_r (str) – Path to the right image.
  • angl_l (int) – Angle in degree to rotate left image.
  • angl_r (int) – Angle in degree to rotate right image.
  • cam_id_l (int) – ID of the camera, which shot the left image.
  • cam_id_r (int) – ID of the camera, which shot the right image.
  • stitcher_type (Stitcher) – Stitcher to use for stitching of the images.
get_parameters()[source][source]

Return the estimated or loaded parameters of the Surveyor needed for later stitching.

With this function you could save the Surveyor parameters and load them later for further stitching of images and mapping of image coordinates/angels to hive coordinates/angles in relation to hive.

set_parameters(homo_left, homo_right, size_left, size_right, cam_id_l, cam_id_r, origin, ratio_px_mm)[source][source]

Load needed parameters for mapping image points/angles to hive coordinates/angles.

This function becomes handy if you calculated the parameters in an earlier surveying process and did not want to calculate the parameters again and just want to map image points/angles to hive coordinates/angles.

Parameters:
  • homo_left (ndarray) – homography (3,3) for data from the left side to form a panorama.
  • homo_right (ndarray) – homography (3,3) for data from the right side to form a panorama.
  • size_left (tuple) – Size of the left image in px, which was used to calculate homography.
  • size_right (tuple) – Size of the right image in px, which was used to calculate homography.
  • cam_id_l (int) – ID of the camera, which shot the left image.
  • cam_id_r (int) – ID of the camera, which shot the right image.
  • origin (ndarray) – Origin of the stitched data/image in px (2,).
  • ratio_px_mm (float) – Ratio to convert pixel to mm.
  • pano_size (tuple) – Size of the panorama in px.
map_points_angles(points, angles, cam_id)[source][source]

Map image points/angles to points/angles in relation to world/hive.

This happens under the assumption that the mapping parameters were estimated or loaded before.

Parameters:
  • points (ndarray) – List of points from left image in px (N,2).
  • angles (ndarray) – Angles in rad (length (N,)).
  • cam_id (ndarray) – ID of the camera, which shot the image.
Returns:

  • points_mapped (ndarray) – points mapped to hive in mm (N,2).
  • angles_mapped (ndarray) – angles mapped to (N,).

Note

For all angles in angles it is assumed that a 0°-angle shows to the right border of the image and that a positive angle means clockwise rotation.

compose_panorama(path_l, path_r, grid=False)[source][source]

Try to compose the given images into the final panorama.

This happens under the assumption that the mapping parameters were estimated or loaded before.

Parameters:
  • path_l (str) – Path to the left image.
  • path_r (str) – Path to the right image.
  • grid (bool, optional) – If True a grid with axes in mm will be drawn on the image.