licornea_tools
checkerboard.h
Go to the documentation of this file.
1 #ifndef LICORNEA_KINECT_LIVE_CHECKERBOARD_H_
2 #define LICORNEA_KINECT_LIVE_CHECKERBOARD_H_
3 
4 #include "../../lib/opencv.h"
5 #include "../../lib/obj_img_correspondence.h"
6 #include "../../lib/intrinsics.h"
7 #include <vector>
8 
9 namespace tlz {
10 
11 struct checkerboard {
12  int cols = 0;
13  int rows = 0;
15  std::vector<vec2> corners;
16  std::vector<vec2> outer_corners;
17  cv::Rect bounding_rect;
18 
19  checkerboard() = default;
20  checkerboard(int cols_, int rows_, real square_width_, const std::vector<vec2>& corners_);
21 
22  vec2 corner(int col, int row) const { return corners[cols*row + col]; }
23 
24  bool is_null() const { return corners.empty(); }
25  explicit operator bool () const { return ! is_null(); }
26 
27  std::size_t corners_count() const { return (rows * cols); }
28 
29  std::vector<cv::Point> outer_corners_i() const;
30 };
31 
36 };
37 
38 checkerboard detect_color_checkerboard(cv::Mat_<cv::Vec3b>&, int cols, int rows, real square_width = NAN);
39 checkerboard detect_ir_checkerboard(cv::Mat_<uchar>&, int cols, int rows, real square_width = NAN);
40 checkerboard detect_ir_checkerboard(cv::Mat_<ushort>&, int cols, int rows, real square_width = NAN);
41 
42 std::vector<vec3> checkerboard_world_corners(int cols, int rows, real square_width);
43 std::vector<vec2> checkerboard_image_corners(const checkerboard&);
44 
46 
49  real measured_depth = NAN;
50  real calculated_depth = NAN;
51 };
52 std::vector<checkerboard_pixel_depth_sample> checkerboard_pixel_depth_samples(const checkerboard&, const cv::Mat_<float>& depth_image, int granularity = 1);
53 
54 void calculate_checkerboard_pixel_depths(const intrinsics&, const checkerboard_extrinsics&, std::vector<checkerboard_pixel_depth_sample>& inout_samples);
55 
58 
60 
62  bool line = true;
63  cv::Vec3b lines_color = cv::Vec3b(100, 100, 255);
64  int line_thickness = 3;
65  bool cv_visualization = true;
66 };
67 cv::Mat_<cv::Vec3b> visualize_checkerboard(const cv::Mat_<cv::Vec3b>&, const checkerboard&, const checkerboard_visualization_parameters& = checkerboard_visualization_parameters());
68 cv::Mat_<cv::Vec3b> visualize_checkerboard(const cv::Mat_<uchar>&, const checkerboard&, const checkerboard_visualization_parameters& = checkerboard_visualization_parameters());
69 cv::Mat_<cv::Vec3b> visualize_checkerboard(const cv::Mat_<ushort>&, const checkerboard&, const checkerboard_visualization_parameters& = checkerboard_visualization_parameters());
70 
71 cv::Mat_<cv::Vec3b> visualize_checkerboard_pixel_samples(const cv::Mat_<cv::Vec3b>&, const std::vector<checkerboard_pixel_depth_sample>&, int rad = 1);
72 cv::Mat_<cv::Vec3b> visualize_checkerboard_pixel_samples(const cv::Mat_<uchar>&, const std::vector<checkerboard_pixel_depth_sample>&, int rad = 1);
73 
76 
77 }
78 
79 #endif
void calculate_checkerboard_pixel_depths(const intrinsics &intr, const checkerboard_extrinsics &ext, std::vector< checkerboard_pixel_depth_sample > &inout_samples)
obj_img_correspondences< 1, 1 > checkerboard_obj_img_correspondences(const checkerboard &chk)
std::vector< vec2 > checkerboard_image_corners(const checkerboard &chk)
checkerboard_extrinsics estimate_checkerboard_extrinsics(const checkerboard &chk, const intrinsics &intr)
cv::Mat_< cv::Vec3b > visualize_checkerboard(const cv::Mat_< cv::Vec3b > &img, const checkerboard &chk, const checkerboard_visualization_parameters &param)
std::vector< vec2 > outer_corners
Definition: checkerboard.h:16
cv::Vec< real, 2 > vec2
Definition: common.h:22
checkerboard detect_color_checkerboard(cv::Mat_< cv::Vec3b > &img, int cols, int rows, real square_width)
Definition: checkerboard.cc:46
std::vector< vec2 > corners
Definition: checkerboard.h:15
vec2 checkerboard_parallel_measures(const checkerboard &chk)
std::size_t corners_count() const
Definition: checkerboard.h:27
real calculate_parallel_checkerboard_depth(const checkerboard &chk, const intrinsics &intr)
cv::Mat_< cv::Vec3b > visualize_checkerboard_pixel_samples(const cv::Mat_< cv::Vec3b > &img, const std::vector< checkerboard_pixel_depth_sample > &pixels, int rad)
cv::Matx< real, 3, 3 > mat33
Definition: common.h:26
double real
Definition: common.h:16
cv::Rect bounding_rect
Definition: checkerboard.h:17
std::vector< obj_img_correspondence< Obj_count, Img_count >> obj_img_correspondences
vec2 corner(int col, int row) const
Definition: checkerboard.h:22
bool is_null() const
Definition: checkerboard.h:24
cv::Vec< real, 3 > vec3
Definition: common.h:23
std::vector< vec3 > checkerboard_world_corners(int cols, int rows, real square_width)
real checkerboard_reprojection_error(const checkerboard &chk, const intrinsics &intr, const checkerboard_extrinsics &ext)
obj_img_correspondences< 1, 2 > checkerboard_obj_2img_correspondences(const checkerboard &chk1, const checkerboard &chk2)
checkerboard detect_ir_checkerboard(cv::Mat_< uchar > &img, int cols, int rows, real square_width)
Definition: checkerboard.cc:62
std::vector< cv::Point > outer_corners_i() const
Definition: checkerboard.cc:41
std::vector< checkerboard_pixel_depth_sample > checkerboard_pixel_depth_samples(const checkerboard &chk, const cv::Mat_< float > &depth_image, int granularity)
checkerboard()=default