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
+228
View File
@@ -0,0 +1,228 @@
/*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) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2013, 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_XSTEREO_HPP__
#define __OPENCV_XSTEREO_HPP__
#include "opencv2/core.hpp"
#include "opencv2/stereo.hpp"
#include "opencv2/xstereo/descriptor.hpp"
#include <opencv2/xstereo/quasi_dense_stereo.hpp>
/**
@defgroup xstereo Extra Stereo Correspondance Algorithms
*/
namespace cv
{
namespace stereo
{
//! @ingroup xstereo
//! @{
//!speckle removal algorithms. These algorithms have the purpose of removing small regions
enum {
CV_SPECKLE_REMOVAL_ALGORITHM, CV_SPECKLE_REMOVAL_AVG_ALGORITHM
};
//!subpixel interpolationm methods for disparities.
enum{
CV_QUADRATIC_INTERPOLATION, CV_SIMETRICV_INTERPOLATION
};
/** @brief Class for computing stereo correspondence using the block matching algorithm, introduced and
contributed to OpenCV by K. Konolige.
*/
class StereoBinaryBM : public StereoMatcher
{
public:
enum { PREFILTER_NORMALIZED_RESPONSE = 0,
PREFILTER_XSOBEL = 1
};
virtual int getPreFilterType() const = 0;
virtual void setPreFilterType(int preFilterType) = 0;
virtual int getPreFilterSize() const = 0;
virtual void setPreFilterSize(int preFilterSize) = 0;
virtual int getPreFilterCap() const = 0;
virtual void setPreFilterCap(int preFilterCap) = 0;
virtual int getTextureThreshold() const = 0;
virtual void setTextureThreshold(int textureThreshold) = 0;
virtual int getUniquenessRatio() const = 0;
virtual void setUniquenessRatio(int uniquenessRatio) = 0;
virtual int getSmallerBlockSize() const = 0;
virtual void setSmallerBlockSize(int blockSize) = 0;
virtual int getScalleFactor() const = 0 ;
virtual void setScalleFactor(int factor) = 0;
virtual int getSpekleRemovalTechnique() const = 0 ;
virtual void setSpekleRemovalTechnique(int factor) = 0;
virtual bool getUsePrefilter() const = 0 ;
virtual void setUsePrefilter(bool factor) = 0;
virtual int getBinaryKernelType() const = 0;
virtual void setBinaryKernelType(int value) = 0;
virtual int getAgregationWindowSize() const = 0;
virtual void setAgregationWindowSize(int value) = 0;
/** @brief Creates StereoBM object
@param numDisparities the disparity search range. For each pixel algorithm will find the best
disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
shifted by changing the minimum disparity.
@param blockSize the linear size of the blocks compared by the algorithm. The size should be odd
(as the block is centered at the current pixel). Larger block size implies smoother, though less
accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
chance for algorithm to find a wrong correspondence.
The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
a specific stereo pair.
*/
CV_EXPORTS static Ptr< cv::stereo::StereoBinaryBM > create(int numDisparities = 0, int blockSize = 9);
};
/** @brief The class implements the modified H. Hirschmuller algorithm @cite HH08 that differs from the original
one as follows:
- By default, the algorithm is single-pass, which means that you consider only 5 directions
instead of 8. Set mode=StereoSGBM::MODE_HH in createStereoSGBM to run the full variant of the
algorithm but beware that it may consume a lot of memory.
- The algorithm matches blocks, not individual pixels. Though, setting blockSize=1 reduces the
blocks to single pixels.
- Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi
sub-pixel metric from @cite BT98 is used. Though, the color images are supported as well.
- Some pre- and post- processing steps from K. Konolige algorithm StereoBM are included, for
example: pre-filtering (StereoBM::PREFILTER_XSOBEL type) and post-filtering (uniqueness
check, quadratic interpolation and speckle filtering).
@note
- (Python) An example illustrating the use of the StereoSGBM matching algorithm can be found
at opencv_source_code/samples/python2/stereo_match.py
*/
class StereoBinarySGBM : public StereoMatcher
{
public:
enum
{
MODE_SGBM = 0,
MODE_HH = 1
};
virtual int getPreFilterCap() const = 0;
virtual void setPreFilterCap(int preFilterCap) = 0;
virtual int getUniquenessRatio() const = 0;
virtual void setUniquenessRatio(int uniquenessRatio) = 0;
virtual int getP1() const = 0;
virtual void setP1(int P1) = 0;
virtual int getP2() const = 0;
virtual void setP2(int P2) = 0;
virtual int getMode() const = 0;
virtual void setMode(int mode) = 0;
virtual int getSpekleRemovalTechnique() const = 0 ;
virtual void setSpekleRemovalTechnique(int factor) = 0;
virtual int getBinaryKernelType() const = 0;
virtual void setBinaryKernelType(int value) = 0;
virtual int getSubPixelInterpolationMethod() const = 0;
virtual void setSubPixelInterpolationMethod(int value) = 0;
/** @brief Creates StereoSGBM object
@param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
@param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
zero. In the current implementation, this parameter must be divisible by 16.
@param blockSize Matched block size. It must be an odd number \>=1 . Normally, it should be
somewhere in the 3..11 range.
@param P1 The first parameter controlling the disparity smoothness.This parameter is used for the case of slanted surfaces (not fronto parallel).
@param P2 The second parameter controlling the disparity smoothness.This parameter is used for "solving" the depth discontinuities problem.
The larger the values are, the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
pixels. The algorithm requires P2 \> P1 . See stereo_match.cpp sample where some reasonably good
P1 and P2 values are shown (like 8\*number_of_image_channels\*SADWindowSize\*SADWindowSize and
32\*number_of_image_channels\*SADWindowSize\*SADWindowSize , respectively).
@param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
disparity check. Set it to a non-positive value to disable the check.
@param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
The result values are passed to the Birchfield-Tomasi pixel cost function.
@param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function
value should "win" the second best value to consider the found match correct. Normally, a value
within the 5-15 range is good enough.
@param speckleWindowSize Maximum size of smooth disparity regions to consider their noise speckles
and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
50-200 range.
@param speckleRange Maximum disparity variation within each connected component. If you do speckle
filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
Normally, 1 or 2 is good enough.
@param mode Set it to StereoSGBM::MODE_HH to run the full-scale two-pass dynamic programming
algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
huge for HD-size pictures. By default, it is set to false .
The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
to a custom value.
*/
CV_EXPORTS static Ptr<StereoBinarySGBM> create(int minDisparity, int numDisparities, int blockSize,
int P1 = 100, int P2 = 1000, int disp12MaxDiff = 1,
int preFilterCap = 0, int uniquenessRatio = 5,
int speckleWindowSize = 400, int speckleRange = 200,
int mode = StereoBinarySGBM::MODE_SGBM);
};
//! @}
}//stereo
} // cv
#endif
@@ -0,0 +1,44 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#ifndef _OPENCV_STEREO_DESCRIPTOR_HPP_
#define _OPENCV_STEREO_DESCRIPTOR_HPP_
namespace cv { namespace stereo {
// FIXIT deprecate and remove CV_ prefix
/// types of supported kernels
enum {
CV_DENSE_CENSUS, CV_SPARSE_CENSUS,
CV_CS_CENSUS, CV_MODIFIED_CS_CENSUS, CV_MODIFIED_CENSUS_TRANSFORM,
CV_MEAN_VARIATION, CV_STAR_KERNEL
};
/**
Two variations of census applied on input images
Implementation of a census transform which is taking into account just the some pixels from the census kernel thus allowing for larger block sizes
**/
CV_EXPORTS void censusTransform(const Mat &image1, const Mat &image2, int kernelSize, Mat &dist1, Mat &dist2, const int type);
/// single image census transform
CV_EXPORTS void censusTransform(const Mat &image1, int kernelSize, Mat &dist1, const int type);
/**
STANDARD_MCT - Modified census which is memorizing for each pixel 2 bits and includes a tolerance to the pixel comparison
MCT_MEAN_VARIATION - Implementation of a modified census transform which is also taking into account the variation to the mean of the window not just the center pixel
**/
CV_EXPORTS void modifiedCensusTransform(const Mat &img1, const Mat &img2, int kernelSize, Mat &dist1, Mat &dist2, const int type, int t = 0, const Mat &integralImage1 = Mat(), const Mat &integralImage2 = Mat());
///single version of modified census transform descriptor
CV_EXPORTS void modifiedCensusTransform(const Mat &img1, int kernelSize, Mat &dist, const int type, int t = 0, const Mat &integralImage = Mat());
/**The classical center symetric census
A modified version of cs census which is comparing a pixel with its correspondent after the center
**/
CV_EXPORTS void symetricCensusTransform(const Mat &img1, const Mat &img2, int kernelSize, Mat &dist1, Mat &dist2, const int type);
///single version of census transform
CV_EXPORTS void symetricCensusTransform(const Mat &img1, int kernelSize, Mat &dist1, const int type);
///in a 9x9 kernel only certain positions are choosen
CV_EXPORTS void starCensusTransform(const Mat &img1, const Mat &img2, int kernelSize, Mat &dist1, Mat &dist2);
///single image version of star kernel
CV_EXPORTS void starCensusTransform(const Mat &img1, int kernelSize, Mat &dist);
}} // namespace
#endif
@@ -0,0 +1,197 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//authors: Danail Stoyanov, Evangelos Mazomenos, Dimitrios Psychogyios
//__OPENCV_QUASI_DENSE_STEREO_H__
#ifndef __OPENCV_QUASI_DENSE_STEREO_H__
#define __OPENCV_QUASI_DENSE_STEREO_H__
#include <opencv2/core.hpp>
namespace cv
{
namespace stereo
{
/** \addtogroup xstereo
* @{
*/
// A basic match structure
struct CV_EXPORTS_W_SIMPLE MatchQuasiDense
{
CV_PROP_RW cv::Point2i p0;
CV_PROP_RW cv::Point2i p1;
CV_PROP_RW float corr;
CV_WRAP MatchQuasiDense() { corr = 0; }
CV_WRAP_AS(apply) bool operator < (const MatchQuasiDense & rhs) const//fixme may be used uninitialized in this function
{
return this->corr < rhs.corr;
}
};
struct CV_EXPORTS_W_SIMPLE PropagationParameters
{
CV_PROP_RW int corrWinSizeX; // similarity window
CV_PROP_RW int corrWinSizeY;
CV_PROP_RW int borderX; // border to ignore
CV_PROP_RW int borderY;
//matching
CV_PROP_RW float correlationThreshold; // correlation threshold
CV_PROP_RW float textrureThreshold; // texture threshold
CV_PROP_RW int neighborhoodSize; // neighborhood size
CV_PROP_RW int disparityGradient; // disparity gradient threshold
// Parameters for LK flow algorithm
CV_PROP_RW int lkTemplateSize;
CV_PROP_RW int lkPyrLvl;
CV_PROP_RW int lkTermParam1;
CV_PROP_RW float lkTermParam2;
// Parameters for GFT algorithm.
CV_PROP_RW float gftQualityThres;
CV_PROP_RW int gftMinSeperationDist;
CV_PROP_RW int gftMaxNumFeatures;
};
/**
* @brief Class containing the methods needed for Quasi Dense Stereo computation.
*
* This module contains the code to perform quasi dense stereo matching.
* The method initially starts with a sparse 3D reconstruction based on feature matching across a
* stereo image pair and subsequently propagates the structure into neighboring image regions.
* To obtain initial seed correspondences, the algorithm locates Shi and Tomashi features in the
* left image of the stereo pair and then tracks them using pyramidal Lucas-Kanade in the right image.
* To densify the sparse correspondences, the algorithm computes the zero-mean normalized
* cross-correlation (ZNCC) in small patches around every seed pair and uses it as a quality metric
* for each match. In this code, we introduce a custom structure to store the location and ZNCC value
* of correspondences called "Match". Seed Matches are stored in a priority queue sorted according to
* their ZNCC value, allowing for the best quality Match to be readily available. The algorithm pops
* Matches and uses them to extract new matches around them. This is done by considering a small
* neighboring area around each Seed and retrieving correspondences above a certain texture threshold
* that are not previously computed. New matches are stored in the seed priority queue and used as seeds.
* The propagation process ends when no additional matches can be retrieved.
*
*
* @sa This code represents the work presented in @cite Stoyanov2010.
* If this code is useful for your work please cite @cite Stoyanov2010.
*
* Also the original growing scheme idea is described in @cite Lhuillier2000
*
*/
class CV_EXPORTS_W QuasiDenseStereo
{
public:
/**
* @brief destructor
* Method to free all the memory allocated by matrices and vectors in this class.
*/
CV_WRAP virtual ~QuasiDenseStereo() = 0;
/**
* @brief Load a file containing the configuration parameters of the class.
* @param[in] filepath The location of the .YAML file containing the configuration parameters.
* @note default value is an empty string in which case the default parameters will be loaded.
* @retval 1: If the path is not empty and the program loaded the parameters successfully.
* @retval 0: If the path is empty and the program loaded default parameters.
* @retval -1: If the file location is not valid or the program could not open the file and
* loaded default parameters from defaults.hpp.
* @note The method is automatically called in the constructor and configures the class.
* @note Loading different parameters will have an effect on the output. This is useful for tuning
* in case of video processing.
* @sa loadParameters
*/
CV_WRAP virtual int loadParameters(cv::String filepath) = 0;
/**
* @brief Save a file containing all the configuration parameters the class is currently set to.
* @param[in] filepath The location to store the parameters file.
* @note Calling this method with no arguments will result in storing class parameters to a file
* names "qds_parameters.yaml" in the root project folder.
* @note This method can be used to generate a template file for tuning the class.
* @sa loadParameters
*/
CV_WRAP virtual int saveParameters(cv::String filepath) = 0;
/**
* @brief Get The sparse corresponding points.
* @param[out] sMatches A vector containing all sparse correspondences.
* @note The method clears the sMatches vector.
* @note The returned Match elements inside the sMatches vector, do not use corr member.
*/
CV_WRAP virtual void getSparseMatches(CV_OUT std::vector<MatchQuasiDense> &sMatches) = 0;
/**
* @brief Get The dense corresponding points.
* @param[out] denseMatches A vector containing all dense matches.
* @note The method clears the denseMatches vector.
* @note The returned Match elements inside the sMatches vector, do not use corr member.
*/
CV_WRAP virtual void getDenseMatches(CV_OUT std::vector<MatchQuasiDense> &denseMatches) = 0;
/**
* @brief Main process of the algorithm. This method computes the sparse seeds and then densifies them.
*
* Initially input images are converted to gray-scale and then the sparseMatching method
* is called to obtain the sparse stereo. Finally quasiDenseMatching is called to densify the corresponding
* points.
* @param[in] imgLeft The left Channel of a stereo image pair.
* @param[in] imgRight The right Channel of a stereo image pair.
* @note If input images are in color, the method assumes that are BGR and converts them to grayscale.
* @sa sparseMatching
* @sa quasiDenseMatching
*/
CV_WRAP virtual void process(const cv::Mat &imgLeft ,const cv::Mat &imgRight) = 0;
/**
* @brief Specify pixel coordinates in the left image and get its corresponding location in the right image.
* @param[in] x The x pixel coordinate in the left image channel.
* @param[in] y The y pixel coordinate in the left image channel.
* @retval cv::Point(x, y) The location of the corresponding pixel in the right image.
* @retval cv::Point(0, 0) (NO_MATCH) if no match is found in the right image for the specified pixel location in the left image.
* @note This method should be always called after process, otherwise the matches will not be correct.
*/
CV_WRAP virtual cv::Point2f getMatch(const int x, const int y) = 0;
/**
* @brief Compute and return the disparity map based on the correspondences found in the "process" method.
* @note Default level is 50
* @return cv::Mat containing a the disparity image in grayscale.
* @sa computeDisparity
* @sa quantizeDisparity
*/
CV_WRAP virtual cv::Mat getDisparity() = 0;
CV_WRAP static cv::Ptr<QuasiDenseStereo> create(cv::Size monoImgSize, cv::String paramFilepath = cv::String());
CV_PROP_RW PropagationParameters Param;
};
/** @}*/
} //namespace cv
} //namespace stereo
#endif // __OPENCV_QUASI_DENSE_STEREO_H__