Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit 601a25b

Browse files
committed
Merge branch 'develop'
2 parents e812dbf + dde90b5 commit 601a25b

File tree

141 files changed

+3516
-2528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+3516
-2528
lines changed

.gitignore

+8-5
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ Release/
5555
*-packagedependencies-unix.*
5656
*-packagedependencies-android.*
5757
*.pc
58-
*-Debug*
59-
*-Release*
60-
*_Debug*
61-
*_Release*
58+
*-Debug
59+
*-Release
60+
*-debug.bat
61+
*-release.bat
62+
*_debug.bat
63+
*_release.bat
64+
*run.sh
6265

6366
# Executables
6467
*.exe
@@ -92,4 +95,4 @@ tests/bin
9295
*aps
9396

9497
# Tests Data
95-
tests/data/loop_desktop_A/*
98+
tests/data/loop_desktop_A/*

SolARModuleOpenCV.pri

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
HEADERS += interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
2+
interfaces/SolARImageFilterWallisOpencv.h \
23
interfaces/SolAR2DOverlayOpencv.h \
34
interfaces/SolAR3DOverlayBoxOpencv.h \
45
interfaces/SolARBaseCameraOpencv.h \
@@ -10,11 +11,14 @@ HEADERS += interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
1011
interfaces/SolARDescriptorMatcherHammingBruteForceOpencv.h \
1112
interfaces/SolARDescriptorMatcherKNNOpencv.h \
1213
interfaces/SolARDescriptorMatcherRadiusOpencv.h \
14+
interfaces/SolARDescriptorMatcherGeometricOpencv.h \
15+
interfaces/SolARDescriptorMatcherRegionOpencv.h \
1316
interfaces/SolARDescriptorsExtractorAKAZE2Opencv.h \
1417
interfaces/SolARDescriptorsExtractorAKAZEOpencv.h \
1518
interfaces/SolARDescriptorsExtractorORBOpencv.h \
1619
interfaces/SolARDescriptorsExtractorSBPatternOpencv.h \
1720
interfaces/SolARDescriptorsExtractorSIFTOpencv.h \
21+
interfaces/SolARDescriptorsExtractorFromImageOpencv.h \
1822
interfaces/SolARDeviceDataLoader.h \
1923
interfaces/SolARFiducialMarkerLoaderOpencv.h \
2024
interfaces/SolARFundamentalMatrixEstimationOpencv.h \
@@ -34,8 +38,7 @@ HEADERS += interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
3438
interfaces/SolARKeypointDetectorOpencv.h \
3539
interfaces/SolARKeypointDetectorRegionOpencv.h \
3640
interfaces/SolARMapFusionOpencv.h \
37-
interfaces/SolARMarker2DNaturalImageOpencv.h \
38-
interfaces/SolARMarker2DSquaredBinaryOpencv.h \
41+
interfaces/SolARImageMarkerLoaderOpencv.h \
3942
interfaces/SolARMatchesOverlayOpencv.h \
4043
interfaces/SolARModuleOpencv_traits.h \
4144
interfaces/SolAROpencvAPI.h \
@@ -47,6 +50,10 @@ HEADERS += interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
4750
interfaces/SolARPoseEstimationSACPnpOpencv.h \
4851
interfaces/SolARPoseFinderFrom2D2DOpencv.h \
4952
interfaces/SolARProjectOpencv.h \
53+
interfaces/SolARStereo2DPointsRectificationOpencv.h \
54+
interfaces/SolARStereoCalibrationOpencv.h \
55+
interfaces/SolARStereoDescriptorMatcherOpencv.h \
56+
interfaces/SolARStereoImageRectificationOpencv.h \
5057
interfaces/SolARSVDFundamentalMatrixDecomposerOpencv.h\
5158
interfaces/SolARUndistortPointsOpencv.h \
5259
interfaces/SolARUnprojectPlanarPointsOpencv.h \
@@ -60,6 +67,8 @@ HEADERS += interfaces/SolAR2D3DcorrespondencesFinderOpencv.h \
6067
src/AKAZE2/utils.h
6168

6269
SOURCES += src/AKAZE2/akaze.cpp \
70+
$$PWD/src/SolARImageFilterWallisOpencv.cpp \
71+
$$PWD/src/SolARImageMarkerLoaderOpencv.cpp \
6372
src/AKAZE2/AKAZEFeatures.cpp \
6473
src/AKAZE2/fed.cpp \
6574
src/AKAZE2/nldiffusion_functions.cpp \
@@ -75,11 +84,14 @@ SOURCES += src/AKAZE2/akaze.cpp \
7584
src/SolARDescriptorMatcherHammingBruteForceOpencv.cpp \
7685
src/SolARDescriptorMatcherKNNOpencv.cpp \
7786
src/SolARDescriptorMatcherRadiusOpencv.cpp \
87+
src/SolARDescriptorMatcherGeometricOpencv.cpp \
88+
src/SolARDescriptorMatcherRegionOpencv.cpp \
7889
src/SolARDescriptorsExtractorAKAZE2Opencv.cpp \
7990
src/SolARDescriptorsExtractorAKAZEOpencv.cpp \
8091
src/SolARDescriptorsExtractorORBOpencv.cpp \
8192
src/SolARDescriptorsExtractorSBPatternOpencv.cpp \
8293
src/SolARDescriptorsExtractorSIFTOpencv.cpp \
94+
src/SolARDescriptorsExtractorFromImageOpencv.cpp \
8395
src/SolARDeviceDataLoader.cpp \
8496
src/SolARFiducialMarkerLoaderOpencv.cpp \
8597
src/SolARFundamentalMatrixEstimationOpencv.cpp \
@@ -99,8 +111,6 @@ SOURCES += src/AKAZE2/akaze.cpp \
99111
src/SolARKeypointDetectorOpencv.cpp \
100112
src/SolARKeypointDetectorRegionOpencv.cpp \
101113
src/SolARMapFusionOpencv.cpp \
102-
src/SolARMarker2DNaturalImageOpencv.cpp \
103-
src/SolARMarker2DSquaredBinaryOpencv.cpp \
104114
src/SolARMatchesOverlayOpencv.cpp \
105115
src/SolARModuleOpencv.cpp \
106116
src/SolAROpenCVHelper.cpp \
@@ -111,6 +121,10 @@ SOURCES += src/AKAZE2/akaze.cpp \
111121
src/SolARPoseEstimationSACPnpOpencv.cpp \
112122
src/SolARPoseFinderFrom2D2DOpencv.cpp \
113123
src/SolARProjectOpencv.cpp \
124+
src/SolARStereo2DPointsRectificationOpencv.cpp \
125+
src/SolARStereoCalibrationOpencv.cpp \
126+
src/SolARStereoDescriptorMatcherOpencv.cpp \
127+
src/SolARStereoImageRectificationOpencv.cpp \
114128
src/SolARSVDFundamentalMatrixDecomposerOpencv.cpp \
115129
src/SolARSVDTriangulationOpencv.cpp \
116130
src/SolARUndistortPointsOpencv.cpp \

SolARModuleOpenCV.pro

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
QT -= core gui
33
CONFIG -= qt
44

5+
QMAKE_PROJECT_DEPTH = 0
6+
57
## global defintions : target lib name, version
68
INSTALLSUBDIR = SolARBuild
79
TARGET = SolARModuleOpenCV
810
FRAMEWORK = $$TARGET
9-
VERSION=0.9.1
11+
VERSION=0.10.0
1012

1113
DEFINES += MYVERSION=$${VERSION}
1214
DEFINES += TEMPLATE_LIBRARY
@@ -47,13 +49,19 @@ unix:!android {
4749
# QMAKE_CXX = clang++
4850
}
4951

52+
linux {
53+
QMAKE_LFLAGS += -ldl
54+
LIBS += -L/home/linuxbrew/.linuxbrew/lib # temporary fix caused by grpc with -lre2 ... without -L in grpc.pc
55+
}
56+
5057
macx {
5158
DEFINES += _MACOS_TARGET_
5259
QMAKE_MAC_SDK= macosx
5360
QMAKE_CFLAGS += -mmacosx-version-min=10.7 -std=c11 #-x objective-c++
5461
QMAKE_CXXFLAGS += -mmacosx-version-min=10.7 -std=c11 -std=c++11 -O3 -fPIC#-x objective-c++
5562
QMAKE_LFLAGS += -mmacosx-version-min=10.7 -v -lstdc++
5663
LIBS += -lstdc++ -lc -lpthread
64+
LIBS += -L/usr/local/lib
5765
}
5866

5967
win32 {

bcom-SolARModuleOpenCV.pc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ libdir=${exec_prefix}/lib
55
includedir=${prefix}/interfaces
66
Name: SolARModuleOpenCV
77
Description:
8-
Version: 0.9.1
8+
Version: 0.10.0
99
Requires:
1010
Libs: -L${libdir} -l${libname}
1111
Libs.private: ${libdir}/${pfx}${libname}.${lext}

interfaces/SolARCameraCalibrationOpencv.h

+22-77
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <string>
2323
#include "opencv2/videoio.hpp"
24-
#include "xpcf/component/ComponentBase.h"
24+
#include "xpcf/component/ConfigurableBase.h"
2525

2626
#include "SolAROpencvAPI.h"
2727

@@ -37,93 +37,38 @@ namespace OPENCV {
3737
*/
3838

3939
class SOLAROPENCV_EXPORT_API SolARCameraCalibrationOpencv :
40-
public org::bcom::xpcf::ComponentBase,
40+
public org::bcom::xpcf::ConfigurableBase,
4141
public api::input::devices::ICameraCalibration
4242
{
4343
public:
44-
enum ProcessMode
45-
{
46-
SOLAR_DETECT = 0,
47-
SOLAR_CAPTURE = 1,
48-
SOLAR_CALIBRATED = 2
49-
};
44+
SolARCameraCalibrationOpencv();
45+
~SolARCameraCalibrationOpencv() override;
46+
/// @brief Calibrate the camera device from a sequence of images
47+
/// @param[in] images The set of images for calibration
48+
/// @param[out] camParams The camera paramters
49+
/// @return FrameworkReturnCode::_SUCCESS if calibration succeed, else FrameworkReturnCode::_ERROR_
50+
FrameworkReturnCode calibrate(const std::vector<SRef<SolAR::datastructure::Image>>& images,
51+
SolAR::datastructure::CameraParameters & camParams) override;
5052

51-
public:
52-
SolARCameraCalibrationOpencv();
53-
virtual ~SolARCameraCalibrationOpencv() override;
54-
/// @brief this method calibrates and fixes an unkonwn camera intrinsic parameters from a offline video stream,
55-
/// it saves the result calibration file inside output folder.
56-
/// @param[in] inputVideo: path of the video stream captured by the unkown camera.
57-
/// @param[out] output: path of the folder where a result calibration file will be written.
58-
bool calibrate(const std::string & inputVideo, const std::string & output) override;
59-
/// @brief this method calibrates and fixes an unkonwn camera intrinsic parameters from a online video stream,
60-
/// it saves the result calibration file inside output folder.
61-
/// @param[in] camera_id: id of the unkown camera from which the video stream is grabbed.
62-
/// @param[out] output: path of the folder where a result calibration file will be written.
63-
bool calibrate(int camera_id, const std::string & output) override;
64-
/// @brief this method is used to set intrinsic parameters and distorsion of the camera
65-
/// @param[in] Camera calibration matrix parameters.
66-
/// @param[in] Camera distorsion parameters.
67-
bool setParameters(const std::string & config_file) override;
68-
virtual void unloadComponent() override;
53+
void unloadComponent() override;
6954

55+
private:
56+
bool findChessboardCornersImage(SRef<SolAR::datastructure::Image>& image,
57+
cv::Mat & displayImage,
58+
std::vector<cv::Point2f>& corners);
7059

7160
private:
72-
protected:
61+
cv::Mat m_camMatrix;
62+
cv::Mat m_camDistortion;
7363
cv::Size m_boardSize;
74-
cv::Size m_imageSize;
75-
cv::Mat m_camMatrix;
76-
cv::Mat m_camDistorsion;
77-
64+
cv::Size m_imageSize;
7865
float m_squareSize;
79-
float m_aspectRatio;
80-
81-
int m_nframes;
66+
int m_nbFrames = 30;
67+
int m_nbDropFrames = 0;
8268
int m_flags;
83-
int m_delay;
84-
85-
virtual bool process(cv::VideoCapture &, const std::string &);
86-
87-
static double computeReprojectionErrors(const std::vector<std::vector<cv::Point3f> >& objectPoints,
88-
const std::vector<std::vector<cv::Point2f> >& imagePoints,
89-
const std::vector<cv::Mat>& rvecs, const std::vector<cv::Mat>& tvecs,
90-
const cv::Mat& cameraMatrix, const cv::Mat& distCoeffs,
91-
std::vector<float>& perViewErrors);
92-
93-
static void calcChessboardCorners(cv::Size boardSize, float squareSize, std::vector<cv::Point3f>& corners);
94-
95-
static bool runCalibration(const std::vector<std::vector<cv::Point2f>> & imagePoints,
96-
cv::Size imageSize,
97-
cv::Size boardSize,
98-
float squareSize,
99-
float aspectRatio,
100-
int flags,
101-
cv::Mat& cameraMatrix,
102-
cv::Mat& distCoeffs,
103-
std::vector<cv::Mat>& rvecs,
104-
std::vector<cv::Mat>& tvecs,
105-
std::vector<float>& reprojErrs,
106-
double& totalAvgErr);
107-
108-
static void saveCameraParams(const std::string& filename,
109-
cv::Size imageSize,
110-
cv::Size boardSize,
111-
float squareSize,
112-
float aspectRatio,
113-
int flags,
114-
const cv::Mat& cameraMatrix,
115-
const cv::Mat& distCoeffs);
116-
117-
static bool runAndSave(const std::string& outputFilename,
118-
const std::vector<std::vector<cv::Point2f> >& imagePoints,
119-
cv::Size imageSize,
120-
cv::Size boardSize,
121-
float squareSize,
122-
float aspectRatio,
123-
int flags,
124-
cv::Mat& cameraMatrix,
125-
cv::Mat& distCoeffs);
69+
int m_waitTime = 30;
12670
};
71+
12772
}
12873
}
12974
} // end of namespace Solar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* @copyright Copyright (c) 2017 B-com http://www.b-com.com/
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef SOLARDESCRIPTORMATCHERGEOMETRICOPENCV_H
18+
#define SOLARDESCRIPTORMATCHERGEOMETRICOPENCV_H
19+
20+
#include "base/features/ADescriptorMatcherGeometric.h"
21+
#include "SolAROpencvAPI.h"
22+
#include <limits>
23+
#include "opencv2/core.hpp"
24+
#include "opencv2/features2d.hpp"
25+
#include "opencv2/imgcodecs.hpp"
26+
#include "opencv2/highgui.hpp"
27+
#include <opencv2/calib3d.hpp>
28+
29+
namespace SolAR {
30+
namespace MODULES {
31+
namespace OPENCV {
32+
33+
/**
34+
* @class SolARDescriptorMatcherGeometricOpencv
35+
* @brief <B>Matches two sets of descriptors based on geometric constraints.</B>
36+
* <TT>UUID: 389ece8b-9e29-45ae-bd60-de1784ff0931</TT>
37+
*
38+
* @SolARComponentPropertiesBegin
39+
* @SolARComponentProperty{ distanceRatio,
40+
* distance ratio used to keep good matches.<br/>
41+
* Several matches can correspond to a given keypoint of the first image. The first match with the best score is always retained.<br>
42+
* But here\, we can also retain the second match if its distance or score is greater than the score of the best match * m_distanceRatio.,
43+
* @SolARComponentPropertyDescNum{ float, [0..MAX FLOAT], default: 0.75f }}
44+
* @SolARComponentProperty{ paddingRatio,
45+
* ,
46+
* @SolARComponentPropertyDescNum{ float, [0..MAX FLOAT], 0.003f }}
47+
* @SolARComponentProperty{ matchingDistanceMax,
48+
* ,
49+
* @SolARComponentPropertyDescNum{ float, [0..MAX FLOAT], 500.f }}
50+
* @SolARComponentPropertiesEnd
51+
*
52+
*
53+
*/
54+
55+
class SOLAROPENCV_EXPORT_API SolARDescriptorMatcherGeometricOpencv : public base::features::ADescriptorMatcherGeometric {
56+
public:
57+
/// @brief SolARDescriptorMatcherGeometricOpencv constructor
58+
SolARDescriptorMatcherGeometricOpencv();
59+
60+
/// @brief SolARDescriptorMatcherGeometricOpencv destructor
61+
~SolARDescriptorMatcherGeometricOpencv() override;
62+
63+
/// @brief Match two sets of descriptors from two frames based on epipolar constraint.
64+
/// @param[in] descriptors1 The first set of descriptors.
65+
/// @param[in] descriptors2 The second set of descriptors.
66+
/// @param[in] undistortedKeypoints1 The first set of undistorted keypoints.
67+
/// @param[in] undistortedKeypoints2 The second set of undistorted keypoints.
68+
/// @param[in] pose1 The first pose.
69+
/// @param[in] pose2 The second pose.
70+
/// @param[in] camParams The intrinsic parameters of the camera.
71+
/// @param[out] matches A vector of matches representing pairs of indices relatively to the first and second set of descriptors.
72+
/// @param[in] mask The indices of descriptors in the first frame are used for matching to the second frame. If it is empty then all will be used.
73+
/// @return FrameworkReturnCode::_SUCCESS if matching succeed, else FrameworkReturnCode::_ERROR_
74+
FrameworkReturnCode match(const SRef<SolAR::datastructure::DescriptorBuffer> descriptors1,
75+
const SRef<SolAR::datastructure::DescriptorBuffer> descriptors2,
76+
const std::vector<SolAR::datastructure::Keypoint> &undistortedKeypoints1,
77+
const std::vector<SolAR::datastructure::Keypoint> &undistortedKeypoints2,
78+
const SolAR::datastructure::Transform3Df& pose1,
79+
const SolAR::datastructure::Transform3Df& pose2,
80+
const SolAR::datastructure::CameraParameters& camParams,
81+
std::vector<SolAR::datastructure::DescriptorMatch> & matches,
82+
const std::vector<uint32_t>& mask = {}) override;
83+
84+
void unloadComponent() override;
85+
86+
private:
87+
float m_distanceRatio = 0.75f;
88+
float m_paddingRatio = 0.003f;
89+
float m_matchingDistanceMax = 500.f;
90+
cv::FlannBasedMatcher m_matcher;
91+
92+
};
93+
94+
}
95+
}
96+
} // end of namespace SolAR
97+
98+
#endif // SOLARDESCRIPTORMATCHERGEOMETRICOPENCV_H

0 commit comments

Comments
 (0)