superres.hpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // Redistribution and use in source and binary forms, with or without modification,
  18. // are permitted provided that the following conditions are met:
  19. //
  20. // * Redistribution's of source code must retain the above copyright notice,
  21. // this list of conditions and the following disclaimer.
  22. //
  23. // * Redistribution's in binary form must reproduce the above copyright notice,
  24. // this list of conditions and the following disclaimer in the documentation
  25. // and/or other materials provided with the distribution.
  26. //
  27. // * The name of the copyright holders may not be used to endorse or promote products
  28. // derived from this software without specific prior written permission.
  29. //
  30. // This software is provided by the copyright holders and contributors "as is" and
  31. // any express or implied warranties, including, but not limited to, the implied
  32. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  33. // In no event shall the Intel Corporation or contributors be liable for any direct,
  34. // indirect, incidental, special, exemplary, or consequential damages
  35. // (including, but not limited to, procurement of substitute goods or services;
  36. // loss of use, data, or profits; or business interruption) however caused
  37. // and on any theory of liability, whether in contract, strict liability,
  38. // or tort (including negligence or otherwise) arising in any way out of
  39. // the use of this software, even if advised of the possibility of such damage.
  40. //
  41. //M*/
  42. #ifndef OPENCV_SUPERRES_HPP
  43. #define OPENCV_SUPERRES_HPP
  44. #include "opencv2/core.hpp"
  45. #include "opencv2/superres/optical_flow.hpp"
  46. /**
  47. @defgroup superres Super Resolution
  48. The Super Resolution module contains a set of functions and classes that can be used to solve the
  49. problem of resolution enhancement. There are a few methods implemented, most of them are described in
  50. the papers @cite Farsiu03 and @cite Mitzel09 .
  51. */
  52. namespace cv
  53. {
  54. namespace superres
  55. {
  56. //! @addtogroup superres
  57. //! @{
  58. class CV_EXPORTS FrameSource
  59. {
  60. public:
  61. virtual ~FrameSource();
  62. virtual void nextFrame(OutputArray frame) = 0;
  63. virtual void reset() = 0;
  64. };
  65. CV_EXPORTS Ptr<FrameSource> createFrameSource_Empty();
  66. CV_EXPORTS Ptr<FrameSource> createFrameSource_Video(const String& fileName);
  67. CV_EXPORTS Ptr<FrameSource> createFrameSource_Video_CUDA(const String& fileName);
  68. CV_EXPORTS Ptr<FrameSource> createFrameSource_Camera(int deviceId = 0);
  69. /** @brief Base class for Super Resolution algorithms.
  70. The class is only used to define the common interface for the whole family of Super Resolution
  71. algorithms.
  72. */
  73. class CV_EXPORTS SuperResolution : public cv::Algorithm, public FrameSource
  74. {
  75. public:
  76. /** @brief Set input frame source for Super Resolution algorithm.
  77. @param frameSource Input frame source
  78. */
  79. void setInput(const Ptr<FrameSource>& frameSource);
  80. /** @brief Process next frame from input and return output result.
  81. @param frame Output result
  82. */
  83. void nextFrame(OutputArray frame) CV_OVERRIDE;
  84. void reset() CV_OVERRIDE;
  85. /** @brief Clear all inner buffers.
  86. */
  87. virtual void collectGarbage();
  88. //! @brief Scale factor
  89. /** @see setScale */
  90. virtual int getScale() const = 0;
  91. /** @copybrief getScale @see getScale */
  92. virtual void setScale(int val) = 0;
  93. //! @brief Iterations count
  94. /** @see setIterations */
  95. virtual int getIterations() const = 0;
  96. /** @copybrief getIterations @see getIterations */
  97. virtual void setIterations(int val) = 0;
  98. //! @brief Asymptotic value of steepest descent method
  99. /** @see setTau */
  100. virtual double getTau() const = 0;
  101. /** @copybrief getTau @see getTau */
  102. virtual void setTau(double val) = 0;
  103. //! @brief Weight parameter to balance data term and smoothness term
  104. /** @see setLambda */
  105. virtual double getLambda() const = 0;
  106. /** @copybrief getLambda @see getLambda */
  107. virtual void setLambda(double val) = 0;
  108. //! @brief Parameter of spacial distribution in Bilateral-TV
  109. /** @see setAlpha */
  110. virtual double getAlpha() const = 0;
  111. /** @copybrief getAlpha @see getAlpha */
  112. virtual void setAlpha(double val) = 0;
  113. //! @brief Kernel size of Bilateral-TV filter
  114. /** @see setKernelSize */
  115. virtual int getKernelSize() const = 0;
  116. /** @copybrief getKernelSize @see getKernelSize */
  117. virtual void setKernelSize(int val) = 0;
  118. //! @brief Gaussian blur kernel size
  119. /** @see setBlurKernelSize */
  120. virtual int getBlurKernelSize() const = 0;
  121. /** @copybrief getBlurKernelSize @see getBlurKernelSize */
  122. virtual void setBlurKernelSize(int val) = 0;
  123. //! @brief Gaussian blur sigma
  124. /** @see setBlurSigma */
  125. virtual double getBlurSigma() const = 0;
  126. /** @copybrief getBlurSigma @see getBlurSigma */
  127. virtual void setBlurSigma(double val) = 0;
  128. //! @brief Radius of the temporal search area
  129. /** @see setTemporalAreaRadius */
  130. virtual int getTemporalAreaRadius() const = 0;
  131. /** @copybrief getTemporalAreaRadius @see getTemporalAreaRadius */
  132. virtual void setTemporalAreaRadius(int val) = 0;
  133. //! @brief Dense optical flow algorithm
  134. /** @see setOpticalFlow */
  135. virtual Ptr<cv::superres::DenseOpticalFlowExt> getOpticalFlow() const = 0;
  136. /** @copybrief getOpticalFlow @see getOpticalFlow */
  137. virtual void setOpticalFlow(const Ptr<cv::superres::DenseOpticalFlowExt> &val) = 0;
  138. protected:
  139. SuperResolution();
  140. virtual void initImpl(Ptr<FrameSource>& frameSource) = 0;
  141. virtual void processImpl(Ptr<FrameSource>& frameSource, OutputArray output) = 0;
  142. bool isUmat_;
  143. private:
  144. Ptr<FrameSource> frameSource_;
  145. bool firstCall_;
  146. };
  147. /** @brief Create Bilateral TV-L1 Super Resolution.
  148. This class implements Super Resolution algorithm described in the papers @cite Farsiu03 and
  149. @cite Mitzel09 .
  150. Here are important members of the class that control the algorithm, which you can set after
  151. constructing the class instance:
  152. - **int scale** Scale factor.
  153. - **int iterations** Iteration count.
  154. - **double tau** Asymptotic value of steepest descent method.
  155. - **double lambda** Weight parameter to balance data term and smoothness term.
  156. - **double alpha** Parameter of spacial distribution in Bilateral-TV.
  157. - **int btvKernelSize** Kernel size of Bilateral-TV filter.
  158. - **int blurKernelSize** Gaussian blur kernel size.
  159. - **double blurSigma** Gaussian blur sigma.
  160. - **int temporalAreaRadius** Radius of the temporal search area.
  161. - **Ptr\<DenseOpticalFlowExt\> opticalFlow** Dense optical flow algorithm.
  162. */
  163. CV_EXPORTS Ptr<SuperResolution> createSuperResolution_BTVL1();
  164. CV_EXPORTS Ptr<SuperResolution> createSuperResolution_BTVL1_CUDA();
  165. //! @} superres
  166. }
  167. }
  168. #endif // OPENCV_SUPERRES_HPP