Skip to content

RFC: API refactor away from primarily camera classes #279

@RealOrangeOne

Description

@RealOrangeOne

As with all good things, I've been tempted to rewrite the API and implementation and change things massively.

The primary changes being:

  • Extract the image processing from the BaseCamera into primary functions
  • Remove the ImageFileCamera and MarkerCamera. Replace with a process_image function, a more generic process_frame function, and some form of get_marker_image. VideoFileCamera will probably stay as-is, as that still makes a bit of sense as a "camera",
  • Ensure these new methods are part of the public API
  • Remove get_visible_markers. It's an additional API to maintain (and variants of the below) with little to no benefit ([marker.id for marker in camera.process_frame()] works absolutely fine).

API examples

def process_image_eager(file: Path, marker_dict, detector_params: CalibrationParameters, marker_size: int) -> Generator[EagerMarker, None, None]: ...
def process_image(file: Path, marker_dict, detector_params: CalibrationParameters, marker_size: int) -> Generator[Marker, None, None]: ...
def process_frame(data: ndarray, marker_dict, detector_params: CalibrationParameters, marker_size: int) -> Generator[Marker, None, None]: ...
def process_frame_eager(data: ndarray, marker_dict, detector_params: CalibrationParameters, marker_size: int) -> Generator[EagerMarker, None, None]: ...
def get_marker_image(border_size: int, marker_id: int, marker_size: int, border_colour: Tuple[int, int, int]) -> ndarray: ...
  • Lots of the options to the above are shared, I wonder if it's worth having a struct to collect them together, similar to CalibrationParameters.?

Implementation probably also requires #202 (and thus #220).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions