diff --git a/modules/calib3d/src/usac.hpp b/modules/calib3d/src/usac.hpp index 85b2730e4a..57d91ab7f3 100644 --- a/modules/calib3d/src/usac.hpp +++ b/modules/calib3d/src/usac.hpp @@ -176,7 +176,7 @@ public: //-------------------------- ESSENTIAL MATRIX ----------------------- class EssentialNonMinimalSolverViaF : public NonMinimalSolver { public: -static Ptr create(const Mat &points_, const cv::Mat &K1, const Mat &K2); + static Ptr create(const Mat &points_, const cv::Mat &K1, const Mat &K2); }; class EssentialNonMinimalSolverViaT : public NonMinimalSolver { @@ -432,7 +432,7 @@ public: }; class EssentialEstimator : public Estimator { -public : +public: static Ptr create (const Ptr &min_solver_, const Ptr &non_min_solver_, const Ptr °eneracy_); }; @@ -542,11 +542,6 @@ public: int cell_size_x_img1_, int cell_size_y_img1_, int cell_size_x_img2_, int cell_size_y_img2_, int max_neighbors); }; -class GridNeighborhoodGraph2Images : public NeighborhoodGraph { -public: - static Ptr create(const Mat &points, int points_size, - float cell_size_x_img1_, float cell_size_y_img1_, float cell_size_x_img2_, float cell_size_y_img2_); -}; ////////////////////////////////////// UNIFORM SAMPLER //////////////////////////////////////////// class UniformSampler : public Sampler { @@ -554,11 +549,6 @@ public: static Ptr create(int state, int sample_size_, int points_size_); }; -class QuasiUniformSampler : public Sampler { -public: - static Ptr create(int state, int sample_size_, int points_size_); -}; - /////////////////////////////////// PROSAC (SIMPLE) SAMPLER /////////////////////////////////////// class ProsacSimpleSampler : public Sampler { public: diff --git a/modules/calib3d/src/usac/utils.cpp b/modules/calib3d/src/usac/utils.cpp index da1956f26c..204b31cf92 100644 --- a/modules/calib3d/src/usac/utils.cpp +++ b/modules/calib3d/src/usac/utils.cpp @@ -826,94 +826,4 @@ Ptr GridNeighborhoodGraph::create(const Mat &points, return makePtr(points, points_size, cell_size_x_img1_, cell_size_y_img1_, cell_size_x_img2_, cell_size_y_img2_, max_neighbors); } - -class GridNeighborhoodGraph2ImagesImpl : public GridNeighborhoodGraph2Images { -private: - // This struct is used for the nearest neighbors search by griding two images. - struct CellCoord { - int c1x, c1y; - CellCoord (int c1x_, int c1y_) { - c1x = c1x_; c1y = c1y_; - } - bool operator==(const CellCoord &o) const { - return c1x == o.c1x && c1y == o.c1y; - } - bool operator<(const CellCoord &o) const { - if (c1x < o.c1x) return true; - return c1x == o.c1x && c1y < o.c1y; - } - }; - - std::vector> graph; -public: - GridNeighborhoodGraph2ImagesImpl (const Mat &container_, int points_size, - float cell_size_x_img1, float cell_size_y_img1, float cell_size_x_img2, float cell_size_y_img2) { - - std::map> neighbors_map1, neighbors_map2; - const auto * const container = (float *) container_.data; - // Key is cell position. The value is indexes of neighbors. - - const auto cell_sz_x1 = 1.f / cell_size_x_img1, - cell_sz_y1 = 1.f / cell_size_y_img1, - cell_sz_x2 = 1.f / cell_size_x_img2, - cell_sz_y2 = 1.f / cell_size_y_img2; - const int dimension = container_.cols; - for (int i = 0; i < points_size; i++) { - const int idx = dimension * i; - neighbors_map1[CellCoord((int)(container[idx ] * cell_sz_x1), - (int)(container[idx+1] * cell_sz_y1))].emplace_back(i); - neighbors_map2[CellCoord((int)(container[idx+2] * cell_sz_x2), - (int)(container[idx+3] * cell_sz_y2))].emplace_back(i); - } - - //--------- create a graph ---------- - graph = std::vector>(points_size); - - // store neighbors cells into graph (2D vector) - for (const auto &cell : neighbors_map1) { - const int neighbors_in_cell = static_cast(cell.second.size()); - // only one point in cell -> no neighbors - if (neighbors_in_cell < 2) continue; - - const std::vector &neighbors = cell.second; - // ---------- fill graph ----- - // for speed-up we make no symmetric graph, eg, x has a neighbor y, but y does not have x - const int v_in_cell = neighbors[0]; - // there is always at least one neighbor - auto &graph_row = graph[v_in_cell]; - graph_row.reserve(neighbors_in_cell); - for (int n : neighbors) - if (n != v_in_cell) - graph_row.emplace_back(n); - } - - // fill neighbors of a second image - for (const auto &cell : neighbors_map2) { - if (cell.second.size() < 2) continue; - const std::vector &neighbors = cell.second; - const int v_in_cell = neighbors[0]; - auto &graph_row = graph[v_in_cell]; - for (const int &n : neighbors) - if (n != v_in_cell) { - bool has = false; - for (const int &nn : graph_row) - if (n == nn) { - has = true; break; - } - if (!has) graph_row.emplace_back(n); - } - } - } - const std::vector> &getGraph () const override { return graph; } - inline const std::vector &getNeighbors(int point_idx) const override { - // Note, neighbors vector also includes point_idx! - return graph[point_idx]; - } -}; - -Ptr GridNeighborhoodGraph2Images::create(const Mat &points, - int points_size, float cell_size_x_img1_, float cell_size_y_img1_, float cell_size_x_img2_, float cell_size_y_img2_) { - return makePtr(points, points_size, - cell_size_x_img1_, cell_size_y_img1_, cell_size_x_img2_, cell_size_y_img2_); -} }} \ No newline at end of file