mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-07 10:37:47 +08:00
OpenCV 5 support (#1732)
* OpenCV 5 support * RTABMapConfig.cmake, guard from including stereoRectifyFisheye.h * unified opencv components at the same place * fixing android build * Confirmed stereo calibration with fisheye works. Fix camera start/top progress dialog not drawn. Opencv >=4.7 using new opencv's ArucoDetector class. * pinning opencv for downstream apps * Avoid changing object/image points between fisheye calibration * Fixed stereo calib diverging when recalibrating same data * removed not needed opencv c api * fixing depthai build on opencv5 * bumped version * Adding ci opencv5 with homebrew * fixed ci script * Fixed OptimizerCeres build with opencv5
This commit is contained in:
@@ -64,7 +64,11 @@
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#if CV_MAJOR_VERSION < 5
|
||||
#include <opencv2/features2d/features2d.hpp>
|
||||
#else
|
||||
#include <opencv2/features.hpp>
|
||||
#endif
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <opencv2/core/core_c.h>
|
||||
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
@@ -252,7 +251,7 @@ static void computeOrbDescriptor(const KeyPoint& kpt,
|
||||
}
|
||||
}
|
||||
else
|
||||
CV_Error( CV_StsBadSize, "Wrong WTA_K. It can be only 2, 3 or 4." );
|
||||
CV_Error( cv::Error::StsBadSize, "Wrong WTA_K. It can be only 2, 3 or 4." );
|
||||
|
||||
#undef GET_VALUE
|
||||
}
|
||||
@@ -752,7 +751,7 @@ void CV_ORB::operator()( InputArray _image, InputArray _mask, std::vector<KeyPoi
|
||||
|
||||
Mat image = _image.getMat(), mask = _mask.getMat();
|
||||
if( image.type() != CV_8UC1 )
|
||||
cvtColor(_image, image, CV_BGR2GRAY);
|
||||
cvtColor(_image, image, cv::COLOR_BGR2GRAY);
|
||||
|
||||
int levelsNum = this->nlevels;
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#ifndef CORELIB_SRC_OPENCV_FIVE_POINT_H_
|
||||
#define CORELIB_SRC_OPENCV_FIVE_POINT_H_
|
||||
|
||||
#if CV_MAJOR_VERSION > 4
|
||||
#include <opencv2/geometry.hpp>
|
||||
#endif
|
||||
|
||||
namespace cv3
|
||||
{
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class PnPRansacCallback : public PointSetRegistrator::Callback
|
||||
|
||||
public:
|
||||
|
||||
PnPRansacCallback(Mat _cameraMatrix=Mat(3,3,CV_64F), Mat _distCoeffs=Mat(4,1,CV_64F), int _flags=CV_ITERATIVE,
|
||||
PnPRansacCallback(Mat _cameraMatrix=Mat(3,3,CV_64F), Mat _distCoeffs=Mat(4,1,CV_64F), int _flags=cv::SOLVEPNP_ITERATIVE,
|
||||
bool _useExtrinsicGuess=false, Mat _rvec=Mat(), Mat _tvec=Mat() )
|
||||
: cameraMatrix(_cameraMatrix), distCoeffs(_distCoeffs), flags(_flags), useExtrinsicGuess(_useExtrinsicGuess),
|
||||
rvec(_rvec), tvec(_tvec) {}
|
||||
@@ -142,12 +142,12 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat();
|
||||
|
||||
int model_points = 6;
|
||||
int ransac_kernel_method = CV_EPNP;
|
||||
int ransac_kernel_method = cv::SOLVEPNP_EPNP;
|
||||
|
||||
if( npoints == 4 )
|
||||
{
|
||||
model_points = 4;
|
||||
ransac_kernel_method = CV_P3P;
|
||||
ransac_kernel_method = cv::SOLVEPNP_P3P;
|
||||
}
|
||||
|
||||
Ptr<PointSetRegistrator::Callback> cb; // pointer to callback
|
||||
@@ -178,7 +178,7 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
opoints_inliers.resize(npoints1);
|
||||
ipoints_inliers.resize(npoints1);
|
||||
result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
|
||||
distCoeffs, rvec, tvec, useExtrinsicGuess, flags == CV_P3P ? CV_EPNP : flags) ? 1 : -1;
|
||||
distCoeffs, rvec, tvec, useExtrinsicGuess, flags == cv::SOLVEPNP_P3P ? cv::SOLVEPNP_EPNP : flags) ? 1 : -1;
|
||||
}
|
||||
|
||||
if( result <= 0 || _local_model.rows <= 0)
|
||||
@@ -213,7 +213,7 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
int RANSACUpdateNumIters( double p, double ep, int modelPoints, int maxIters )
|
||||
{
|
||||
if( modelPoints <= 0 )
|
||||
CV_Error( 0, "the number of model points should be positive" );
|
||||
CV_Error( cv::Error::Code::StsBadArg, "the number of model points should be positive" );
|
||||
|
||||
p = MAX(p, 0.);
|
||||
p = MIN(p, 1.);
|
||||
|
||||
@@ -45,9 +45,10 @@
|
||||
#define RTABMAP_CORELIB_SRC_OPENCV_SOLVEPNP_H_
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#if CV_MAJOR_VERSION >= 5
|
||||
#include <opencv2/geometry.hpp>
|
||||
#else
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#if CV_MAJOR_VERSION >= 3
|
||||
#include <opencv2/calib3d/calib3d_c.h>
|
||||
#endif
|
||||
|
||||
namespace cv3 {
|
||||
@@ -95,7 +96,7 @@ bool solvePnPRansac( cv::InputArray objectPoints, cv::InputArray imagePoints,
|
||||
cv::OutputArray rvec, cv::OutputArray tvec,
|
||||
bool useExtrinsicGuess = false, int iterationsCount = 100,
|
||||
float reprojectionError = 8.0, double confidence = 0.99,
|
||||
cv::OutputArray inliers = cv::noArray(), int flags = CV_ITERATIVE );
|
||||
cv::OutputArray inliers = cv::noArray(), int flags = cv::SOLVEPNP_ITERATIVE );
|
||||
|
||||
int RANSACUpdateNumIters( double p, double ep, int modelPoints, int maxIters );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user