Targets

You can import icepy4d classes by

import icepy4d.core as icecore

and directly access to the Camera class by

icecore.Targets

icepy4d.core.targets.Targets

Class to store Target information, including image coordinates and object coordinates Targets are stored as numpy arrays

Attributes:
  • im_coor (List[ndarray]) –

    A list of nx2 numpy arrays, where each numpy array contains the xy coordinates of the target projections on each image.

  • obj_coor (ndarray) –

    A nx3 numpy array containing XYZ object coordinates (can be empty).

__init__(im_file_path=None, obj_file_path=None)

Initialize a new instance of the Targets class.

Parameters:
  • im_file_path (List[Union[str, Path]], default: None ) –

    A list of file paths to read image coordinates from. Defaults to None.

  • obj_file_path (Union[str, Path], default: None ) –

    A file path to read object coordinates from. Defaults to None.

__len__()

Return the total number of features stored.

Returns:
  • int( int ) –

    The total number of features stored.

append_obj_cord(new_obj_coor)

Append new object coordinates to the current object coordinates.

Parameters:
  • new_obj_coor (ndarray) –

    The new object coordinates to append.

TODO: add checks on input dimensions

get_im_coord(cam_id=None)

Return the image coordinates as a numpy array.

Parameters:
  • cam_id (int, default: None ) –

    The camera ID to return the image coordinates for. If not provided, returns the list with the projections on all the cameras. Defaults to None.

Returns:
  • ndarray

    np.ndarray: A numpy array containing the image coordinates.

get_image_coor_by_label(labels, cam_id)

get_image_coor_by_label Get image coordinates of the targets on the images given a list of target labels

Parameters:
  • labels (List[str]) –

    List containing the targets' label to extract

  • cam_id (int) –

    numeric (integer) id of the camera for which the image coordinates are asked.

Raises:
  • ValueError

    No targets are found.

Returns:
  • Tuple[ndarray, List[str]]

    Tuple[np.ndarray, List[str]]: Tuple cointaining a numpy nx2 array with the coordinates of the selected (and valid) targets and a list with the labels of the valid targets

get_obj_coord()

Return the object coordinates as a numpy array.

Returns:
  • ndarray

    np.ndarray: A numpy array containing the object coordinates.

get_object_coor_by_label(labels)

get_object_coor_by_label Get object coordinates of the targets on the images given a list of target labels

Parameters:
  • labels (List[str]) –

    List containing the targets' label to extract

Raises:
  • ValueError

    No targets are found.

Returns:
  • Tuple[ndarray, List[str]]

    Tuple[np.ndarray, List[str]]: Tuple cointaining a nx3 array containing object coordinates of the selected (and valid) targets and a list with the labels of the valid targets

get_target_labels(cam_id=None)

Returns target labels as a list.

Parameters:
  • cam_id (int, default: None ) –

    Numeric id of the camera for which the target labels are requested.

Returns:
  • List( List[str] ) –

    Target labels as a list.

read_im_coord_from_txt(camera_id, path, delimiter=',', header=0)

Read target image coordinates from a .txt file and store them in a pandas DataFrame organized as follows:

- One line per target
- label, then first x coordinate, then y coordinate
- Coordinates separated by a delimiter (default: ',')
e.g.
# label,x,y
target_1,1000,2000
target_2,2000,3000
Parameters:
  • camera_id (int) –

    The numeric (integer) ID of the camera to which the target coordinates belong.

  • path (Union[str, Path]) –

    The path to the input file.

  • delimiter (str, default: ',' ) –

    The delimiter used in the input file (default: ',').

  • header (int, default: 0 ) –

    The row number to use as the column names. Default is 0 (the first row).

Raises:
  • FileNotFoundError

    If the input path does not exist.

Returns:
  • None

    None

read_obj_coord_from_txt(path=None, delimiter=',', header=0)

Read target object coordinates from a .txt file and store them in a pandas DataFrame organized as follows:

- One line per target
- label, then first x coordinate, then y coordinate
- Coordinates separated by a delimiter (default: ',')
e.g.
# label,X,Y,Z
target_1,1000,2000,3000
target_1,2000,3000,3000
Parameters:
  • path (Union[str, Path], default: None ) –

    The path to the input file.

  • delimiter (str, default: ',' ) –

    The delimiter used in the input file (default: ',').

  • header (int, default: 0 ) –

    The row number to use as the column names. Default is 0 (the first row).

Raises:
  • FileNotFoundError

    If the input path does not exist.

Returns:
  • None

    None.

reset_targets()

Reset Target instance to empy list and None objects