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