sparse_match_interpolator.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * By downloading, copying, installing or using the software you agree to this license.
  3. * If you do not agree to this license, do not download, install,
  4. * copy or use the software.
  5. *
  6. *
  7. * License Agreement
  8. * For Open Source Computer Vision Library
  9. * (3 - clause BSD License)
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met :
  13. *
  14. * * Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. *
  17. * * Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and / or other materials provided with the distribution.
  20. *
  21. * * Neither the names of the copyright holders nor the names of the contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * This software is provided by the copyright holders and contributors "as is" and
  26. * any express or implied warranties, including, but not limited to, the implied
  27. * warranties of merchantability and fitness for a particular purpose are disclaimed.
  28. * In no event shall copyright holders or contributors be liable for any direct,
  29. * indirect, incidental, special, exemplary, or consequential damages
  30. * (including, but not limited to, procurement of substitute goods or services;
  31. * loss of use, data, or profits; or business interruption) however caused
  32. * and on any theory of liability, whether in contract, strict liability,
  33. * or tort(including negligence or otherwise) arising in any way out of
  34. * the use of this software, even if advised of the possibility of such damage.
  35. */
  36. #ifndef __OPENCV_SPARSEMATCHINTERPOLATOR_HPP__
  37. #define __OPENCV_SPARSEMATCHINTERPOLATOR_HPP__
  38. #ifdef __cplusplus
  39. #include <opencv2/core.hpp>
  40. namespace cv {
  41. namespace ximgproc {
  42. //! @addtogroup ximgproc_filters
  43. //! @{
  44. /** @brief Main interface for all filters, that take sparse matches as an
  45. input and produce a dense per-pixel matching (optical flow) as an output.
  46. */
  47. class CV_EXPORTS_W SparseMatchInterpolator : public Algorithm
  48. {
  49. public:
  50. /** @brief Interpolate input sparse matches.
  51. @param from_image first of the two matched images, 8-bit single-channel or three-channel.
  52. @param from_points points of the from_image for which there are correspondences in the
  53. to_image (Point2f vector, size shouldn't exceed 32767)
  54. @param to_image second of the two matched images, 8-bit single-channel or three-channel.
  55. @param to_points points in the to_image corresponding to from_points
  56. (Point2f vector, size shouldn't exceed 32767)
  57. @param dense_flow output dense matching (two-channel CV_32F image)
  58. */
  59. CV_WRAP virtual void interpolate(InputArray from_image, InputArray from_points,
  60. InputArray to_image , InputArray to_points,
  61. OutputArray dense_flow) = 0;
  62. };
  63. /** @brief Sparse match interpolation algorithm based on modified locally-weighted affine
  64. estimator from @cite Revaud2015 and Fast Global Smoother as post-processing filter.
  65. */
  66. class CV_EXPORTS_W EdgeAwareInterpolator : public SparseMatchInterpolator
  67. {
  68. public:
  69. /** @brief K is a number of nearest-neighbor matches considered, when fitting a locally affine
  70. model. Usually it should be around 128. However, lower values would make the interpolation
  71. noticeably faster.
  72. */
  73. CV_WRAP virtual void setK(int _k) = 0;
  74. /** @see setK */
  75. CV_WRAP virtual int getK() = 0;
  76. /** @brief Sigma is a parameter defining how fast the weights decrease in the locally-weighted affine
  77. fitting. Higher values can help preserve fine details, lower values can help to get rid of noise in the
  78. output flow.
  79. */
  80. CV_WRAP virtual void setSigma(float _sigma) = 0;
  81. /** @see setSigma */
  82. CV_WRAP virtual float getSigma() = 0;
  83. /** @brief Lambda is a parameter defining the weight of the edge-aware term in geodesic distance,
  84. should be in the range of 0 to 1000.
  85. */
  86. CV_WRAP virtual void setLambda(float _lambda) = 0;
  87. /** @see setLambda */
  88. CV_WRAP virtual float getLambda() = 0;
  89. /** @brief Sets whether the fastGlobalSmootherFilter() post-processing is employed. It is turned on by
  90. default.
  91. */
  92. CV_WRAP virtual void setUsePostProcessing(bool _use_post_proc) = 0;
  93. /** @see setUsePostProcessing */
  94. CV_WRAP virtual bool getUsePostProcessing() = 0;
  95. /** @brief Sets the respective fastGlobalSmootherFilter() parameter.
  96. */
  97. CV_WRAP virtual void setFGSLambda(float _lambda) = 0;
  98. /** @see setFGSLambda */
  99. CV_WRAP virtual float getFGSLambda() = 0;
  100. /** @see setFGSLambda */
  101. CV_WRAP virtual void setFGSSigma(float _sigma) = 0;
  102. /** @see setFGSLambda */
  103. CV_WRAP virtual float getFGSSigma() = 0;
  104. };
  105. /** @brief Factory method that creates an instance of the
  106. EdgeAwareInterpolator.
  107. */
  108. CV_EXPORTS_W
  109. Ptr<EdgeAwareInterpolator> createEdgeAwareInterpolator();
  110. //! @}
  111. }
  112. }
  113. #endif
  114. #endif