SDK Calibration Utils

class 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(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

Returns

true if image was updated

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, unsigned int cols, unsigned 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)

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

Returns

true if points fit well the grid

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

Checks that points are on a grid (for fisheye)

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)

Returns

true if points fit well the grid

class PatternRenderer

Class that renders a pattern on an image.

Public Functions

PatternRenderer(const Pattern &pattern)

Constructor.

Parameters

pattern – The pattern to render

virtual ~PatternRenderer() = default

Destructor.

virtual void render(const PatternDetection &detection, cv::Mat &image) const

Renders the pattern on the image from a pattern detection.

Parameters
  • detection – The pattern detection

  • image – The image to render the pattern on

Throws

std::runtime_error – if the number of detected corners does not match the number of corners in the pattern

virtual void render(const std::vector<cv::Point2f> &points, cv::Mat &image) const

Renders the pattern on the image from a set of detected corners.

Parameters
  • points – The detected corners

  • image – The image to render the pattern on

Throws

std::runtime_error – if the number of detected corners does not match the number of corners in the pattern

virtual void get_2d_hull(const PatternDetection &detection, std::vector<cv::Point> &hull) const

Gets the 2D convex hull of the pattern detection.

Parameters
  • detection – The pattern detection to get the hull from

  • hull[out] The output hull

inline virtual std::unique_ptr<PatternRenderer> clone() const

Clones the pattern renderer.

Returns

The cloned instance