Commit e6d82017 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

added documentation for gpu::BroxOpticalFlow, updated other docs

parent b398ac7a
......@@ -68,9 +68,9 @@ Structure similar to :ocv:class:`gpu::DevMem2D_` but containing only a pointer a
gpu::PtrElemStrp\_
gpu::PtrElemStep\_
------------------
.. ocv:class:: gpu::PtrElemStrp\_
.. ocv:class:: gpu::PtrElemStep\_
Structure similar to :ocv:class:`gpu::DevMem2D_` but containing only a pointer and a row step in elements. Width and height fields are excluded due to performance reasons. This class can only be constructed if ``sizeof(T)`` is a multiple of 256. The structure is intended for internal use or for users who write device code. ::
......@@ -123,7 +123,6 @@ Beware that the latter limitation may lead to overloaded matrix operators that c
void upload(const CudaMem& m, Stream& stream);
//! downloads data from device to host memory. Blocking calls.
operator Mat() const;
void download(cv::Mat& m) const;
//! download async
......
......@@ -16,3 +16,4 @@ gpu. GPU-accelerated Computer Vision
feature_detection_and_description
image_filtering
camera_calibration_and_3d_reconstruction
video
......@@ -328,15 +328,23 @@ gpu::remap
--------------
Applies a generic geometrical transformation to an image.
.. ocv:function:: void gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap)
.. ocv:function:: void gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode = BORDER_CONSTANT, const Scalar& borderValue = Scalar(), Stream& stream = Stream::Null()
:param src: Source image. Only ``CV_8UC1`` and ``CV_8UC3`` source types are supported.
:param src: Source image.
:param dst: Destination image with the size the same as ``xmap`` and the type the same as ``src`` .
:param xmap: X values. Only ``CV_32FC1`` type is supported.
:param ymap: Y values. Only ``CV_32FC1`` type is supported.
:param interpolation: Interpolation method (see :ocv:func:`resize` ). ``INTER_NEAREST`` , ``INTER_LINEAR`` and ``INTER_CUBIC`` are supported for now.
:param borderMode: Pixel extrapolation method (see :ocv:func:`borderInterpolate` ). ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
:param borderValue: Value used in case of a constant border. By default, it is 0.
:param stream: Stream for the asynchronous version.
The function transforms the source image using the specified map:
......@@ -400,7 +408,7 @@ Resizes an image.
.. ocv:function:: void gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null())
:param src: Source image. ``CV_8UC1`` and ``CV_8UC4`` types are supported.
:param src: Source image.
:param dst: Destination image with the same type as ``src`` . The size is ``dsize`` (when it is non-zero) or the size is computed from ``src.size()`` , ``fx`` , and ``fy`` .
......@@ -423,7 +431,7 @@ Resizes an image.
\texttt{(double)dsize.height/src.rows}
:param interpolation: Interpolation method. Only ``INTER_NEAREST`` and ``INTER_LINEAR`` are supported.
:param interpolation: Interpolation method. ``INTER_NEAREST`` , ``INTER_LINEAR`` and ``INTER_CUBIC`` are supported for now.
:param stream: Stream for the asynchronous version.
......@@ -503,9 +511,9 @@ Rotates an image around the origin (0,0) and then shifts it.
gpu::copyMakeBorder
-----------------------
Copies a 2D array to a larger destination array and pads borders with the given constant.
Forms a border around an image.
.. ocv:function:: void gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar(), Stream& stream = Stream::Null())
.. ocv:function:: void gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType, const Scalar& value = Scalar(), Stream& stream = Stream::Null())
:param src: Source image. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` , and ``CV_32FC1`` types are supported.
......@@ -519,6 +527,8 @@ Copies a 2D array to a larger destination array and pads borders with the given
:param right: Number of pixels in each direction from the source image rectangle to extrapolate. For example: ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built.
:param borderType: Border type. See :ocv:func:`borderInterpolate` for details. ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
:param value: Border value.
:param stream: Stream for the asynchronous version.
......@@ -685,43 +695,17 @@ Builds spherical warping maps.
gpu::downsample
-------------------
Downsamples image by rejecting even rows and columns.
.. ocv:function:: void gpu::downsample(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
:param src: Source image.
:param dst: Destination image. Will have ``Size((src.cols+1)/2, (src.rows+1)/2)`` size and the same type as ``src`` .
:param stream: Stream for the asynchronous version.
gpu::upsample
-------------------
Upsamples the source image by injecting even zero rows and columns.
.. ocv:function:: void gpu::upsample(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
:param src: Source image.
:param dst: Destination image. Will have ``Size(src.cols*2, src.rows*2)`` size and the same type as ``src`` .
:param stream: Stream for the asynchronous version.
gpu::pyrDown
-------------------
Smoothes an image and downsamples it.
.. ocv:function:: void gpu::pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::pyrDown(const GpuMat& src, GpuMat& dst, int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null())
:param src: Source image.
:param dst: Destination image. Will have ``Size((src.cols+1)/2, (src.rows+1)/2)`` size and the same type as ``src`` .
:param borderType: Pixel extrapolation method (see :ocv:func:`borderInterpolate` ). ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
:param stream: Stream for the asynchronous version.
......@@ -733,11 +717,13 @@ gpu::pyrUp
-------------------
Upsamples an image and then smoothes it.
.. ocv:function:: void gpu::pyrUp(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::pyrUp(const GpuMat& src, GpuMat& dst, int borderType = BORDER_DEFAULT, Stream& stream = Stream::Null())
:param src: Source image.
:param dst: Destination image. Will have ``Size(src.cols*2, src.rows*2)`` size and the same type as ``src`` .
:param borderType: Pixel extrapolation method (see :ocv:func:`borderInterpolate` ). ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
:param stream: Stream for the asynchronous version.
......
......@@ -60,6 +60,7 @@ Class providing GPU computing features. ::
FEATURE_SET_COMPUTE_20,
FEATURE_SET_COMPUTE_21,
GLOBAL_ATOMICS,
SHARED_ATOMICS,
NATIVE_DOUBLE
};
......
......@@ -156,3 +156,33 @@ Counts non-zero matrix elements.
The function does not work with ``CV_64F`` images on GPUs with the compute capability < 1.3.
.. seealso:: :ocv:func:`countNonZero`
gpu::reduce
------
Reduces a matrix to a vector.
.. ocv:function:: void gpu::reduce(const GpuMat& mtx, GpuMat& vec, int dim, int reduceOp, int dtype = -1, Stream& stream = Stream::Null())
:param mtx: Source 2D matrix.
:param vec: Destination vector. Its size and type is defined by ``dim`` and ``dtype`` parameters.
:param dim: Dimension index along which the matrix is reduced. 0 means that the matrix is reduced to a single row. 1 means that the matrix is reduced to a single column.
:param reduceOp: Reduction operation that could be one of the following:
* **CV_REDUCE_SUM** The output is the sum of all rows/columns of the matrix.
* **CV_REDUCE_AVG** The output is the mean vector of all rows/columns of the matrix.
* **CV_REDUCE_MAX** The output is the maximum (column/row-wise) of all rows/columns of the matrix.
* **CV_REDUCE_MIN** The output is the minimum (column/row-wise) of all rows/columns of the matrix.
:param dtype: When it is negative, the destination vector will have the same type as the source matrix. Otherwise, its type will be ``CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), mtx.channels())`` .
The function ``reduce`` reduces the matrix to a vector by treating the matrix rows/columns as a set of 1D vectors and performing the specified operation on the vectors until a single row/column is obtained. For example, the function can be used to compute horizontal and vertical projections of a raster image. In case of ``CV_REDUCE_SUM`` and ``CV_REDUCE_AVG`` , the output may have a larger element bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction modes.
.. seealso:: :ocv:func:`reduce`
......@@ -5,6 +5,42 @@ Operations on Matrices
gpu::gemm
------------------
Performs generalized matrix multiplication.
.. ocv:function:: void gemm(const GpuMat& src1, const GpuMat& src2, double alpha, const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null())
:param src1: First multiplied input matrix that should have ``CV_32FC1`` , ``CV_64FC1`` , ``CV_32FC2`` , or ``CV_64FC2`` type.
:param src2: Second multiplied input matrix of the same type as ``src1`` .
:param alpha: Weight of the matrix product.
:param src3: Third optional delta matrix added to the matrix product. It should have the same type as ``src1`` and ``src2`` .
:param beta: Weight of ``src3`` .
:param dst: Destination matrix. It has the proper size and the same type as input matrices.
:param flags: Operation flags:
* **GEMM_1_T** transpose ``src1``
* **GEMM_2_T** transpose ``src2``
* **GEMM_3_T** transpose ``src3``
:param stream: Stream for the asynchronous version.
The function performs generalized matrix multiplication similar to the ``gemm`` functions in BLAS level 3. For example, ``gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`` corresponds to
.. math::
\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T
.. seealso:: :ocv:func:`gemm`
gpu::transpose
------------------
Transposes a matrix.
......
......@@ -9,15 +9,19 @@ gpu::add
------------
Computes a matrix-matrix or matrix-scalar sum.
.. ocv:function:: void gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::add(const GpuMat& src1, const Scalar& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::add(const GpuMat& src1, const Scalar& src2, GpuMat& dst, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null())
:param src1: First source matrix. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` , and ``CV_32FC1`` matrices are supported for now. Version with scalar supports only ``CV_32FC1`` and ``CV_32FC2`` matrices.
:param src1: First source matrix.
:param src2: Second source matrix or a scalar to be added to ``src1`` .
:param src2: Second source matrix or a scalar to be added to ``src1`` . Matrix should have the same size and type as ``src1`` .
:param dst: Destination matrix with the same size and type as ``src1`` .
:param dst: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``src1`` depth.
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
:param dtype: Optional depth of the output array.
:param stream: Stream for the asynchronous version.
......@@ -29,15 +33,19 @@ gpu::subtract
-----------------
Computes a matrix-matrix or matrix-scalar difference.
.. ocv:function:: void gpu::subtract(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::subtract(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::subtract(const GpuMat& src1, const Scalar& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::subtract(const GpuMat& src1, const Scalar& src2, GpuMat& dst, const GpuMat& mask = GpuMat(), int dtype = -1, Stream& stream = Stream::Null())
:param src1: First source matrix. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` , and ``CV_32FC1`` matrices are supported for now. Version with scalar supports only ``CV_32FC1`` and ``CV_32FC2`` matrices.
:param src1: First source matrix.
:param src2: Second source matrix or a scalar to be subtracted from ``src1`` .
:param src2: Second source matrix or a scalar to be added to ``src1`` . Matrix should have the same size and type as ``src1`` .
:param dst: Destination matrix with the same size and type as ``src1`` .
:param dst: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``src1`` depth.
:param mask: Optional operation mask, 8-bit single channel array, that specifies elements of the destination array to be changed.
:param dtype: Optional depth of the output array.
:param stream: Stream for the asynchronous version.
......@@ -49,15 +57,19 @@ gpu::multiply
-----------------
Computes a matrix-matrix or matrix-scalar per-element product.
.. ocv:function:: void gpu::multiply(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::multiply(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, double scale = 1, int dtype = -1, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::multiply(const GpuMat& src1, const Scalar& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::multiply(const GpuMat& src1, const Scalar& src2, GpuMat& dst, double scale = 1, int dtype = -1, Stream& stream = Stream::Null())
:param src1: First source matrix. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` , and ``CV_32FC1`` matrices are supported for now. Version with scalar supports only ``CV_32FC1`` matrices.
:param src1: First source matrix.
:param src2: Second source matrix or a scalar to be multiplied by ``src1`` elements.
:param dst: Destination matrix with the same size and type as ``src1`` .
:param dst: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``src1`` depth.
:param scale: Optional scale factor.
:param dtype: Optional depth of the output array.
:param stream: Stream for the asynchronous version.
......@@ -67,17 +79,23 @@ Computes a matrix-matrix or matrix-scalar per-element product.
gpu::divide
---------------
Computes a matrix-matrix or matrix-scalar sum.
Computes a matrix-matrix or matrix-scalar division.
.. ocv:function:: void gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, double scale = 1, int dtype = -1, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::divide(const GpuMat& src1, const Scalar& src2, GpuMat& dst, Stream& stream = Stream::Null())
.. ocv:function:: void gpu::divide(const GpuMat& src1, const Scalar& src2, GpuMat& dst, double scale = 1, int dtype = -1, Stream& stream = Stream::Null())
:param src1: First source matrix. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` , and ``CV_32FC1`` matrices are supported for now. Version with scalar supports only ``CV_32FC1`` matrices.
.. ocv:function:: void gpu::divide(double src1, const GpuMat& src2, GpuMat& dst, int dtype = -1, Stream& stream = Stream::Null())
:param src1: First source matrix or a scalar.
:param src2: Second source matrix or a scalar. The ``src1`` elements are divided by it.
:param dst: Destination matrix with the same size and type as ``src1`` .
:param dst: Destination matrix that has the same size and number of channels as the input array(s). The depth is defined by ``dtype`` or ``src1`` depth.
:param scale: Optional scale factor.
:param dtype: Optional depth of the output array.
:param stream: Stream for the asynchronous version.
......@@ -87,6 +105,42 @@ This function, in contrast to :ocv:func:`divide`, uses a round-down rounding mod
addWeighted
---------------
Computes the weighted sum of two arrays.
.. ocv:function:: void gpu::addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst, int dtype = -1, Stream& stream = Stream::Null());
:param src1: First source array.
:param alpha: Weight for the first array elements.
:param src2: Second source array of the same size and channel number as ``src1`` .
:param beta: Weight for the second array elements.
:param dst: Destination array that has the same size and number of channels as the input arrays.
:param gamma: Scalar added to each sum.
:param dtype: Optional depth of the destination array. When both input arrays have the same depth, ``dtype`` can be set to ``-1``, which will be equivalent to ``src1.depth()``.
:param stream: Stream for the asynchronous version.
The function ``addWeighted`` calculates the weighted sum of two arrays as follows:
.. math::
\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )
where ``I`` is a multi-dimensional index of array elements. In case of multi-channel arrays, each channel is processed independently.
.. seealso:: :ocv:func:`addWeighted`
gpu::exp
------------
Computes an exponent of each matrix element.
......@@ -151,7 +205,7 @@ Computes per-element absolute difference of two matrices (or of a matrix and sca
.. ocv:function:: void gpu::absdiff(const GpuMat& src1, const Scalar& src2, GpuMat& dst, Stream& stream = Stream::Null())
:param src1: First source matrix. ``CV_8UC1`` , ``CV_8UC4`` , ``CV_32SC1`` and ``CV_32FC1`` matrices are supported for now. Version with scalar supports only ``CV_32FC1`` matrices.
:param src1: First source matrix.
:param src2: Second source matrix or a scalar to be added to ``src1`` .
......@@ -169,11 +223,11 @@ Compares elements of two matrices.
.. ocv:function:: void gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int cmpop, Stream& stream = Stream::Null())
:param src1: First source matrix. ``CV_8UC4`` and ``CV_32FC1`` matrices are supported for now.
:param src1: First source matrix.
:param src2: Second source matrix with the same size and type as ``a`` .
:param src2: Second source matrix with the same size and type as ``src1`` .
:param dst: Destination matrix with the same size as ``a`` and the ``CV_8UC1`` type.
:param dst: Destination matrix with the same size as ``src1`` and the ``CV_8UC1`` type.
:param cmpop: Flag specifying the relation between the elements to be checked:
......
Video Analysis
==============
.. highlight:: cpp
gpu::BroxOpticalFlow
--------------------
.. ocv:class:: gpu::BroxOpticalFlow
Class computing the optical flow for two images using Brox et al Optical Flow algorithm ([Brox2004]_). ::
class BroxOpticalFlow
{
public:
BroxOpticalFlow(float alpha_, float gamma_, float scale_factor_, int inner_iterations_, int outer_iterations_, int solver_iterations_);
//! Compute optical flow
//! frame0 - source frame (supports only CV_32FC1 type)
//! frame1 - frame to track (with the same size and type as frame0)
//! u - flow horizontal component (along x axis)
//! v - flow vertical component (along y axis)
void operator ()(const GpuMat& frame0, const GpuMat& frame1, GpuMat& u, GpuMat& v, Stream& stream = Stream::Null());
//! flow smoothness
float alpha;
//! gradient constancy importance
float gamma;
//! pyramid scale factor
float scale_factor;
//! number of lagged non-linearity iterations (inner loop)
int inner_iterations;
//! number of warping iterations (number of pyramid levels)
int outer_iterations;
//! number of linear system solver iterations
int solver_iterations;
GpuMat buf;
};
gpu::interpolateFrames
----------------------
Interpolate frames (images) using provided optical flow (displacement field).
.. ocv:function:: void gpu::interpolateFrames(const GpuMat& frame0, const GpuMat& frame1, const GpuMat& fu, const GpuMat& fv, const GpuMat& bu, const GpuMat& bv, float pos, GpuMat& newFrame, GpuMat& buf, Stream& stream = Stream::Null())
:param frame0: First frame (32-bit floating point images, single channel).
:param frame1: Second frame. Must have the same type and size as ``frame0`` .
:param fu: Forward horizontal displacement.
:param fv: Forward vertical displacement.
:param bu: Backward horizontal displacement.
:param bv: Backward vertical displacement.
:param pos: New frame position.
:param newFrame: Output image.
:param buf: Temporary buffer, will have width x 6*height size, CV_32FC1 type and contain 6 GpuMat: occlusion masks for first frame, occlusion masks for second, interpolated forward horizontal flow, interpolated forward vertical flow, interpolated backward horizontal flow, interpolated backward vertical flow.
:param stream: Stream for the asynchronous version.
.. [Brox2004] T. Brox, A. Bruhn, N. Papenberg, J. Weickert. *High accuracy optical flow estimation based on a theory for warping*. ECCV 2004.
......@@ -598,7 +598,6 @@ CV_EXPORTS void pow(const GpuMat& src, double power, GpuMat& dst, Stream& stream
CV_EXPORTS void log(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());
//! compares elements of two arrays (c = a <cmpop> b)
//! supports CV_8UC4, CV_32FC1 types
CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream = Stream::Null());
//! performs per-elements bit-wise inversion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment