11 json j_hom = json::object();
13 if(! std::isnan(hom.
err)) j_hom[
"err"] = hom.
err;
27 json j_homs = json::object();
28 for(
const auto& kv : homs) {
39 for(
auto it = j_homs.begin(); it != j_homs.end(); ++it) {
41 const json& j_hom = it.value();
55 for(
const auto& kv : homs) err += kv.second.err;
62 std::vector<vec2> src {
69 std::vector<vec2> dst;
70 cv::perspectiveTransform(src, dst, hom.
mat);
78 real max_x = std::max({ dst[0][0], dst[1][0], dst[2][0], dst[3][0] });
79 real max_y = std::max({ dst[0][1], dst[1][1], dst[2][1], dst[3][1] });
80 real min_x = std::min({ dst[0][0], dst[1][0], dst[2][0], dst[3][0] });
81 real min_y = std::min({ dst[0][1], dst[1][1], dst[2][1], dst[3][1] });
86 bord.bottom = max_y - height;
87 bord.right = max_x - width;
94 max_bord.
top = INT_MIN;
95 max_bord.
left = INT_MIN;
97 max_bord.
right = INT_MIN;
99 for(
const auto& kv : homs) {
101 max_bord.
top = std::max({ max_bord.
top, bord.
top });
112 std::cout <<
"loading view homography" << std::endl;
117 std::cout <<
"loading view homographies" << std::endl;
view_homography decode_view_homography(const json &j_hom)
std::vector< vec2 > quadrilateral(const view_homography &hom, real width, real height)
bool has(const json &j, const std::string &key)
std::string encode_view_index(view_index idx)
view_homographies homographies_arg()
bool is_single_view_homography(const json &j)
std::map< view_index, view_homography > view_homographies
cv::Mat_< real > decode_mat(const json &j)
json encode_view_homography(const view_homography &hom)
border maximal_border(const view_homography &hom, real width, real height)
json encode_mat(const Mat &mat)
view_homography homography_arg()
view_index decode_view_index(const std::string &key)
real view_homographies_error(const view_homographies &homs)
json encode_view_homographies(const view_homographies &homs)
view_homographies decode_view_homographies(const json &j_homs)
T get_or(const json &j, const std::string &key, const T &default_value)