vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e

This commit is contained in:
Gitea Mirror Bot
2026-08-22 00:11:13 +08:00
commit 12022378a3
3872 changed files with 2513409 additions and 0 deletions
@@ -0,0 +1,28 @@
Import Reconstruction {#tutorial_sfm_import_reconstruction}
=====================
Goal
----
In this tutorial you will learn how to import a reconstruction from a given file obtained with Bundler [1]:
- Load a file containing a set of cameras and 3D points.
- Show obtained results using Viz.
Code
----
@include sfm/samples/import_reconstruction.cpp
Results
-------
The following picture shows a reconstruction from la *Sagrada Familia* (BCN) using dataset [2].
![](pics/import_sagrada_familia.png)
[1] [http://www.cs.cornell.edu/~snavely/bundler](http://www.cs.cornell.edu/~snavely/bundler)
[2] Penate Sanchez, A. and Moreno-Noguer, F. and Andrade Cetto, J. and Fleuret, F. (2014). LETHA: Learning from High Quality Inputs for 3D Pose Estimation in Low Quality Images. Proceedings of the International Conference on 3D vision (3DV).
[URL](http://www.iri.upc.edu/research/webprojects/pau/datasets/sagfam)
@@ -0,0 +1,62 @@
SFM module installation {#tutorial_sfm_installation}
=======================
Dependencies
------------
The Structure from Motion module depends on some open source libraries.
- [Eigen](http://eigen.tuxfamily.org) 3.2.2 or later. \b Required
- [GLog](https://github.com/google/glog) 0.3.1 or later. \b Required
- [GFlags]( https://github.com/gflags). \b Required
- [Ceres Solver](http://ceres-solver.org). Needed by the reconstruction API in order to solve part of the Bundle Adjustment plus the points Intersect. If Ceres Solver is not installed on your system, the reconstruction funcionality will be disabled. \b Recommended
Installation
------------
__Required Dependencies__
In case you are on [Ubuntu](http://www.ubuntu.com) you can simply install the required dependencies by typing the following command:
@code{.bash}
sudo apt-get install libeigen3-dev libgflags-dev libgoogle-glog-dev
@endcode
__Ceres Solver__
Start by installing all the dependencies:
@code{.bash}
# CMake
sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev
# BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3
sudo apt-get install libeigen3-dev
# SuiteSparse and CXSparse (optional)
# - If you want to build Ceres as a *static* library (the default)
# you can use the SuiteSparse package in the main Ubuntu package
# repository:
sudo apt-get install libsuitesparse-dev
# - However, if you want to build Ceres as a *shared* library, you must
# add the following PPA:
sudo add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687
sudo apt-get update
sudo apt-get install libsuitesparse-dev
@endcode
We are now ready to build, test, and install Ceres:
@code{.bash}
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
mkdir build && cd build
cmake ..
make -j4
make test
sudo make install
@endcode
@@ -0,0 +1,104 @@
Scene Reconstruction {#tutorial_sfm_scene_reconstruction}
====================
Goal
----
In this tutorial you will learn how to use the reconstruction api for sparse reconstruction:
- Load and file with a list of image paths.
- Run libmv reconstruction pipeline.
- Show obtained results using Viz.
Code
----
@include sfm/samples/scene_reconstruction.cpp
Explanation
-----------
Firstly, we need to load the file containing list of image paths in order to feed the reconstruction api:
@code{.cpp}
/home/eriba/software/opencv_contrib/modules/sfm/samples/data/images/resized_IMG_2889.jpg
/home/eriba/software/opencv_contrib/modules/sfm/samples/data/images/resized_IMG_2890.jpg
/home/eriba/software/opencv_contrib/modules/sfm/samples/data/images/resized_IMG_2891.jpg
/home/eriba/software/opencv_contrib/modules/sfm/samples/data/images/resized_IMG_2892.jpg
...
int getdir(const string _filename, vector<string> &files)
{
ifstream myfile(_filename.c_str());
if (!myfile.is_open()) {
cout << "Unable to read file: " << _filename << endl;
exit(0);
} else {
string line_str;
while ( getline(myfile, line_str) )
files.push_back(line_str);
}
return 1;
}
@endcode
Secondly, the built container will be used to feed the reconstruction api. It is important outline that the estimated results must be stored in a vector<Mat>. In this
case is called the overloaded signature for real images which from the images, internally extracts and compute the sparse 2d features using DAISY descriptors in order to be matched using FlannBasedMatcher and build the tracks structure.
@code{.cpp}
bool is_projective = true;
vector<Mat> Rs_est, ts_est, points3d_estimated;
reconstruct(images_paths, Rs_est, ts_est, K, points3d_estimated, is_projective);
// Print output
cout << "\n----------------------------\n" << endl;
cout << "Reconstruction: " << endl;
cout << "============================" << endl;
cout << "Estimated 3D points: " << points3d_estimated.size() << endl;
cout << "Estimated cameras: " << Rs_est.size() << endl;
cout << "Refined intrinsics: " << endl << K << endl << endl;
@endcode
Finally, the obtained results will be shown in Viz.
Usage and Results
-----------------
In order to run this sample we need to specify the path to the image paths files, the focal length of the camera in addition to the center projection coordinates (in pixels).
**1. Middlebury temple**
Using following image sequence [1] and the followings camera parameters we can compute the sparse 3d reconstruction:
@code{.bash}
./example_sfm_scene_reconstruction image_paths_file.txt 800 400 225
@endcode
![](pics/temple_input.jpg)
The following picture shows the obtained camera motion in addition to the estimated sparse 3d reconstruction:
![](pics/temple_reconstruction.jpg)
**2. Sagrada Familia**
Using following image sequence [2] and the followings camera parameters we can compute the sparse 3d reconstruction:
@code{.bash}
./example_sfm_scene_reconstruction image_paths_file.txt 350 240 360
@endcode
![](pics/sagrada_familia_input.jpg)
The following picture shows the obtained camera motion in addition to the estimated sparse 3d reconstruction:
![](pics/sagrada_familia_reconstruction.jpg)
[1] [http://vision.middlebury.edu/mview/data](http://vision.middlebury.edu/mview/data)
[2] Penate Sanchez, A. and Moreno-Noguer, F. and Andrade Cetto, J. and Fleuret, F. (2014). LETHA: Learning from High Quality Inputs for 3D Pose Estimation in Low Quality Images. Proceedings of the International Conference on 3D vision (3DV).
[URL](http://www.iri.upc.edu/research/webprojects/pau/datasets/sagfam)
@@ -0,0 +1,82 @@
Camera Motion Estimation {#tutorial_sfm_trajectory_estimation}
========================
Goal
----
In this tutorial you will learn how to use the reconstruction api for camera motion estimation:
- Load a file with the tracked 2d points and build the container over all the frames.
- Run libmv reconstruction pipeline.
- Show obtained results using Viz.
Code
----
@include sfm/samples/trajectory_reconstruction.cpp
Explanation
-----------
Firstly, we need to load the file containing the 2d points tracked over all the frames and construct the container to feed the reconstruction api. In this case the tracked 2d points will have the following structure, a vector of 2d points array, where each inner array represents a different frame. Every frame is composed by a list of 2d points which e.g. the first point in frame 1 is the same point in frame 2. If there is no point in a frame the assigned value will be (-1,-1):
@code{.cpp}
/* Build the following structure data
*
* frame1 frame2 frameN
* track1 | (x11,y11) | -> | (x12,y12) | -> | (x1N,y1N) |
* track2 | (x21,y11) | -> | (x22,y22) | -> | (x2N,y2N) |
* trackN | (xN1,yN1) | -> | (xN2,yN2) | -> | (xNN,yNN) |
*
*
* In case a marker (x,y) does not appear in a frame its
* values will be (-1,-1).
*/
...
for (int i = 0; i < n_frames; ++i)
{
Mat_<double> frame(2, n_tracks);
for (int j = 0; j < n_tracks; ++j)
{
frame(0,j) = tracks[j][i][0];
frame(1,j) = tracks[j][i][1];
}
points2d.push_back(Mat(frame));
}
@endcode
Secondly, the built container will be used to feed the reconstruction api. It is important outline that the estimated results must be stored in a vector<Mat>:
@code{.cpp}
bool is_projective = true;
vector<Mat> Rs_est, ts_est, points3d_estimated;
reconstruct(points2d, Rs_est, ts_est, K, points3d_estimated, is_projective);
// Print output
cout << "\n----------------------------\n" << endl;
cout << "Reconstruction: " << endl;
cout << "============================" << endl;
cout << "Estimated 3D points: " << points3d_estimated.size() << endl;
cout << "Estimated cameras: " << Rs_est.size() << endl;
cout << "Refined intrinsics: " << endl << K << endl << endl;
@endcode
Finally, the obtained results will be shown in Viz, in this case reproducing the camera with an oscillation effect.
Usage and Results
-----------------
In order to run this sample we need to specify the path to the tracked points file, the focal length of the camera in addition to the center projection coordinates (in pixels). You can find a sample file in samples/data/desktop_trakcks.txt
@code{.bash}
./example_sfm_trajectory_reconstruction desktop_tracks.txt 1914 640 360
@endcode
The following picture shows the obtained camera motion obtained from the tracked 2d points:
![](pics/desktop_trajectory.png)
@@ -0,0 +1,34 @@
Structure From Motion {#tutorial_table_of_content_sfm}
=====================
- @subpage tutorial_sfm_installation
*Compatibility:* \> OpenCV 3.0
*Author:* Edgar Riba
Instructions in order to properly setup the Structure from Motion module.
- @subpage tutorial_sfm_trajectory_estimation
*Compatibility:* \> OpenCV 3.0
*Author:* Edgar Riba
Camera motion estimation from a given set of tracked 2d points.
- @subpage tutorial_sfm_scene_reconstruction
*Compatibility:* \> OpenCV 3.0
*Author:* Edgar Riba
Sparse scene reconstruction from a given set of images.
- @subpage tutorial_sfm_import_reconstruction
*Compatibility:* \> OpenCV 3.0
*Author:* Edgar Riba
Import a scene reconstruction.