2 #include "../../../lib/random_color.h" 3 #include "../../../lib/assert.h" 4 #include "../../../lib/string.h" 10 Assert(! fpoints.
is_distorted,
"feature_slopes can only be created for undistorted feature points");
17 const json& j_fslopes_feat = j_fslopes[
"points"];
18 for(
auto it = j_fslopes_feat.begin(); it != j_fslopes_feat.end(); ++it) {
19 const std::string& feature_name = it.key();
20 const json& j_fslope = it.value();
22 fslope.
horizontal = j_fslope[
"slope_horizontal"];
23 fslope.
vertical = j_fslope[
"slope_vertical"];
30 return has(j_fslopes[
"points"].begin().value(),
"slope_horizontal");
36 json& j_fslopes_feat = j_fslopes[
"points"];
37 for(
const auto& kv : fslopes.
slopes) {
38 const std::string& feature_name = kv.first;
40 json& j_fslope = j_fslopes_feat[feature_name];
41 j_fslope[
"slope_horizontal"] = fslope.
horizontal;
42 j_fslope[
"slope_vertical"] = fslope.
vertical;
49 real ix = undistorted_point[0], iy = undistorted_point[1];
50 real fx = K(0, 0), fy = K(1, 1), cx = K(0, 2), cy = K(1, 2);
51 real r11 = R(0, 0), r21 = R(1, 0), r31 = R(2, 0);
52 return (fy*r21 + cy*r31 - iy*r31) / (fx*r11 + cx*r31 - ix*r31);
57 real ix = undistorted_point[0], iy = undistorted_point[1];
58 real fx = K(0, 0), fy = K(1, 1), cx = K(0, 2), cy = K(1, 2);
59 real r12 = R(0, 1), r22 = R(1, 1), r32 = R(2, 1);
60 return (fx*r12 + cx*r32 - ix*r32) / (fy*r22 + cy*r32 - iy*r32);
65 cv::Mat_<cv::Vec3b> out_img;
66 back_img.copyTo(out_img);
68 int radius = width / 2;
70 for(
const auto& kv : fslopes.
slopes) {
71 const std::string& feature_name = kv.first;
75 cv::Point center_point = vec2_to_point(fpoint.
position);
76 center_point.x += bord.
left;
77 center_point.y += bord.
top;
85 std::vector<cv::Point> end_points(2);
86 end_points[0] = cv::Point(center_point.x - radius, center_point.y - radius*hslope);
87 end_points[1] = cv::Point(center_point.x + radius, center_point.y + radius*hslope);
88 std::vector<std::vector<cv::Point>> polylines { end_points };
89 cv::polylines(out_img, polylines,
false, cv::Scalar(col), thickness);
95 std::vector<cv::Point> end_points(2);
96 end_points[0] = cv::Point(center_point.x - radius*vslope, center_point.y - radius);
97 end_points[1] = cv::Point(center_point.x + radius*vslope, center_point.y + radius);
98 std::vector<std::vector<cv::Point>> polylines { end_points };
99 cv::polylines(out_img, polylines,
false, cv::Scalar(col), thickness);
121 std::cout <<
"loading feature slopes" << std::endl;
json encode_feature_slopes(const feature_slopes &fslopes)
bool has(const json &j, const std::string &key)
bool has_feature_slopes(const json &j_fslopes)
real model_vertical_slope(const vec2 &undistorted_point, const mat33 &K, const mat33 &R)
real model_horizontal_slope(const vec2 &undistorted_point, const mat33 &K, const mat33 &R)
cv::Vec3b random_color(int i)
Points of different features, on one view.
feature_slopes feature_slopes_arg()
cv::Mat_< cv::Vec3b > visualize_feature_slopes(const feature_slopes &fslopes, const cv::Mat_< cv::Vec3b > &back_img, int width, real exaggeration, int thickness, const border &bord)
std::map< std::string, feature_point > points
json encode_feature_points(const feature_points &fpoints)
cv::Matx< real, 3, 3 > mat33
feature_points decode_feature_points(const json &j_fpoints)
int string_hash(const std::string &str)
feature_slopes decode_feature_slopes(const json &j_fslopes)
std::map< std::string, feature_slope > slopes
feature_slopes merge_multiview_feature_slopes(const feature_slopes &a, const feature_slopes &b)