SDK Calibration Utils

struct Metavision::CalibrationDetectionResult

Structure to store the pattern’s keypoints (static chessboard, blinking chessboard, blinking points grid, …) and the frame from which they were extracted.

Public Functions

CalibrationDetectionResult() = default

Default constructor.

CalibrationDetectionResult(CalibrationDetectionResult &&other)

Move operator.

CalibrationDetectionResult &operator=(CalibrationDetectionResult &&other)

Move assignment operator.

void reset(int width, int height, int channels = CV_8UC3)

Resets the frame and the keypoints.

Parameters
  • width: Image’s width

  • height: Image’s height

  • channels: Number of color channels

Public Members

std::vector<cv::Point2f> keypoints_

Calibration pattern’s keypoints.

cv::Mat frame_

Frame on which the keypoints have been extracted.

class Metavision::CalibrationDetectionFrameGenerator

Class that generates an image used for calibration.

Generates an image by combining:

  • the image of a calibration pattern (either frame-based image of a static pattern, or event-based accumulation image of a blinking pattern).

  • the vector containing the pattern’s keypoints.

  • a colored overlay that shows which regions have been well covered during the calibration.

Public Types

enum PatternMode

Type of pattern used during the calibration. It’s required to be able to draw the pattern correctly.

Values:

enumerator Chessboard

The pattern is a cartesian grid.

Public Functions

CalibrationDetectionFrameGenerator(int width, int height, int cols, int rows, PatternMode pattern_mode = PatternMode::Chessboard, bool overlay_convex_hull = false, bool four_corners_only = false)

Constructor. It assumes a calibration pattern aligned according to a grid, distorted or not, so that the concept of rows and columns make sense to describe the pattern.

Parameters
  • width: Image’s width

  • height: Image’s height

  • cols: Number of cols in the pattern (its width)

  • rows: Number of rows of the pattern (its height)

  • pattern_mode: Type of pattern used during the calibration (PatternMode)

  • overlay_convex_hull: If true, overlay a “shadow” over the convex hull covering all the dots in the pattern. If false, draw only a circle over each dot.

  • four_corners_only: Extract only the 4 extreme corners to compute the pattern’s convex hull used for the colored overlay (assuming there’s no distortion and the grid looks like a rectangle). This has no effect if overlay_convex_hull is false.

void generate_bgr_img(cv::Mat &output_img, const CalibrationDetectionResult &results)

Generates an image representing a calibration pattern on top of the frame on which it has been extracted. There’s also a colored overlay to show which regions have been well covered during the calibration.

Parameters
  • output_img: Output image

  • results: Structure containing a vector of keypoints and the frame on which they were extracted

class Metavision::PatternBlinker

Class that generates a blinking pattern by returning, at a fixed frequency, either a white image or the image of the pattern.

Public Functions

PatternBlinker(timestamp blinking_rate = 1e4)

Constructor using the default hardcoded pattern.

Parameters
  • blinking_rate: Time period between two consecutive blinks (in us)

PatternBlinker(const cv::Mat &pattern_img, timestamp blinking_rate = 1e4)

Constructor loading the pattern from a colored image.

Parameters
  • pattern_img: Pattern’s image

  • blinking_rate: Time period between two consecutive blinks (in us)

bool update_blinking_image(const timestamp ts, cv::Mat &output_img)

Swaps the blinking frame between “All White” and “With a Pattern”, provided that the timestamp is less recent than the refresh period.

Parameters
  • ts: Timestamp

  • output_img: Output copy of the current blink/blank frame

void get_current_blinking_image(cv::Mat &output_img)

Gets the current state of the blinking frame, without updating it.

Parameters
  • output_img: Output copy of the current blink/blank frame

cv::Size get_image_size()

Returns the size of the blinking frame.

bool Metavision::are_points_on_grid(const std::vector<cv::Point2f> &centers, int cols, int rows, float ths = 0.01f)

Checks that points are on a grid.

Warning

with strong radial distortion the threshold here should not be too aggressive. Another possibility is to use are_points_on_grid_radial_distortion instead (recommended for fisheye)

Return

true if points fit well the grid

Parameters
  • centers: The points of the grid

  • cols: Number of horizontal lines

  • rows: Number of vertical lines

  • ths: Maximum line fitting error for a point to be considered on the grid. Default value is 0.01

bool Metavision::are_points_on_grid_radial_distortion(const std::vector<cv::Point2f> &centers, int cols, int rows, float cos_max_angle = 0.9f)

Checks that points are on a grid (for fisheye)

Return

true if points fit well the grid

Parameters
  • centers: The points of the grid

  • cols: Number of horizontal lines

  • rows: Number of vertical lines

  • cos_max_angle: Cosine of maximum angle between 2 consecutive vectors (3 consecutive points) which belong to the same row of the grid. Default value is 0.9 (~ 25 degrees)