From 9498f8208515789cc37db7cb5684cd2dfce88c93 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 6 May 2013 13:36:52 +0400 Subject: [PATCH] updated documentation --- modules/gpuimgproc/doc/color.rst | 68 ++++- modules/gpuimgproc/doc/feature_detection.rst | 117 +++++--- modules/gpuimgproc/doc/histogram.rst | 138 ++++++--- modules/gpuimgproc/doc/hough.rst | 280 ++++++++++++++++--- modules/gpuimgproc/doc/imgproc.rst | 166 ++++++----- 5 files changed, 577 insertions(+), 192 deletions(-) diff --git a/modules/gpuimgproc/doc/color.rst b/modules/gpuimgproc/doc/color.rst index 70de236ea5..5cdcd5749b 100644 --- a/modules/gpuimgproc/doc/color.rst +++ b/modules/gpuimgproc/doc/color.rst @@ -6,16 +6,16 @@ Color space processing gpu::cvtColor ------------------ +------------- Converts an image from one color space to another. -.. ocv:function:: void gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::cvtColor(InputArray src, OutputArray dst, int code, int dcn = 0, Stream& stream = Stream::Null()) :param src: Source image with ``CV_8U`` , ``CV_16U`` , or ``CV_32F`` depth and 1, 3, or 4 channels. - :param dst: Destination image with the same size and depth as ``src`` . + :param dst: Destination image. - :param code: Color space conversion code. For details, see :ocv:func:`cvtColor` . Conversion to/from Luv and Bayer color spaces is not supported. + :param code: Color space conversion code. For details, see :ocv:func:`cvtColor` . :param dcn: Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from ``src`` and the ``code`` . @@ -27,11 +27,45 @@ Converts an image from one color space to another. +gpu::demosaicing +---------------- +Converts an image from Bayer pattern to RGB or grayscale. + +.. ocv:function:: void gpu::demosaicing(InputArray src, OutputArray dst, int code, int dcn = -1, Stream& stream = Stream::Null()) + + :param src: Source image (8-bit or 16-bit single channel). + + :param dst: Destination image. + + :param code: Color space conversion code (see the description below). + + :param dcn: Number of channels in the destination image. If the parameter is 0, the number of the channels is derived automatically from ``src`` and the ``code`` . + + :param stream: Stream for the asynchronous version. + +The function can do the following transformations: + +* Demosaicing using bilinear interpolation + + * ``COLOR_BayerBG2GRAY`` , ``COLOR_BayerGB2GRAY`` , ``COLOR_BayerRG2GRAY`` , ``COLOR_BayerGR2GRAY`` + + * ``COLOR_BayerBG2BGR`` , ``COLOR_BayerGB2BGR`` , ``COLOR_BayerRG2BGR`` , ``COLOR_BayerGR2BGR`` + +* Demosaicing using Malvar-He-Cutler algorithm ([MHT2011]_) + + * ``COLOR_BayerBG2GRAY_MHT`` , ``COLOR_BayerGB2GRAY_MHT`` , ``COLOR_BayerRG2GRAY_MHT`` , ``COLOR_BayerGR2GRAY_MHT`` + + * ``COLOR_BayerBG2BGR_MHT`` , ``COLOR_BayerGB2BGR_MHT`` , ``COLOR_BayerRG2BGR_MHT`` , ``COLOR_BayerGR2BGR_MHT`` + +.. seealso:: :ocv:func:`cvtColor` + + + gpu::swapChannels ----------------- Exchanges the color channels of an image in-place. -.. ocv:function:: void gpu::swapChannels(GpuMat& image, const int dstOrder[4], Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::swapChannels(InputOutputArray image, const int dstOrder[4], Stream& stream = Stream::Null()) :param image: Source image. Supports only ``CV_8UC4`` type. @@ -43,11 +77,27 @@ The methods support arbitrary permutations of the original channels, including r +gpu::gammaCorrection +-------------------- +Routines for correcting image color gamma. + +.. ocv:function:: void gpu::gammaCorrection(InputArray src, OutputArray dst, bool forward = true, Stream& stream = Stream::Null()) + + :param src: Source image (3- or 4-channel 8 bit). + + :param dst: Destination image. + + :param forward: ``true`` for forward gamma correction or ``false`` for inverse gamma correction. + + :param stream: Stream for the asynchronous version. + + + gpu::alphaComp -------------------- +-------------- Composites two images using alpha opacity values contained in each image. -.. ocv:function:: void gpu::alphaComp(const GpuMat& img1, const GpuMat& img2, GpuMat& dst, int alpha_op, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::alphaComp(InputArray img1, InputArray img2, OutputArray dst, int alpha_op, Stream& stream = Stream::Null()) :param img1: First image. Supports ``CV_8UC4`` , ``CV_16UC4`` , ``CV_32SC4`` and ``CV_32FC4`` types. @@ -72,3 +122,7 @@ Composites two images using alpha opacity values contained in each image. * **ALPHA_PREMUL** :param stream: Stream for the asynchronous version. + + + +.. [MHT2011] Pascal Getreuer, Malvar-He-Cutler Linear Image Demosaicking, Image Processing On Line, 2011 diff --git a/modules/gpuimgproc/doc/feature_detection.rst b/modules/gpuimgproc/doc/feature_detection.rst index c38b8c2007..fc5e592cf8 100644 --- a/modules/gpuimgproc/doc/feature_detection.rst +++ b/modules/gpuimgproc/doc/feature_detection.rst @@ -5,15 +5,41 @@ Feature Detection -gpu::cornerHarris ---------------------- -Computes the Harris cornerness criteria at each image pixel. +gpu::CornernessCriteria +----------------------- +.. ocv:class:: gpu::CornernessCriteria : public Algorithm -.. ocv:function:: void gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101) +Base class for Cornerness Criteria computation. :: - :param src: Source image. Only ``CV_8UC1`` and ``CV_32FC1`` images are supported for now. + class CV_EXPORTS CornernessCriteria : public Algorithm + { + public: + virtual void compute(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) = 0; + }; - :param dst: Destination image containing cornerness values. It has the same size as ``src`` and ``CV_32FC1`` type. + + +gpu::CornernessCriteria::compute +-------------------------------- +Computes the cornerness criteria at each image pixel. + +.. ocv:function:: void gpu::CornernessCriteria::compute(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) + + :param src: Source image. + + :param dst: Destination image containing cornerness values. It will have the same size as ``src`` and ``CV_32FC1`` type. + + :param stream: Stream for the asynchronous version. + + + +gpu::createHarrisCorner +----------------------- +Creates implementation for Harris cornerness criteria. + +.. ocv:function:: Ptr gpu::createHarrisCorner(int srcType, int blockSize, int ksize, double k, int borderType = BORDER_REFLECT101) + + :param srcType: Input source type. Only ``CV_8UC1`` and ``CV_32FC1`` are supported for now. :param blockSize: Neighborhood size. @@ -27,55 +53,70 @@ Computes the Harris cornerness criteria at each image pixel. -gpu::cornerMinEigenVal --------------------------- -Computes the minimum eigen value of a 2x2 derivative covariation matrix at each pixel (the cornerness criteria). +gpu::createMinEigenValCorner +---------------------------- +Creates implementation for the minimum eigen value of a 2x2 derivative covariation matrix (the cornerness criteria). -.. ocv:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101) +.. ocv:function:: Ptr gpu::createMinEigenValCorner(int srcType, int blockSize, int ksize, int borderType = BORDER_REFLECT101) -.. ocv:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, int borderType=BORDER_REFLECT101) - -.. ocv:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, int borderType=BORDER_REFLECT101, Stream& stream = Stream::Null()) - - :param src: Source image. Only ``CV_8UC1`` and ``CV_32FC1`` images are supported for now. - - :param dst: Destination image containing cornerness values. The size is the same. The type is ``CV_32FC1`` . + :param srcType: Input source type. Only ``CV_8UC1`` and ``CV_32FC1`` are supported for now. :param blockSize: Neighborhood size. :param ksize: Aperture parameter for the Sobel operator. - :param borderType: Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now. + :param borderType: Pixel extrapolation method. Only ``BORDER_REFLECT101`` and ``BORDER_REPLICATE`` are supported for now. .. seealso:: :ocv:func:`cornerMinEigenVal` -gpu::GoodFeaturesToTrackDetector_GPU ------------------------------------- -.. ocv:class:: gpu::GoodFeaturesToTrackDetector_GPU +gpu::CornersDetector +-------------------- +.. ocv:class:: gpu::CornersDetector : public Algorithm -Class used for strong corners detection on an image. :: +Base class for Corners Detector. :: - class GoodFeaturesToTrackDetector_GPU + class CV_EXPORTS CornersDetector : public Algorithm { public: - explicit GoodFeaturesToTrackDetector_GPU(int maxCorners_ = 1000, double qualityLevel_ = 0.01, double minDistance_ = 0.0, - int blockSize_ = 3, bool useHarrisDetector_ = false, double harrisK_ = 0.04); - - void operator ()(const GpuMat& image, GpuMat& corners, const GpuMat& mask = GpuMat()); - - int maxCorners; - double qualityLevel; - double minDistance; - - int blockSize; - bool useHarrisDetector; - double harrisK; - - void releaseMemory(); + virtual void detect(InputArray image, OutputArray corners, InputArray mask = noArray()) = 0; }; -The class finds the most prominent corners in the image. + + +gpu::CornersDetector::detect +---------------------------- +Determines strong corners on an image. + +.. ocv:function:: void gpu::CornersDetector::detect(InputArray image, OutputArray corners, InputArray mask = noArray()) + + :param image: Input 8-bit or floating-point 32-bit, single-channel image. + + :param corners: Output vector of detected corners (1-row matrix with CV_32FC2 type with corners positions). + + :param mask: Optional region of interest. If the image is not empty (it needs to have the type ``CV_8UC1`` and the same size as ``image`` ), it specifies the region in which the corners are detected. + + + +gpu::createGoodFeaturesToTrackDetector +-------------------------------------- +Creates implementation for :ocv:class:`gpu::CornersDetector` . + +.. ocv:function:: Ptr gpu::createGoodFeaturesToTrackDetector(int srcType, int maxCorners = 1000, double qualityLevel = 0.01, double minDistance = 0.0, int blockSize = 3, bool useHarrisDetector = false, double harrisK = 0.04) + + :param srcType: Input source type. Only ``CV_8UC1`` and ``CV_32FC1`` are supported for now. + + :param maxCorners: Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. + + :param qualityLevel: Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see :ocv:func:`cornerMinEigenVal` ) or the Harris function response (see :ocv:func:`cornerHarris` ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the ``qualityLevel=0.01`` , then all the corners with the quality measure less than 15 are rejected. + + :param minDistance: Minimum possible Euclidean distance between the returned corners. + + :param blockSize: Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See :ocv:func:`cornerEigenValsAndVecs` . + + :param useHarrisDetector: Parameter indicating whether to use a Harris detector (see :ocv:func:`cornerHarris`) or :ocv:func:`cornerMinEigenVal`. + + :param harrisK: Free parameter of the Harris detector. .. seealso:: :ocv:func:`goodFeaturesToTrack` diff --git a/modules/gpuimgproc/doc/histogram.rst b/modules/gpuimgproc/doc/histogram.rst index 7b29de6ba9..dfdf322864 100644 --- a/modules/gpuimgproc/doc/histogram.rst +++ b/modules/gpuimgproc/doc/histogram.rst @@ -5,11 +5,89 @@ Histogram Calculation +gpu::calcHist +------------- +Calculates histogram for one channel 8-bit image. + +.. ocv:function:: void gpu::calcHist(InputArray src, OutputArray hist, Stream& stream = Stream::Null()) + + :param src: Source image with ``CV_8UC1`` type. + + :param hist: Destination histogram with one row, 256 columns, and the ``CV_32SC1`` type. + + :param stream: Stream for the asynchronous version. + + + +gpu::equalizeHist +----------------- +Equalizes the histogram of a grayscale image. + +.. ocv:function:: void gpu::equalizeHist(InputArray src, OutputArray dst, Stream& stream = Stream::Null()) + +.. ocv:function:: void gpu::equalizeHist(InputArray src, OutputArray dst, InputOutputArray buf, Stream& stream = Stream::Null()) + + :param src: Source image with ``CV_8UC1`` type. + + :param dst: Destination image. + + :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). + + :param stream: Stream for the asynchronous version. + +.. seealso:: :ocv:func:`equalizeHist` + + + +gpu::CLAHE +---------- +.. ocv:class:: gpu::CLAHE : public cv::CLAHE + +Base class for Contrast Limited Adaptive Histogram Equalization. :: + + class CV_EXPORTS CLAHE : public cv::CLAHE + { + public: + using cv::CLAHE::apply; + virtual void apply(InputArray src, OutputArray dst, Stream& stream) = 0; + }; + + + +gpu::CLAHE::apply +----------------- +Equalizes the histogram of a grayscale image using Contrast Limited Adaptive Histogram Equalization. + +.. ocv:function:: void gpu::CLAHE::apply(InputArray src, OutputArray dst) + +.. ocv:function:: void gpu::CLAHE::apply(InputArray src, OutputArray dst, Stream& stream) + + :param src: Source image with ``CV_8UC1`` type. + + :param dst: Destination image. + + :param stream: Stream for the asynchronous version. + + + +gpu::createCLAHE +---------------- +Creates implementation for :ocv:class:`gpu::CLAHE` . + +.. ocv:function:: Ptr createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8)) + + :param clipLimit: Threshold for contrast limiting. + + :param tileGridSize: Size of grid for histogram equalization. Input image will be divided into equally sized rectangular tiles. ``tileGridSize`` defines the number of tiles in row and column. + + + + gpu::evenLevels -------------------- +--------------- Computes levels with even distribution. -.. ocv:function:: void gpu::evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel) +.. ocv:function:: void gpu::evenLevels(OutputArray levels, int nLevels, int lowerLevel, int upperLevel) :param levels: Destination array. ``levels`` has 1 row, ``nLevels`` columns, and the ``CV_32SC1`` type. @@ -22,16 +100,16 @@ Computes levels with even distribution. gpu::histEven ------------------ +------------- Calculates a histogram with evenly distributed bins. -.. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::histEven(InputArray src, OutputArray hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null()) -.. ocv:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, GpuMat& buf, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::histEven(InputArray src, OutputArray hist, InputOutputArray buf, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null()) -.. ocv:function:: void gpu::histEven( const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::histEven(InputArray src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null()) -.. ocv:function:: void gpu::histEven( const GpuMat& src, GpuMat hist[4], GpuMat& buf, int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::histEven(InputArray src, GpuMat hist[4], InputOutputArray buf, int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null()) :param src: Source image. ``CV_8U``, ``CV_16U``, or ``CV_16S`` depth and 1 or 4 channels are supported. For a four-channel image, all channels are processed separately. @@ -50,12 +128,16 @@ Calculates a histogram with evenly distributed bins. gpu::histRange ------------------- +-------------- Calculates a histogram with bins determined by the ``levels`` array. -.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::histRange(InputArray src, OutputArray hist, InputArray levels, Stream& stream = Stream::Null()) -.. ocv:function:: void gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, GpuMat& buf, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::histRange(InputArray src, OutputArray hist, InputArray levels, InputOutputArray buf, Stream& stream = Stream::Null()) + +.. ocv:function:: void gpu::histRange(InputArray src, GpuMat hist[4], const GpuMat levels[4], Stream& stream = Stream::Null()) + +.. ocv:function:: void gpu::histRange(InputArray src, GpuMat hist[4], const GpuMat levels[4], InputOutputArray buf, Stream& stream = Stream::Null()) :param src: Source image. ``CV_8U`` , ``CV_16U`` , or ``CV_16S`` depth and 1 or 4 channels are supported. For a four-channel image, all channels are processed separately. @@ -66,39 +148,3 @@ Calculates a histogram with bins determined by the ``levels`` array. :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). :param stream: Stream for the asynchronous version. - - - -gpu::calcHist ------------------- -Calculates histogram for one channel 8-bit image. - -.. ocv:function:: void gpu::calcHist(const GpuMat& src, GpuMat& hist, Stream& stream = Stream::Null()) - - :param src: Source image. - - :param hist: Destination histogram with one row, 256 columns, and the ``CV_32SC1`` type. - - :param stream: Stream for the asynchronous version. - - - -gpu::equalizeHist ------------------- -Equalizes the histogram of a grayscale image. - -.. ocv:function:: void gpu::equalizeHist(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) - -.. ocv:function:: void gpu::equalizeHist(const GpuMat& src, GpuMat& dst, GpuMat& hist, GpuMat& buf, Stream& stream = Stream::Null()) - - :param src: Source image. - - :param dst: Destination image. - - :param hist: Destination histogram with one row, 256 columns, and the ``CV_32SC1`` type. - - :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). - - :param stream: Stream for the asynchronous version. - -.. seealso:: :ocv:func:`equalizeHist` diff --git a/modules/gpuimgproc/doc/hough.rst b/modules/gpuimgproc/doc/hough.rst index 33afabbb6b..eb0f83c97e 100644 --- a/modules/gpuimgproc/doc/hough.rst +++ b/modules/gpuimgproc/doc/hough.rst @@ -5,18 +5,70 @@ Hough Transform -gpu::HoughLines ---------------- +gpu::HoughLinesDetector +----------------------- +.. ocv:class:: gpu::HoughLinesDetector : public Algorithm + +Base class for lines detector algorithm. :: + + class CV_EXPORTS HoughLinesDetector : public Algorithm + { + public: + virtual void detect(InputArray src, OutputArray lines) = 0; + virtual void downloadResults(InputArray d_lines, OutputArray h_lines, OutputArray h_votes = noArray()) = 0; + + virtual void setRho(float rho) = 0; + virtual float getRho() const = 0; + + virtual void setTheta(float theta) = 0; + virtual float getTheta() const = 0; + + virtual void setThreshold(int threshold) = 0; + virtual int getThreshold() const = 0; + + virtual void setDoSort(bool doSort) = 0; + virtual bool getDoSort() const = 0; + + virtual void setMaxLines(int maxLines) = 0; + virtual int getMaxLines() const = 0; + }; + + + +gpu::HoughLinesDetector::detect +------------------------------- Finds lines in a binary image using the classical Hough transform. -.. ocv:function:: void gpu::HoughLines(const GpuMat& src, GpuMat& lines, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096) - -.. ocv:function:: void gpu::HoughLines(const GpuMat& src, GpuMat& lines, HoughLinesBuf& buf, float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096) +.. ocv:function:: void gpu::HoughLinesDetector::detect(InputArray src, OutputArray lines) :param src: 8-bit, single-channel binary source image. :param lines: Output vector of lines. Each line is represented by a two-element vector :math:`(\rho, \theta)` . :math:`\rho` is the distance from the coordinate origin :math:`(0,0)` (top-left corner of the image). :math:`\theta` is the line rotation angle in radians ( :math:`0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}` ). +.. seealso:: :ocv:func:`HoughLines` + + + +gpu::HoughLinesDetector::downloadResults +---------------------------------------- +Downloads results from :ocv:func:`gpu::HoughLinesDetector::detect` to host memory. + +.. ocv:function:: void gpu::HoughLinesDetector::downloadResults(InputArray d_lines, OutputArray h_lines, OutputArray h_votes = noArray()) + + :param d_lines: Result of :ocv:func:`gpu::HoughLinesDetector::detect` . + + :param h_lines: Output host array. + + :param h_votes: Optional output array for line's votes. + + + +gpu::createHoughLinesDetector +----------------------------- +Creates implementation for :ocv:class:`gpu::HoughLinesDetector` . + +.. ocv:function:: Ptr gpu::createHoughLinesDetector(float rho, float theta, int threshold, bool doSort = false, int maxLines = 4096) + :param rho: Distance resolution of the accumulator in pixels. :param theta: Angle resolution of the accumulator in radians. @@ -27,47 +79,129 @@ Finds lines in a binary image using the classical Hough transform. :param maxLines: Maximum number of output lines. - :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). -.. seealso:: :ocv:func:`HoughLines` + +gpu::HoughSegmentDetector +------------------------- +.. ocv:class:: gpu::HoughSegmentDetector : public Algorithm + +Base class for line segments detector algorithm. :: + + class CV_EXPORTS HoughSegmentDetector : public Algorithm + { + public: + virtual void detect(InputArray src, OutputArray lines) = 0; + + virtual void setRho(float rho) = 0; + virtual float getRho() const = 0; + + virtual void setTheta(float theta) = 0; + virtual float getTheta() const = 0; + + virtual void setMinLineLength(int minLineLength) = 0; + virtual int getMinLineLength() const = 0; + + virtual void setMaxLineGap(int maxLineGap) = 0; + virtual int getMaxLineGap() const = 0; + + virtual void setMaxLines(int maxLines) = 0; + virtual int getMaxLines() const = 0; + }; -gpu::HoughLinesDownload ------------------------ -Downloads results from :ocv:func:`gpu::HoughLines` to host memory. +gpu::HoughSegmentDetector::detect +--------------------------------- +Finds line segments in a binary image using the probabilistic Hough transform. -.. ocv:function:: void gpu::HoughLinesDownload(const GpuMat& d_lines, OutputArray h_lines, OutputArray h_votes = noArray()) +.. ocv:function:: void gpu::HoughSegmentDetector::detect(InputArray src, OutputArray lines) - :param d_lines: Result of :ocv:func:`gpu::HoughLines` . + :param src: 8-bit, single-channel binary source image. - :param h_lines: Output host array. + :param lines: Output vector of lines. Each line is represented by a 4-element vector :math:`(x_1, y_1, x_2, y_2)` , where :math:`(x_1,y_1)` and :math:`(x_2, y_2)` are the ending points of each detected line segment. - :param h_votes: Optional output array for line's votes. - -.. seealso:: :ocv:func:`gpu::HoughLines` +.. seealso:: :ocv:func:`HoughLinesP` -gpu::HoughCircles ------------------ +gpu::createHoughSegmentDetector +------------------------------- +Creates implementation for :ocv:class:`gpu::HoughSegmentDetector` . + +.. ocv:function:: Ptr gpu::createHoughSegmentDetector(float rho, float theta, int minLineLength, int maxLineGap, int maxLines = 4096) + + :param rho: Distance resolution of the accumulator in pixels. + + :param theta: Angle resolution of the accumulator in radians. + + :param minLineLength: Minimum line length. Line segments shorter than that are rejected. + + :param maxLineGap: Maximum allowed gap between points on the same line to link them. + + :param maxLines: Maximum number of output lines. + + + +gpu::HoughCirclesDetector +------------------------- +.. ocv:class:: gpu::HoughCirclesDetector : public Algorithm + +Base class for circles detector algorithm. :: + + class CV_EXPORTS HoughCirclesDetector : public Algorithm + { + public: + virtual void detect(InputArray src, OutputArray circles) = 0; + + virtual void setDp(float dp) = 0; + virtual float getDp() const = 0; + + virtual void setMinDist(float minDist) = 0; + virtual float getMinDist() const = 0; + + virtual void setCannyThreshold(int cannyThreshold) = 0; + virtual int getCannyThreshold() const = 0; + + virtual void setVotesThreshold(int votesThreshold) = 0; + virtual int getVotesThreshold() const = 0; + + virtual void setMinRadius(int minRadius) = 0; + virtual int getMinRadius() const = 0; + + virtual void setMaxRadius(int maxRadius) = 0; + virtual int getMaxRadius() const = 0; + + virtual void setMaxCircles(int maxCircles) = 0; + virtual int getMaxCircles() const = 0; + }; + + + +gpu::HoughCirclesDetector::detect +--------------------------------- Finds circles in a grayscale image using the Hough transform. -.. ocv:function:: void gpu::HoughCircles(const GpuMat& src, GpuMat& circles, int method, float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096) - -.. ocv:function:: void gpu::HoughCircles(const GpuMat& src, GpuMat& circles, HoughCirclesBuf& buf, int method, float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096) +.. ocv:function:: void gpu::HoughCirclesDetector::detect(InputArray src, OutputArray circles) :param src: 8-bit, single-channel grayscale input image. :param circles: Output vector of found circles. Each vector is encoded as a 3-element floating-point vector :math:`(x, y, radius)` . - :param method: Detection method to use. Currently, the only implemented method is ``CV_HOUGH_GRADIENT`` , which is basically *21HT* , described in [Yuen90]_. +.. seealso:: :ocv:func:`HoughCircles` + + + +gpu::createHoughCirclesDetector +------------------------------- +Creates implementation for :ocv:class:`gpu::HoughCirclesDetector` . + +.. ocv:function:: Ptr gpu::createHoughCirclesDetector(float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096) :param dp: Inverse ratio of the accumulator resolution to the image resolution. For example, if ``dp=1`` , the accumulator has the same resolution as the input image. If ``dp=2`` , the accumulator has half as big width and height. :param minDist: Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed. - :param cannyThreshold: The higher threshold of the two passed to the :ocv:func:`gpu::Canny` edge detector (the lower one is twice smaller). + :param cannyThreshold: The higher threshold of the two passed to Canny edge detector (the lower one is twice smaller). :param votesThreshold: The accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. @@ -77,20 +211,102 @@ Finds circles in a grayscale image using the Hough transform. :param maxCircles: Maximum number of output circles. - :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). -.. seealso:: :ocv:func:`HoughCircles` + +gpu::GeneralizedHough +--------------------- +.. ocv:class:: gpu::GeneralizedHough : public Algorithm + +Base class for generalized hough transform. :: + + class CV_EXPORTS GeneralizedHough : public Algorithm + { + public: + static Ptr create(int method); + + virtual void setTemplate(InputArray templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1)) = 0; + virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0; + + virtual void detect(InputArray image, OutputArray positions, int cannyThreshold = 100) = 0; + virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions) = 0; + + virtual void downloadResults(InputArray d_positions, OutputArray h_positions, OutputArray h_votes = noArray()) = 0; + }; + + +Finds arbitrary template in the grayscale image using Generalized Hough Transform. -gpu::HoughCirclesDownload -------------------------- -Downloads results from :ocv:func:`gpu::HoughCircles` to host memory. +gpu::GeneralizedHough::create +----------------------------- +Creates implementation for :ocv:class:`gpu::GeneralizedHough` . -.. ocv:function:: void gpu::HoughCirclesDownload(const GpuMat& d_circles, OutputArray h_circles) +.. ocv:function:: Ptr gpu::GeneralizedHough::create(int method) - :param d_circles: Result of :ocv:func:`gpu::HoughCircles` . + :param method: Combination of flags ( ``cv::GeneralizedHough::GHT_POSITION`` , ``cv::GeneralizedHough::GHT_SCALE`` , ``cv::GeneralizedHough::GHT_ROTATION`` ) specifying transformation to find. - :param h_circles: Output host array. +For full affine transformations (move + scale + rotation) [Guil1999]_ algorithm is used, otherwise [Ballard1981]_ algorithm is used. -.. seealso:: :ocv:func:`gpu::HoughCircles` + + +gpu::GeneralizedHough::setTemplate +---------------------------------- +Set template to search. + +.. ocv:function:: void gpu::GeneralizedHough::setTemplate(InputArray templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1)) + +.. ocv:function:: void gpu::GeneralizedHough::setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) + + :param templ: Template image. Canny edge detector will be applied to extract template edges. + + :param cannyThreshold: Threshold value for Canny edge detector. + + :param templCenter: Center for rotation. By default image center will be used. + + :param edges: Edge map for template image. + + :param dx: First derivative of template image in the vertical direction. Support only ``CV_32S`` type. + + :param dy: First derivative of template image in the horizontal direction. Support only ``CV_32S`` type. + + + +gpu::GeneralizedHough::detect +----------------------------- +Finds template (set by :ocv:func:`gpu::GeneralizedHough::setTemplate` ) in the grayscale image. + +.. ocv:function:: void gpu::GeneralizedHough::detect(InputArray image, OutputArray positions, int cannyThreshold = 100) + +.. ocv:function:: void gpu::GeneralizedHough::detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions) + + :param templ: Input image. Canny edge detector will be applied to extract template edges. + + :param positions: Output vector of found objects. Each vector is encoded as a 4-element floating-point vector :math:`(x, y, scale, angle)` . + + :param cannyThreshold: Threshold value for Canny edge detector. + + :param edges: Edge map for input image. + + :param dx: First derivative of input image in the vertical direction. Support only ``CV_32S`` type. + + :param dy: First derivative of input image in the horizontal direction. Support only ``CV_32S`` type. + + + +gpu::GeneralizedHough::downloadResults +-------------------------------------- +Downloads results from :ocv:func:`gpu::GeneralizedHough::detect` to host memory. + +.. ocv:function:: void gpu::GeneralizedHough::downloadResult(InputArray d_positions, OutputArray h_positions, OutputArray h_votes = noArray()) + + :param d_lines: Result of :ocv:func:`gpu::GeneralizedHough::detect` . + + :param h_lines: Output host array. + + :param h_votes: Optional output array for votes. Each vector is encoded as a 3-element integer-point vector :math:`(position_votes, scale_votes, angle_votes)` . + + + +.. [Ballard1981] Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122. +.. [Guil1999] Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038. diff --git a/modules/gpuimgproc/doc/imgproc.rst b/modules/gpuimgproc/doc/imgproc.rst index cd91afecfa..776c339a53 100644 --- a/modules/gpuimgproc/doc/imgproc.rst +++ b/modules/gpuimgproc/doc/imgproc.rst @@ -5,11 +5,72 @@ Image Processing +gpu::CannyEdgeDetector +---------------------- +.. ocv:class:: gpu::CannyEdgeDetector : public Algorithm + +Base class for Canny Edge Detector. :: + + class CV_EXPORTS CannyEdgeDetector : public Algorithm + { + public: + virtual void detect(InputArray image, OutputArray edges) = 0; + virtual void detect(InputArray dx, InputArray dy, OutputArray edges) = 0; + + virtual void setLowThreshold(double low_thresh) = 0; + virtual double getLowThreshold() const = 0; + + virtual void setHighThreshold(double high_thresh) = 0; + virtual double getHighThreshold() const = 0; + + virtual void setAppertureSize(int apperture_size) = 0; + virtual int getAppertureSize() const = 0; + + virtual void setL2Gradient(bool L2gradient) = 0; + virtual bool getL2Gradient() const = 0; + }; + + + +gpu::CannyEdgeDetector::detect +------------------------------ +Finds edges in an image using the [Canny86]_ algorithm. + +.. ocv:function:: void gpu::CannyEdgeDetector::detect(InputArray image, OutputArray edges) + +.. ocv:function:: void gpu::CannyEdgeDetector::detect(InputArray dx, InputArray dy, OutputArray edges) + + :param image: Single-channel 8-bit input image. + + :param dx: First derivative of image in the vertical direction. Support only ``CV_32S`` type. + + :param dy: First derivative of image in the horizontal direction. Support only ``CV_32S`` type. + + :param edges: Output edge map. It has the same size and type as ``image`` . + + + +gpu::createCannyEdgeDetector +---------------------------- +Creates implementation for :ocv:class:`gpu::CannyEdgeDetector` . + +.. ocv:function:: Ptr gpu::createCannyEdgeDetector(double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false) + + :param low_thresh: First threshold for the hysteresis procedure. + + :param high_thresh: Second threshold for the hysteresis procedure. + + :param apperture_size: Aperture size for the :ocv:func:`Sobel` operator. + + :param L2gradient: Flag indicating whether a more accurate :math:`L_2` norm :math:`=\sqrt{(dI/dx)^2 + (dI/dy)^2}` should be used to compute the image gradient magnitude ( ``L2gradient=true`` ), or a faster default :math:`L_1` norm :math:`=|dI/dx|+|dI/dy|` is enough ( ``L2gradient=false`` ). + + + gpu::meanShiftFiltering ---------------------------- +----------------------- Performs mean-shift filtering for each point of the source image. -.. ocv:function:: void gpu::meanShiftFiltering( const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::meanShiftFiltering(InputArray src, OutputArray dst, int sp, int sr, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), Stream& stream = Stream::Null()) :param src: Source image. Only ``CV_8UC4`` images are supported for now. @@ -26,10 +87,10 @@ It maps each point of the source image into another point. As a result, you have gpu::meanShiftProc ----------------------- +------------------ Performs a mean-shift procedure and stores information about processed points (their colors and positions) in two images. -.. ocv:function:: void gpu::meanShiftProc( const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr, TermCriteria criteria=TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::meanShiftProc(InputArray src, OutputArray dstr, OutputArray dstsp, int sp, int sr, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), Stream& stream = Stream::Null()) :param src: Source image. Only ``CV_8UC4`` images are supported for now. @@ -48,14 +109,14 @@ Performs a mean-shift procedure and stores information about processed points (t gpu::meanShiftSegmentation ------------------------------- +-------------------------- Performs a mean-shift segmentation of the source image and eliminates small segments. -.. ocv:function:: void gpu::meanShiftSegmentation(const GpuMat& src, Mat& dst, int sp, int sr, int minsize, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1)) +.. ocv:function:: void gpu::meanShiftSegmentation(InputArray src, OutputArray dst, int sp, int sr, int minsize, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1)) :param src: Source image. Only ``CV_8UC4`` images are supported for now. - :param dst: Segmented image with the same size and type as ``src`` . + :param dst: Segmented image with the same size and type as ``src`` (host memory). :param sp: Spatial window radius. @@ -67,46 +128,49 @@ Performs a mean-shift segmentation of the source image and eliminates small segm -gpu::MatchTemplateBuf +gpu::TemplateMatching --------------------- -.. ocv:struct:: gpu::MatchTemplateBuf +.. ocv:class:: gpu::TemplateMatching : public Algorithm -Class providing memory buffers for :ocv:func:`gpu::matchTemplate` function, plus it allows to adjust some specific parameters. :: +Base class for Template Matching. :: - struct CV_EXPORTS MatchTemplateBuf + class CV_EXPORTS TemplateMatching : public Algorithm { - Size user_block_size; - GpuMat imagef, templf; - std::vector images; - std::vector image_sums; - std::vector image_sqsums; + public: + virtual void match(InputArray image, InputArray templ, OutputArray result, Stream& stream = Stream::Null()) = 0; }; -You can use field `user_block_size` to set specific block size for :ocv:func:`gpu::matchTemplate` function. If you leave its default value `Size(0,0)` then automatic estimation of block size will be used (which is optimized for speed). By varying `user_block_size` you can reduce memory requirements at the cost of speed. - -gpu::matchTemplate ----------------------- +gpu::TemplateMatching::match +---------------------------- Computes a proximity map for a raster template and an image where the template is searched for. -.. ocv:function:: void gpu::matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method, Stream &stream = Stream::Null()) +.. ocv:function:: void gpu::TemplateMatching::match(InputArray image, InputArray templ, OutputArray result, Stream& stream = Stream::Null()) -.. ocv:function:: void gpu::matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method, MatchTemplateBuf &buf, Stream& stream = Stream::Null()) - - :param image: Source image. ``CV_32F`` and ``CV_8U`` depth images (1..4 channels) are supported for now. + :param image: Source image. :param templ: Template image with the size and type the same as ``image`` . :param result: Map containing comparison results ( ``CV_32FC1`` ). If ``image`` is *W x H* and ``templ`` is *w x h*, then ``result`` must be *W-w+1 x H-h+1*. - :param method: Specifies the way to compare the template with the image. - - :param buf: Optional buffer to avoid extra memory allocations and to adjust some specific parameters. See :ocv:struct:`gpu::MatchTemplateBuf`. - :param stream: Stream for the asynchronous version. - The following methods are supported for the ``CV_8U`` depth images for now: + + +gpu::createTemplateMatching +--------------------------- +Creates implementation for :ocv:class:`gpu::TemplateMatching` . + +.. ocv:function:: Ptr gpu::createTemplateMatching(int srcType, int method, Size user_block_size = Size()) + + :param srcType: Input source type. ``CV_32F`` and ``CV_8U`` depth images (1..4 channels) are supported for now. + + :param method: Specifies the way to compare the template with the image. + + :param user_block_size: You can use field `user_block_size` to set specific block size. If you leave its default value `Size(0,0)` then automatic estimation of block size will be used (which is optimized for speed). By varying `user_block_size` you can reduce memory requirements at the cost of speed. + +The following methods are supported for the ``CV_8U`` depth images for now: * ``CV_TM_SQDIFF`` * ``CV_TM_SQDIFF_NORMED`` @@ -115,7 +179,7 @@ Computes a proximity map for a raster template and an image where the template i * ``CV_TM_CCOEFF`` * ``CV_TM_CCOEFF_NORMED`` - The following methods are supported for the ``CV_32F`` images for now: +The following methods are supported for the ``CV_32F`` images for now: * ``CV_TM_SQDIFF`` * ``CV_TM_CCORR`` @@ -124,45 +188,11 @@ Computes a proximity map for a raster template and an image where the template i -gpu::Canny -------------------- -Finds edges in an image using the [Canny86]_ algorithm. - -.. ocv:function:: void gpu::Canny(const GpuMat& image, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false) - -.. ocv:function:: void gpu::Canny(const GpuMat& image, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false) - -.. ocv:function:: void gpu::Canny(const GpuMat& dx, const GpuMat& dy, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false) - -.. ocv:function:: void gpu::Canny(const GpuMat& dx, const GpuMat& dy, CannyBuf& buf, GpuMat& edges, double low_thresh, double high_thresh, bool L2gradient = false) - - :param image: Single-channel 8-bit input image. - - :param dx: First derivative of image in the vertical direction. Support only ``CV_32S`` type. - - :param dy: First derivative of image in the horizontal direction. Support only ``CV_32S`` type. - - :param edges: Output edge map. It has the same size and type as ``image`` . - - :param low_thresh: First threshold for the hysteresis procedure. - - :param high_thresh: Second threshold for the hysteresis procedure. - - :param apperture_size: Aperture size for the :ocv:func:`Sobel` operator. - - :param L2gradient: Flag indicating whether a more accurate :math:`L_2` norm :math:`=\sqrt{(dI/dx)^2 + (dI/dy)^2}` should be used to compute the image gradient magnitude ( ``L2gradient=true`` ), or a faster default :math:`L_1` norm :math:`=|dI/dx|+|dI/dy|` is enough ( ``L2gradient=false`` ). - - :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). - -.. seealso:: :ocv:func:`Canny` - - - gpu::bilateralFilter -------------------- Performs bilateral filtering of passed image -.. ocv:function:: void gpu::bilateralFilter( const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode=BORDER_DEFAULT, Stream& stream=Stream::Null() ) +.. ocv:function:: void gpu::bilateralFilter(InputArray src, OutputArray dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode=BORDER_DEFAULT, Stream& stream=Stream::Null()) :param src: Source image. Supports only (channles != 2 && depth() != CV_8S && depth() != CV_32S && depth() != CV_64F). @@ -178,9 +208,7 @@ Performs bilateral filtering of passed image :param stream: Stream for the asynchronous version. -.. seealso:: - - :ocv:func:`bilateralFilter` +.. seealso:: :ocv:func:`bilateralFilter` @@ -188,7 +216,7 @@ gpu::blendLinear ------------------- Performs linear blending of two images. -.. ocv:function:: void gpu::blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2, GpuMat& result, Stream& stream = Stream::Null()) +.. ocv:function:: void gpu::blendLinear(InputArray img1, InputArray img2, InputArray weights1, InputArray weights2, OutputArray result, Stream& stream = Stream::Null()) :param img1: First image. Supports only ``CV_8U`` and ``CV_32F`` depth.