From aa51382dbc6526df2e3b0aa1c438d6c3cc8854cc Mon Sep 17 00:00:00 2001 From: arodrigu Date: Fri, 16 Oct 2020 14:41:41 +0200 Subject: [PATCH] Fix: UsacParams Python bindings --- modules/calib3d/include/opencv2/calib3d.hpp | 23 +++++++++++---------- modules/calib3d/src/solvepnp.cpp | 15 ++++++++++++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index cc5fdbfe1c..a1a4c57d8a 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -550,17 +550,18 @@ enum NeighborSearchMethod { NEIGH_FLANN_KNN, NEIGH_GRID, NEIGH_FLANN_RADIUS }; struct CV_EXPORTS_W_SIMPLE UsacParams { // in alphabetical order - double confidence = 0.99; - bool isParallel = false; - int loIterations = 5; - LocalOptimMethod loMethod = LocalOptimMethod::LOCAL_OPTIM_INNER_LO; - int loSampleSize = 14; - int maxIterations = 5000; - NeighborSearchMethod neighborsSearch = NeighborSearchMethod::NEIGH_GRID; - int randomGeneratorState = 0; - SamplingMethod sampler = SamplingMethod::SAMPLING_UNIFORM; - ScoreMethod score = ScoreMethod::SCORE_METHOD_MSAC; - double threshold = 1.5; + CV_WRAP UsacParams(); + CV_PROP_RW double confidence; + CV_PROP_RW bool isParallel; + CV_PROP_RW int loIterations; + CV_PROP_RW LocalOptimMethod loMethod; + CV_PROP_RW int loSampleSize; + CV_PROP_RW int maxIterations; + CV_PROP_RW NeighborSearchMethod neighborsSearch; + CV_PROP_RW int randomGeneratorState; + CV_PROP_RW SamplingMethod sampler; + CV_PROP_RW ScoreMethod score; + CV_PROP_RW double threshold; }; /** @brief Converts a rotation matrix to a rotation vector or vice versa. diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 5c04662489..bb595085fa 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -197,6 +197,21 @@ public: Mat tvec; }; +UsacParams::UsacParams() +{ + confidence = 0.99; + isParallel = false; + loIterations = 5; + loMethod = LocalOptimMethod::LOCAL_OPTIM_INNER_LO; + loSampleSize = 14; + maxIterations = 5000; + neighborsSearch = NeighborSearchMethod::NEIGH_GRID; + randomGeneratorState = 0; + sampler = SamplingMethod::SAMPLING_UNIFORM; + score = ScoreMethod::SCORE_METHOD_MSAC; + threshold = 1.5; +} + bool solvePnPRansac(InputArray _opoints, InputArray _ipoints, InputArray _cameraMatrix, InputArray _distCoeffs, OutputArray _rvec, OutputArray _tvec, bool useExtrinsicGuess,