3 #include "../../lib/random_color.h" 4 #include "../../lib/json.h" 5 #include "../../lib/string.h" 13 const json& j_fpoints_feat = j_fpoints[
"points"];
14 for(
auto it = j_fpoints_feat.begin(); it != j_fpoints_feat.end(); ++it) {
15 const std::string& feature_name = it.key();
16 const json& j_fpoint = it.value();
24 json f_fpoints_feat = json::object();
25 for(
const auto& kv : fpoints.
points) {
26 const std::string& feature_name = kv.first;
29 f_fpoints_feat[feature_name] = j_fpoint;
32 json j_fpoints = json::object();
34 j_fpoints[
"points"] = f_fpoints_feat;
42 real weights_sum = 0.0;
43 for(
const auto& kv :
points) weights_sum += kv.second.weight;
44 weights_sum /= points.size();
45 for(
auto& kv : points) kv.second.weight /= weights_sum;
54 for(
const auto& kv : cors.
features) {
55 const std::string& feature_name = kv.first;
57 auto point_it = feature.
points.find(idx);
58 if(point_it != feature.
points.end()) fpoints.
points[feature_name] = point_it->second;
73 std::vector<vec2> distorted_points;
74 std::vector<vec2*> undistorted_point_ptrs;
75 for(
const auto& kv : dist_fpoints.
points) {
76 const std::string& feature_name = kv.first;
79 distorted_points.push_back(dist_fpt.
position);
80 undistorted_point_ptrs.push_back(&undist_fpt.
position);
81 undist_fpt = dist_fpt;
84 std::vector<vec2> undistorted_points =
undistort_points(intr, distorted_points);
85 for(std::ptrdiff_t idx = 0; idx < distorted_points.size(); ++idx)
86 *(undistorted_point_ptrs[idx]) = undistorted_points[idx];
88 return undist_fpoints;
104 std::vector<vec2> list;
105 for(
const auto& kv : fpoints.
points) {
115 cv::Mat_<cv::Vec3b> img;
116 back_img.copyTo(img);
118 for(
const auto& kv : fpoints.
points) {
119 const std::string& feature_name = kv.first;
122 cv::Point2f center_point = vec2_to_point(fpoint.
position);
123 center_point.x += bord.
left;
124 center_point.y += bord.
top;
125 cv_aa_circle(img, center_point, 10, cv::Scalar(col), 2);
126 cv::Point label_point(center_point.x + 10, center_point.y - 10);
127 cv::putText(img, feature_name, label_point, cv::FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(col));
134 std::cout <<
"loading feature points" << std::endl;
bool has(const json &j, const std::string &key)
std::vector< vec2 > positions(const feature_points &fpoints)
std::string encode_view_index(view_index idx)
feature_points undistorted_feature_points_for_view(const image_correspondences &cors, view_index idx, const intrinsics &intr)
Set of features, each on set of views.
feature_point decode_feature_point(const json &j_pt)
cv::Vec3b random_color(int i)
Points of different features, on one view.
std::map< std::string, feature_point > points
feature_points feature_points_for_view(const image_correspondences &cors, view_index idx, bool is_distorted)
std::map< std::string, image_correspondence_feature > features
distortion_parameters distortion
json encode_feature_point(const feature_point &pt)
json encode_feature_points(const feature_points &fpoints)
feature_points decode_feature_points(const json &j_fpoints)
int string_hash(const std::string &str)
feature_points undistort(const feature_points &dist_fpoints, const intrinsics &intr)
Feature on set of views. Optionally one view is "reference".
std::vector< vec2 > undistort_points(const intrinsics &intr, const std::vector< vec2 > &distorted)
view_index decode_view_index(const std::string &key)
cv::Mat_< cv::Vec3b > visualize_feature_points(const feature_points &fpoints, const cv::Mat_< cv::Vec3b > &back_img, const border &bord)
feature_points feature_points_arg()
T get_or(const json &j, const std::string &key, const T &default_value)
std::map< view_index, feature_point > points
void cv_aa_circle(cv::Mat &mat, const cv::Point2f ¢er, float rad, cv::Scalar col, int thickness)