vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_SFM_HPP__
|
||||
#define __OPENCV_SFM_HPP__
|
||||
|
||||
#include <opencv2/sfm/conditioning.hpp>
|
||||
#include <opencv2/sfm/fundamental.hpp>
|
||||
#include <opencv2/sfm/io.hpp>
|
||||
#include <opencv2/sfm/numeric.hpp>
|
||||
#include <opencv2/sfm/projection.hpp>
|
||||
#include <opencv2/sfm/triangulation.hpp>
|
||||
#if CERES_FOUND
|
||||
#include <opencv2/sfm/reconstruct.hpp>
|
||||
#include <opencv2/sfm/simple_pipeline.hpp>
|
||||
#endif
|
||||
|
||||
/** @defgroup sfm Structure From Motion
|
||||
|
||||
The opencv_sfm module contains algorithms to perform 3d reconstruction
|
||||
from 2d images.\n
|
||||
The core of the module is based on a light version of
|
||||
[Libmv](https://developer.blender.org/project/profile/59) originally
|
||||
developed by Sameer Agarwal and Keir Mierle.
|
||||
|
||||
__Whats is libmv?__ \n
|
||||
libmv, also known as the Library for Multiview Reconstruction (or LMV),
|
||||
is the computer vision backend for Blender's motion tracking abilities.
|
||||
Unlike other vision libraries with general ambitions, libmv is focused
|
||||
on algorithms for match moving, specifically targeting [Blender](https://developer.blender.org) as the
|
||||
primary customer. Dense reconstruction, reconstruction from unorganized
|
||||
photo collections, image recognition, and other tasks are not a focus
|
||||
of libmv.
|
||||
|
||||
__Development__ \n
|
||||
libmv is officially under the Blender umbrella, and so is developed
|
||||
on developer.blender.org. The [source repository](https://developer.blender.org/diffusion/LMV) can get checked out
|
||||
independently from Blender.
|
||||
|
||||
This module has been originally developed as a project for Google Summer of Code 2012-2015.
|
||||
|
||||
@note
|
||||
- Notice that it is compiled only when Eigen, GLog and GFlags are correctly installed.\n
|
||||
Check installation instructions in the following tutorial: @ref tutorial_sfm_installation
|
||||
|
||||
@{
|
||||
@defgroup conditioning Conditioning
|
||||
@defgroup fundamental Fundamental
|
||||
@defgroup io Input/Output
|
||||
@defgroup numeric Numeric
|
||||
@defgroup projection Projection
|
||||
@defgroup robust Robust Estimation
|
||||
@defgroup triangulation Triangulation
|
||||
|
||||
@defgroup reconstruction Reconstruction
|
||||
|
||||
@note
|
||||
- Notice that it is compiled only when Ceres Solver is correctly installed.\n
|
||||
Check installation instructions in the following tutorial: @ref tutorial_sfm_installation
|
||||
|
||||
@defgroup simple_pipeline Simple Pipeline
|
||||
|
||||
@note
|
||||
- Notice that it is compiled only when Ceres Solver is correctly installed.\n
|
||||
Check installation instructions in the following tutorial: @ref tutorial_sfm_installation
|
||||
@}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_CONDITIONING_HPP__
|
||||
#define __OPENCV_CONDITIONING_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup conditioning
|
||||
//! @{
|
||||
|
||||
/** Point conditioning (non isotropic).
|
||||
@param points Input vector of N-dimensional points.
|
||||
@param T Output 3x3 transformation matrix.
|
||||
|
||||
Computes the transformation matrix such that the two principal moments of the set of points are equal to unity,
|
||||
forming an approximately symmetric circular cloud of points of radius 1 about the origin.\n
|
||||
Reference: @cite HartleyZ00 4.4.4 pag.109
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
preconditionerFromPoints( InputArray points,
|
||||
OutputArray T );
|
||||
|
||||
/** @brief Point conditioning (isotropic).
|
||||
@param points Input vector of N-dimensional points.
|
||||
@param T Output 3x3 transformation matrix.
|
||||
|
||||
Computes the transformation matrix such that each coordinate direction will be scaled equally,
|
||||
bringing the centroid to the origin with an average centroid \f$(1,1,1)^T\f$.\n
|
||||
Reference: @cite HartleyZ00 4.4.4 pag.107.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
isotropicPreconditionerFromPoints( InputArray points,
|
||||
OutputArray T );
|
||||
|
||||
/** @brief Apply Transformation to points.
|
||||
@param points Input vector of N-dimensional points.
|
||||
@param T Input 3x3 transformation matrix such that \f$x = T*X\f$, where \f$X\f$ are the points to transform and \f$x\f$ the transformed points.
|
||||
@param transformed_points Output vector of N-dimensional transformed points.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
applyTransformationToPoints( InputArray points,
|
||||
InputArray T,
|
||||
OutputArray transformed_points );
|
||||
|
||||
/** @brief This function normalizes points (non isotropic).
|
||||
@param points Input vector of N-dimensional points.
|
||||
@param normalized_points Output vector of the same N-dimensional points but with mean 0 and average norm \f$\sqrt{2}\f$.
|
||||
@param T Output 3x3 transform matrix such that \f$x = T*X\f$, where \f$X\f$ are the points to normalize and \f$x\f$ the normalized points.
|
||||
|
||||
Internally calls @ref preconditionerFromPoints in order to get the scaling matrix before applying @ref applyTransformationToPoints.
|
||||
This operation is an essential step before applying the DLT algorithm in order to consider the result as optimal.\n
|
||||
Reference: @cite HartleyZ00 4.4.4 pag.109
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
normalizePoints( InputArray points,
|
||||
OutputArray normalized_points,
|
||||
OutputArray T );
|
||||
|
||||
/** @brief This function normalizes points. (isotropic).
|
||||
@param points Input vector of N-dimensional points.
|
||||
@param normalized_points Output vector of the same N-dimensional points but with mean 0 and average norm \f$\sqrt{2}\f$.
|
||||
@param T Output 3x3 transform matrix such that \f$x = T*X\f$, where \f$X\f$ are the points to normalize and \f$x\f$ the normalized points.
|
||||
|
||||
Internally calls @ref preconditionerFromPoints in order to get the scaling matrix before applying @ref applyTransformationToPoints.
|
||||
This operation is an essential step before applying the DLT algorithm in order to consider the result as optimal.\n
|
||||
Reference: @cite HartleyZ00 4.4.4 pag.107.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
normalizeIsotropicPoints( InputArray points,
|
||||
OutputArray normalized_points,
|
||||
OutputArray T );
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace sfm */
|
||||
} /* namespace cv */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_SFM_FUNDAMENTAL_HPP__
|
||||
#define __OPENCV_SFM_FUNDAMENTAL_HPP__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup fundamental
|
||||
//! @{
|
||||
|
||||
/** @brief Get projection matrices from Fundamental matrix
|
||||
@param F Input 3x3 fundamental matrix.
|
||||
@param P1 Output 3x4 one possible projection matrix.
|
||||
@param P2 Output 3x4 another possible projection matrix.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
projectionsFromFundamental( InputArray F,
|
||||
OutputArray P1,
|
||||
OutputArray P2 );
|
||||
|
||||
/** @brief Get Fundamental matrix from Projection matrices.
|
||||
@param P1 Input 3x4 first projection matrix.
|
||||
@param P2 Input 3x4 second projection matrix.
|
||||
@param F Output 3x3 fundamental matrix.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
fundamentalFromProjections( InputArray P1,
|
||||
InputArray P2,
|
||||
OutputArray F );
|
||||
|
||||
/** @brief Estimate the fundamental matrix between two dataset of 2D point (image coords space).
|
||||
@param x1 Input 2xN Array of 2D points in view 1.
|
||||
@param x2 Input 2xN Array of 2D points in view 2.
|
||||
@param F Output 3x3 fundamental matrix.
|
||||
|
||||
Uses the normalized 8-point fundamental matrix solver.
|
||||
Reference: @cite HartleyZ00 11.2 pag.281 (x1 = x, x2 = x')
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
normalizedEightPointSolver( InputArray x1,
|
||||
InputArray x2,
|
||||
OutputArray F );
|
||||
|
||||
/** @brief Computes the relative camera motion between two cameras.
|
||||
@param R1 Input 3x3 first camera rotation matrix.
|
||||
@param t1 Input 3x1 first camera translation vector.
|
||||
@param R2 Input 3x3 second camera rotation matrix.
|
||||
@param t2 Input 3x1 second camera translation vector.
|
||||
@param R Output 3x3 relative rotation matrix.
|
||||
@param t Output 3x1 relative translation vector.
|
||||
|
||||
Given the motion parameters of two cameras, computes the motion parameters
|
||||
of the second one assuming the first one to be at the origin.
|
||||
If T1 and T2 are the camera motions, the computed relative motion is \f$T = T_2 T_1^{-1}\f$
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
relativeCameraMotion( InputArray R1,
|
||||
InputArray t1,
|
||||
InputArray R2,
|
||||
InputArray t2,
|
||||
OutputArray R,
|
||||
OutputArray t );
|
||||
|
||||
/** Get Motion (R's and t's ) from Essential matrix.
|
||||
@param E Input 3x3 essential matrix.
|
||||
@param Rs Output vector of 3x3 rotation matrices.
|
||||
@param ts Output vector of 3x1 translation vectors.
|
||||
|
||||
Reference: @cite HartleyZ00 9.6 pag 259 (Result 9.19)
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
motionFromEssential( InputArray E,
|
||||
OutputArrayOfArrays Rs,
|
||||
OutputArrayOfArrays ts );
|
||||
|
||||
/** Choose one of the four possible motion solutions from an essential matrix.
|
||||
@param Rs Input vector of 3x3 rotation matrices.
|
||||
@param ts Input vector of 3x1 translation vectors.
|
||||
@param K1 Input 3x3 first camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$.
|
||||
@param x1 Input 2x1 vector with first 2d point.
|
||||
@param K2 Input 3x3 second camera matrix. The parameters are similar to K1.
|
||||
@param x2 Input 2x1 vector with second 2d point.
|
||||
|
||||
Decides the right solution by checking that the triangulation of a match
|
||||
x1--x2 lies in front of the cameras. Return index of the right solution or -1 if no solution.
|
||||
|
||||
Reference: See @cite HartleyZ00 9.6 pag 259 (9.6.3 Geometrical interpretation of the 4 solutions).
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
int motionFromEssentialChooseSolution( InputArrayOfArrays Rs,
|
||||
InputArrayOfArrays ts,
|
||||
InputArray K1,
|
||||
InputArray x1,
|
||||
InputArray K2,
|
||||
InputArray x2 );
|
||||
|
||||
/** @brief Get Essential matrix from Fundamental and Camera matrices.
|
||||
@param E Input 3x3 essential matrix.
|
||||
@param K1 Input 3x3 first camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$.
|
||||
@param K2 Input 3x3 second camera matrix. The parameters are similar to K1.
|
||||
@param F Output 3x3 fundamental matrix.
|
||||
|
||||
Reference: @cite HartleyZ00 9.6 pag 257 (formula 9.12) or http://ai.stanford.edu/~birch/projective/node20.html
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
fundamentalFromEssential( InputArray E,
|
||||
InputArray K1,
|
||||
InputArray K2,
|
||||
OutputArray F );
|
||||
|
||||
/** @brief Get Essential matrix from Fundamental and Camera matrices.
|
||||
@param F Input 3x3 fundamental matrix.
|
||||
@param K1 Input 3x3 first camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$.
|
||||
@param K2 Input 3x3 second camera matrix. The parameters are similar to K1.
|
||||
@param E Output 3x3 essential matrix.
|
||||
|
||||
Reference: @cite HartleyZ00 9.6 pag 257 (formula 9.12)
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
essentialFromFundamental( InputArray F,
|
||||
InputArray K1,
|
||||
InputArray K2,
|
||||
OutputArray E );
|
||||
|
||||
/** @brief Get Essential matrix from Motion (R's and t's ).
|
||||
@param R1 Input 3x3 first camera rotation matrix.
|
||||
@param t1 Input 3x1 first camera translation vector.
|
||||
@param R2 Input 3x3 second camera rotation matrix.
|
||||
@param t2 Input 3x1 second camera translation vector.
|
||||
@param E Output 3x3 essential matrix.
|
||||
|
||||
Reference: @cite HartleyZ00 9.6 pag 257 (formula 9.12)
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
essentialFromRt( InputArray R1,
|
||||
InputArray t1,
|
||||
InputArray R2,
|
||||
InputArray t2,
|
||||
OutputArray E );
|
||||
|
||||
/** @brief Normalizes the Fundamental matrix.
|
||||
@param F Input 3x3 fundamental matrix.
|
||||
@param F_normalized Output 3x3 normalized fundamental matrix.
|
||||
|
||||
By default divides the fundamental matrix by its L2 norm.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
normalizeFundamental( InputArray F,
|
||||
OutputArray F_normalized );
|
||||
|
||||
/** @brief Computes Absolute or Exterior Orientation (Pose Estimation) between 2 sets of 3D point.
|
||||
@param x1 Input first 3xN or 2xN array of points.
|
||||
@param x2 Input second 3xN or 2xN array of points.
|
||||
@param R Output 3x3 computed rotation matrix.
|
||||
@param t Output 3x1 computed translation vector.
|
||||
@param s Output computed scale factor.
|
||||
|
||||
Find the best transformation such that xp=projection*(s*R*x+t) (same as Pose Estimation, ePNP).
|
||||
The routines below are only for the orthographic case for now.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
computeOrientation( InputArrayOfArrays x1,
|
||||
InputArrayOfArrays x2,
|
||||
OutputArray R,
|
||||
OutputArray t,
|
||||
double s );
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace sfm */
|
||||
} /* namespace cv */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,88 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_SFM_IO_HPP__
|
||||
#define __OPENCV_SFM_IO_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup io
|
||||
//! @{
|
||||
|
||||
/** @brief Different supported file formats.
|
||||
*/
|
||||
enum {
|
||||
SFM_IO_BUNDLER = 0,
|
||||
SFM_IO_VISUALSFM = 1,
|
||||
SFM_IO_OPENSFM = 2,
|
||||
SFM_IO_OPENMVG = 3,
|
||||
SFM_IO_THEIASFM = 4
|
||||
};
|
||||
|
||||
/** @brief Import a reconstruction file.
|
||||
@param file The path to the file.
|
||||
@param Rs Output vector of 3x3 rotations of the camera
|
||||
@param Ts Output vector of 3x1 translations of the camera.
|
||||
@param Ks Output vector of 3x3 instrinsics of the camera.
|
||||
@param points3d Output array with 3d points. Is 3 x N.
|
||||
@param file_format The format of the file to import.
|
||||
|
||||
The function supports reconstructions from Bundler.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
importReconstruction(const cv::String &file, OutputArrayOfArrays Rs,
|
||||
OutputArrayOfArrays Ts, OutputArrayOfArrays Ks,
|
||||
OutputArrayOfArrays points3d, int file_format = SFM_IO_BUNDLER);
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace sfm */
|
||||
} /* namespace cv */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_SFM_NUMERIC_HPP__
|
||||
#define __OPENCV_SFM_NUMERIC_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup numeric
|
||||
//! @{
|
||||
|
||||
/** @brief Computes the mean and variance of a given matrix along its rows.
|
||||
@param A Input NxN matrix.
|
||||
@param mean Output Nx1 matrix with computed mean.
|
||||
@param variance Output Nx1 matrix with computed variance.
|
||||
|
||||
It computes in the same way as woud do @ref reduce but with \a Variance function.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
meanAndVarianceAlongRows( InputArray A,
|
||||
OutputArray mean,
|
||||
OutputArray variance );
|
||||
|
||||
/** @brief Returns the 3x3 skew symmetric matrix of a vector.
|
||||
@param x Input 3x1 vector.
|
||||
|
||||
Reference: @cite HartleyZ00, p581, equation (A4.5).
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
Mat
|
||||
skew( InputArray x );
|
||||
|
||||
///** @brief Returns the skew anti-symmetric matrix of a vector.
|
||||
// @param x Input 3x3 matrix.
|
||||
//*/
|
||||
//CV_EXPORTS
|
||||
//Matx33d
|
||||
//skewMat( const Vec3d &x );
|
||||
//
|
||||
///** @brief Returns the skew anti-symmetric matrix of a vector with only the first two (independent) lines.
|
||||
// @param x Input 3x3 matrix.
|
||||
//*/
|
||||
//CV_EXPORTS
|
||||
//Matx33d
|
||||
//skewMatMinimal( const Vec3d &x );
|
||||
|
||||
//! @} numeric
|
||||
|
||||
} /* namespace sfm */
|
||||
} /* namespace cv */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_PROJECTION_HPP__
|
||||
#define __OPENCV_PROJECTION_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup projection
|
||||
//! @{
|
||||
|
||||
/** @brief Converts point coordinates from homogeneous to euclidean pixel coordinates. E.g., ((x,y,z)->(x/z, y/z))
|
||||
@param src Input vector of N-dimensional points.
|
||||
@param dst Output vector of N-1-dimensional points.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
homogeneousToEuclidean(InputArray src, OutputArray dst);
|
||||
|
||||
/** @brief Converts points from Euclidean to homogeneous space. E.g., ((x,y)->(x,y,1))
|
||||
@param src Input vector of N-dimensional points.
|
||||
@param dst Output vector of N+1-dimensional points.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
euclideanToHomogeneous(InputArray src, OutputArray dst);
|
||||
|
||||
/** @brief Get projection matrix P from K, R and t.
|
||||
@param K Input 3x3 camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$.
|
||||
@param R Input 3x3 rotation matrix.
|
||||
@param t Input 3x1 translation vector.
|
||||
@param P Output 3x4 projection matrix.
|
||||
|
||||
This function estimate the projection matrix by solving the following equation: \f$P = K * [R|t]\f$
|
||||
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
projectionFromKRt(InputArray K, InputArray R, InputArray t, OutputArray P);
|
||||
|
||||
/** @brief Get K, R and t from projection matrix P, decompose using the RQ decomposition.
|
||||
@param P Input 3x4 projection matrix.
|
||||
@param K Output 3x3 camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$.
|
||||
@param R Output 3x3 rotation matrix.
|
||||
@param t Output 3x1 translation vector.
|
||||
|
||||
Reference: @cite HartleyZ00 A4.1.1 pag.579
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
KRtFromProjection( InputArray P, OutputArray K, OutputArray R, OutputArray t );
|
||||
|
||||
/** @brief Returns the depth of a point transformed by a rigid transform.
|
||||
@param R Input 3x3 rotation matrix.
|
||||
@param t Input 3x1 translation vector.
|
||||
@param X Input 3x1 or 4x1 vector with the 3d point.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
double
|
||||
depth( InputArray R, InputArray t, InputArray X);
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace sfm */
|
||||
} /* namespace cv */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,143 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_SFM_RECONSTRUCT_HPP__
|
||||
#define __OPENCV_SFM_RECONSTRUCT_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup reconstruction
|
||||
//! @{
|
||||
|
||||
#if defined(CV_DOXYGEN) || defined(CERES_FOUND)
|
||||
|
||||
/** @brief Reconstruct 3d points from 2d correspondences while performing autocalibration.
|
||||
@param points2d Input vector of vectors of 2d points (the inner vector is per image).
|
||||
@param Ps Output vector with the 3x4 projections matrices of each image.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
@param K Input/Output camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$. Input parameters used as initial guess.
|
||||
@param is_projective if true, the cameras are supposed to be projective.
|
||||
|
||||
This method calls below signature and extracts projection matrices from estimated K, R and t.
|
||||
|
||||
@note
|
||||
- Tracks must be as precise as possible. It does not handle outliers and is very sensible to them.
|
||||
*/
|
||||
CV_EXPORTS
|
||||
void
|
||||
reconstruct(InputArrayOfArrays points2d, OutputArray Ps, OutputArray points3d, InputOutputArray K,
|
||||
bool is_projective = false);
|
||||
|
||||
/** @brief Reconstruct 3d points from 2d correspondences while performing autocalibration.
|
||||
@param points2d Input vector of vectors of 2d points (the inner vector is per image).
|
||||
@param Rs Output vector of 3x3 rotations of the camera.
|
||||
@param Ts Output vector of 3x1 translations of the camera.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
@param K Input/Output camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$. Input parameters used as initial guess.
|
||||
@param is_projective if true, the cameras are supposed to be projective.
|
||||
|
||||
Internally calls libmv simple pipeline routine with some default parameters by instatiating SFMLibmvEuclideanReconstruction class.
|
||||
|
||||
@note
|
||||
- Tracks must be as precise as possible. It does not handle outliers and is very sensible to them.
|
||||
- To see a working example for camera motion reconstruction, check the following tutorial: @ref tutorial_sfm_trajectory_estimation.
|
||||
*/
|
||||
CV_EXPORTS
|
||||
void
|
||||
reconstruct(InputArrayOfArrays points2d, OutputArray Rs, OutputArray Ts, InputOutputArray K,
|
||||
OutputArray points3d, bool is_projective = false);
|
||||
|
||||
/** @brief Reconstruct 3d points from 2d images while performing autocalibration.
|
||||
@param images a vector of string with the images paths.
|
||||
@param Ps Output vector with the 3x4 projections matrices of each image.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
@param K Input/Output camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$. Input parameters used as initial guess.
|
||||
@param is_projective if true, the cameras are supposed to be projective.
|
||||
|
||||
This method calls below signature and extracts projection matrices from estimated K, R and t.
|
||||
|
||||
@note
|
||||
- The images must be ordered as they were an image sequence. Additionally, each frame should be as close as posible to the previous and posterior.
|
||||
- For now DAISY features are used in order to compute the 2d points tracks and it only works for 3-4 images.
|
||||
*/
|
||||
CV_EXPORTS
|
||||
void
|
||||
reconstruct(const std::vector<String> images, OutputArray Ps, OutputArray points3d,
|
||||
InputOutputArray K, bool is_projective = false);
|
||||
|
||||
/** @brief Reconstruct 3d points from 2d images while performing autocalibration.
|
||||
@param images a vector of string with the images paths.
|
||||
@param Rs Output vector of 3x3 rotations of the camera.
|
||||
@param Ts Output vector of 3x1 translations of the camera.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
@param K Input/Output camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$. Input parameters used as initial guess.
|
||||
@param is_projective if true, the cameras are supposed to be projective.
|
||||
|
||||
Internally calls libmv simple pipeline routine with some default parameters by instatiating SFMLibmvEuclideanReconstruction class.
|
||||
|
||||
@note
|
||||
- The images must be ordered as they were an image sequence. Additionally, each frame should be as close as posible to the previous and posterior.
|
||||
- For now DAISY features are used in order to compute the 2d points tracks and it only works for 3-4 images.
|
||||
- To see a working example for scene reconstruction, check the following tutorial: @ref tutorial_sfm_scene_reconstruction.
|
||||
*/
|
||||
CV_EXPORTS
|
||||
void
|
||||
reconstruct(const std::vector<String> images, OutputArray Rs, OutputArray Ts,
|
||||
InputOutputArray K, OutputArray points3d, bool is_projective = false);
|
||||
|
||||
#endif /* CV_DOXYGEN || CERES_FOUND */
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace cv */
|
||||
} /* namespace sfm */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_SFM_ROBUST_HPP__
|
||||
#define __OPENCV_SFM_ROBUST_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup robust
|
||||
//! @{
|
||||
|
||||
/** @brief Estimate robustly the fundamental matrix between two dataset of 2D point (image coords space).
|
||||
@param x1 Input 2xN Array of 2D points in view 1.
|
||||
@param x2 Input 2xN Array of 2D points in view 2.
|
||||
@param max_error maximum error (in pixels).
|
||||
@param F Output 3x3 fundamental matrix such that \f$x_2^T F x_1=0\f$.
|
||||
@param inliers Output 1xN vector that contains the indexes of the detected inliers.
|
||||
@param outliers_probability outliers probability (in ]0,1[).
|
||||
The number of iterations is controlled using the following equation:
|
||||
\f$k = \frac{log(1-p)}{log(1.0 - w^n )}\f$ where \f$k\f$, \f$w\f$ and \f$n\f$ are the number of
|
||||
iterations, the inliers ratio and minimun number of selected independent samples.
|
||||
The more this value is high, the less the function selects ramdom samples.
|
||||
|
||||
The fundamental solver relies on the 8 point solution. Returns the best error (in pixels), associated to the solution F.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
double
|
||||
fundamentalFromCorrespondences8PointRobust( InputArray x1,
|
||||
InputArray x2,
|
||||
double max_error,
|
||||
OutputArray F,
|
||||
OutputArray inliers,
|
||||
double outliers_probability = 1e-2 );
|
||||
|
||||
/** @brief Estimate robustly the fundamental matrix between two dataset of 2D point (image coords space).
|
||||
@param x1 Input 2xN Array of 2D points in view 1.
|
||||
@param x2 Input 2xN Array of 2D points in view 2.
|
||||
@param max_error maximum error (in pixels).
|
||||
@param F Output 3x3 fundamental matrix such that \f$x_2^T F x_1=0\f$.
|
||||
@param inliers Output 1xN vector that contains the indexes of the detected inliers.
|
||||
@param outliers_probability outliers probability (in ]0,1[).
|
||||
The number of iterations is controlled using the following equation:
|
||||
\f$k = \frac{log(1-p)}{log(1.0 - w^n )}\f$ where \f$k\f$, \f$w\f$ and \f$n\f$ are the number of
|
||||
iterations, the inliers ratio and minimun number of selected independent samples.
|
||||
The more this value is high, the less the function selects ramdom samples.
|
||||
|
||||
The fundamental solver relies on the 7 point solution. Returns the best error (in pixels), associated to the solution F.
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
double
|
||||
fundamentalFromCorrespondences7PointRobust( InputArray x1,
|
||||
InputArray x2,
|
||||
double max_error,
|
||||
OutputArray F,
|
||||
OutputArray inliers,
|
||||
double outliers_probability = 1e-2 );
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace cv */
|
||||
} /* namespace sfm */
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_SFM_SIMPLE_PIPELINE_HPP__
|
||||
#define __OPENCV_SFM_SIMPLE_PIPELINE_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup simple_pipeline
|
||||
//! @{
|
||||
|
||||
/** @brief Different camera models that libmv supports.
|
||||
*/
|
||||
enum {
|
||||
SFM_DISTORTION_MODEL_POLYNOMIAL = 0, // LIBMV_DISTORTION_MODEL_POLYNOMIAL
|
||||
SFM_DISTORTION_MODEL_DIVISION = 1, // LIBMV_DISTORTION_MODEL_DIVISION
|
||||
};
|
||||
|
||||
/** @brief Data structure describing the camera model and its parameters.
|
||||
@param _distortion_model Type of camera model.
|
||||
@param _focal_length_x focal length of the camera (in pixels).
|
||||
@param _focal_length_y focal length of the camera (in pixels).
|
||||
@param _principal_point_x principal point of the camera in the x direction (in pixels).
|
||||
@param _principal_point_y principal point of the camera in the y direction (in pixels).
|
||||
@param _polynomial_k1 radial distortion parameter.
|
||||
@param _polynomial_k2 radial distortion parameter.
|
||||
@param _polynomial_k3 radial distortion parameter.
|
||||
@param _polynomial_p1 radial distortion parameter.
|
||||
@param _polynomial_p2 radial distortion parameter.
|
||||
|
||||
Is assumed that modern cameras have their principal point in the image center.\n
|
||||
In case that the camera model was SFM_DISTORTION_MODEL_DIVISION, it's only needed to provide
|
||||
_polynomial_k1 and _polynomial_k2 which will be assigned as division distortion parameters.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE libmv_CameraIntrinsicsOptions
|
||||
{
|
||||
public:
|
||||
CV_WRAP
|
||||
libmv_CameraIntrinsicsOptions(const int _distortion_model=0,
|
||||
const double _focal_length_x=0,
|
||||
const double _focal_length_y=0,
|
||||
const double _principal_point_x=0,
|
||||
const double _principal_point_y=0,
|
||||
const double _polynomial_k1=0,
|
||||
const double _polynomial_k2=0,
|
||||
const double _polynomial_k3=0,
|
||||
const double _polynomial_p1=0,
|
||||
const double _polynomial_p2=0)
|
||||
: distortion_model(_distortion_model),
|
||||
image_width(2*_principal_point_x),
|
||||
image_height(2*_principal_point_y),
|
||||
focal_length_x(_focal_length_x),
|
||||
focal_length_y(_focal_length_y),
|
||||
principal_point_x(_principal_point_x),
|
||||
principal_point_y(_principal_point_y),
|
||||
polynomial_k1(_polynomial_k1),
|
||||
polynomial_k2(_polynomial_k2),
|
||||
polynomial_k3(_polynomial_k3),
|
||||
division_k1(_polynomial_p1),
|
||||
division_k2(_polynomial_p2)
|
||||
{
|
||||
if ( _distortion_model == SFM_DISTORTION_MODEL_DIVISION )
|
||||
{
|
||||
division_k1 = _polynomial_k1;
|
||||
division_k2 = _polynomial_k2;
|
||||
}
|
||||
}
|
||||
|
||||
// Common settings of all distortion models.
|
||||
CV_PROP_RW int distortion_model;
|
||||
CV_PROP_RW int image_width, image_height;
|
||||
CV_PROP_RW double focal_length_x;
|
||||
CV_PROP_RW double focal_length_y;
|
||||
CV_PROP_RW double principal_point_x, principal_point_y;
|
||||
|
||||
// Radial distortion model.
|
||||
CV_PROP_RW double polynomial_k1, polynomial_k2, polynomial_k3;
|
||||
CV_PROP_RW double polynomial_p1, polynomial_p2;
|
||||
|
||||
// Division distortion model.
|
||||
CV_PROP_RW double division_k1, division_k2;
|
||||
};
|
||||
|
||||
|
||||
/** @brief All internal camera parameters that libmv is able to refine.
|
||||
*/
|
||||
enum { SFM_REFINE_FOCAL_LENGTH = (1 << 0), // libmv::BUNDLE_FOCAL_LENGTH
|
||||
SFM_REFINE_PRINCIPAL_POINT = (1 << 1), // libmv::BUNDLE_PRINCIPAL_POINT
|
||||
SFM_REFINE_RADIAL_DISTORTION_K1 = (1 << 2), // libmv::BUNDLE_RADIAL_K1
|
||||
SFM_REFINE_RADIAL_DISTORTION_K2 = (1 << 4), // libmv::BUNDLE_RADIAL_K2
|
||||
};
|
||||
|
||||
|
||||
/** @brief Data structure describing the reconstruction options.
|
||||
@param _keyframe1 first keyframe used in order to initialize the reconstruction.
|
||||
@param _keyframe2 second keyframe used in order to initialize the reconstruction.
|
||||
@param _refine_intrinsics camera parameter or combination of parameters to refine.
|
||||
@param _select_keyframes allows to select automatically the initial keyframes. If 1 then autoselection is enabled. If 0 then is disabled.
|
||||
@param _verbosity_level verbosity logs level for Glog. If -1 then logs are disabled, otherwise the log level will be the input integer.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE libmv_ReconstructionOptions
|
||||
{
|
||||
public:
|
||||
CV_WRAP
|
||||
libmv_ReconstructionOptions(const int _keyframe1=1,
|
||||
const int _keyframe2=2,
|
||||
const int _refine_intrinsics=1,
|
||||
const int _select_keyframes=1,
|
||||
const int _verbosity_level=-1)
|
||||
: keyframe1(_keyframe1), keyframe2(_keyframe2),
|
||||
refine_intrinsics(_refine_intrinsics),
|
||||
select_keyframes(_select_keyframes),
|
||||
verbosity_level(_verbosity_level) {}
|
||||
|
||||
CV_PROP_RW int keyframe1, keyframe2;
|
||||
CV_PROP_RW int refine_intrinsics;
|
||||
CV_PROP_RW int select_keyframes;
|
||||
CV_PROP_RW int verbosity_level;
|
||||
};
|
||||
|
||||
|
||||
/** @brief base class BaseSFM declares a common API that would be used in a typical scene reconstruction scenario
|
||||
*/
|
||||
class CV_EXPORTS_W BaseSFM
|
||||
{
|
||||
public:
|
||||
virtual ~BaseSFM() {};
|
||||
|
||||
CV_WRAP
|
||||
virtual void run(InputArrayOfArrays points2d) = 0;
|
||||
|
||||
CV_WRAP
|
||||
virtual void run(InputArrayOfArrays points2d, InputOutputArray K, OutputArray Rs,
|
||||
OutputArray Ts, OutputArray points3d) = 0;
|
||||
|
||||
virtual void run(const std::vector<String> &images) = 0;
|
||||
virtual void run(const std::vector<String> &images, InputOutputArray K, OutputArray Rs,
|
||||
OutputArray Ts, OutputArray points3d) = 0;
|
||||
|
||||
CV_WRAP virtual double getError() const = 0;
|
||||
CV_WRAP virtual void getPoints(OutputArray points3d) = 0;
|
||||
CV_WRAP virtual cv::Mat getIntrinsics() const = 0;
|
||||
CV_WRAP virtual void getCameras(OutputArray Rs, OutputArray Ts) = 0;
|
||||
|
||||
CV_WRAP
|
||||
virtual void
|
||||
setReconstructionOptions(const libmv_ReconstructionOptions &libmv_reconstruction_options) = 0;
|
||||
|
||||
CV_WRAP
|
||||
virtual void
|
||||
setCameraIntrinsicOptions(const libmv_CameraIntrinsicsOptions &libmv_camera_intrinsics_options) = 0;
|
||||
};
|
||||
|
||||
/** @brief SFMLibmvEuclideanReconstruction class provides an interface with the Libmv Structure From Motion pipeline.
|
||||
*/
|
||||
class CV_EXPORTS_W SFMLibmvEuclideanReconstruction : public BaseSFM
|
||||
{
|
||||
public:
|
||||
/** @brief Calls the pipeline in order to perform Eclidean reconstruction.
|
||||
@param points2d Input vector of vectors of 2d points (the inner vector is per image).
|
||||
|
||||
@note
|
||||
- Tracks must be as precise as possible. It does not handle outliers and is very sensible to them.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual void run(InputArrayOfArrays points2d) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Calls the pipeline in order to perform Eclidean reconstruction.
|
||||
@param points2d Input vector of vectors of 2d points (the inner vector is per image).
|
||||
@param K Input/Output camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$. Input parameters used as initial guess.
|
||||
@param Rs Output vector of 3x3 rotations of the camera.
|
||||
@param Ts Output vector of 3x1 translations of the camera.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
|
||||
@note
|
||||
- Tracks must be as precise as possible. It does not handle outliers and is very sensible to them.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual void run(InputArrayOfArrays points2d, InputOutputArray K, OutputArray Rs,
|
||||
OutputArray Ts, OutputArray points3d) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Calls the pipeline in order to perform Eclidean reconstruction.
|
||||
@param images a vector of string with the images paths.
|
||||
|
||||
@note
|
||||
- The images must be ordered as they were an image sequence. Additionally, each frame should be as close as posible to the previous and posterior.
|
||||
- For now DAISY features are used in order to compute the 2d points tracks and it only works for 3-4 images.
|
||||
*/
|
||||
virtual void run(const std::vector<String> &images) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Calls the pipeline in order to perform Eclidean reconstruction.
|
||||
@param images a vector of string with the images paths.
|
||||
@param K Input/Output camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$. Input parameters used as initial guess.
|
||||
@param Rs Output vector of 3x3 rotations of the camera.
|
||||
@param Ts Output vector of 3x1 translations of the camera.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
|
||||
@note
|
||||
- The images must be ordered as they were an image sequence. Additionally, each frame should be as close as posible to the previous and posterior.
|
||||
- For now DAISY features are used in order to compute the 2d points tracks and it only works for 3-4 images.
|
||||
*/
|
||||
virtual void run(const std::vector<String> &images, InputOutputArray K, OutputArray Rs,
|
||||
OutputArray Ts, OutputArray points3d) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Returns the computed reprojection error.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual double getError() const CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Returns the estimated 3d points.
|
||||
@param points3d Output array with estimated 3d points.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual void getPoints(OutputArray points3d) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Returns the refined camera calibration matrix.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual cv::Mat getIntrinsics() const CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Returns the estimated camera extrinsic parameters.
|
||||
@param Rs Output vector of 3x3 rotations of the camera.
|
||||
@param Ts Output vector of 3x1 translations of the camera.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual void getCameras(OutputArray Rs, OutputArray Ts) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Setter method for reconstruction options.
|
||||
@param libmv_reconstruction_options struct with reconstruction options such as initial keyframes,
|
||||
automatic keyframe selection, parameters to refine and the verbosity level.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual void
|
||||
setReconstructionOptions(const libmv_ReconstructionOptions &libmv_reconstruction_options) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Setter method for camera intrinsic options.
|
||||
@param libmv_camera_intrinsics_options struct with camera intrinsic options such as camera model and
|
||||
the internal camera parameters.
|
||||
*/
|
||||
CV_WRAP
|
||||
virtual void
|
||||
setCameraIntrinsicOptions(const libmv_CameraIntrinsicsOptions &libmv_camera_intrinsics_options) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Creates an instance of the SFMLibmvEuclideanReconstruction class. Initializes Libmv. */
|
||||
static Ptr<SFMLibmvEuclideanReconstruction>
|
||||
create(const libmv_CameraIntrinsicsOptions &camera_instrinsic_options=libmv_CameraIntrinsicsOptions(),
|
||||
const libmv_ReconstructionOptions &reconstruction_options=libmv_ReconstructionOptions());
|
||||
};
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace cv */
|
||||
} /* namespace sfm */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Software License Agreement (BSD License)
|
||||
*
|
||||
* Copyright (c) 2009, Willow Garage, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_SFM_TRIANGULATION_HPP__
|
||||
#define __OPENCV_SFM_TRIANGULATION_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace sfm
|
||||
{
|
||||
|
||||
//! @addtogroup triangulation
|
||||
//! @{
|
||||
|
||||
/** @brief Reconstructs bunch of points by triangulation.
|
||||
@param points2d Input vector of vectors of 2d points (the inner vector is per image). Has to be 2 X N.
|
||||
@param projection_matrices Input vector with 3x4 projections matrices of each image.
|
||||
@param points3d Output array with computed 3d points. Is 3 x N.
|
||||
|
||||
Triangulates the 3d position of 2d correspondences between several images.
|
||||
Reference: Internally it uses DLT method @cite HartleyZ00 12.2 pag.312
|
||||
*/
|
||||
CV_EXPORTS_W
|
||||
void
|
||||
triangulatePoints(InputArrayOfArrays points2d, InputArrayOfArrays projection_matrices,
|
||||
OutputArray points3d);
|
||||
|
||||
//! @} sfm
|
||||
|
||||
} /* namespace sfm */
|
||||
} /* namespace cv */
|
||||
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
Reference in New Issue
Block a user