corrected grammar (done by Elena)

This commit is contained in:
Vadim Pisarevsky 2011-03-28 23:16:20 +00:00
parent fafc2f372c
commit 5291b9dfe5
4 changed files with 443 additions and 511 deletions

View File

@ -3,8 +3,6 @@ Camera Calibration and 3d Reconstruction
.. highlight:: cpp .. highlight:: cpp
.. index:: gpu::StereoBM_GPU .. index:: gpu::StereoBM_GPU
gpu::StereoBM_GPU gpu::StereoBM_GPU
@ -40,19 +38,18 @@ The class for computing stereo correspondence using block matching algorithm. ::
... ...
}; };
This class computes the disparity map using block matching algorithm. The class also performs pre- and post- filtering steps: sobel prefiltering (if ``PREFILTER_XSOBEL`` flag is set) and low textureness filtering (if ``averageTexThreshols`` :math:`>` 0). If ``avergeTexThreshold = 0`` low textureness filtering is disabled, otherwise disparity is set to 0 in each point ``(x, y)`` where for left image
This class computes the disparity map using block matching algorithm. The class also performs pre- and post- filtering steps: sobel prefiltering (if ``PREFILTER_XSOBEL`` flag is set) and low textureness filtering (if ``averageTexThreshols > 0``). If ``avergeTexThreshold = 0``, low textureness filtering is disabled, otherwise the disparity is set to 0 in each point ``(x, y)``, where for the left image
.. math:: .. math::
\sum HorizontalGradiensInWindow(x, y, winSize) < (winSize \cdot winSize) \cdot avergeTexThreshold \sum HorizontalGradiensInWindow(x, y, winSize) < (winSize \cdot winSize) \cdot avergeTexThreshold
i.e. input left image is low textured. i.e. input left image is low textured.
.. index:: gpu::StereoBM_GPU::StereoBM_GPU .. index:: gpu::StereoBM_GPU::StereoBM_GPU
gpu::StereoBM_GPU::StereoBM_GPU gpu::StereoBM_GPU::StereoBM_GPU
----------------------------------- -----------------------------------_
.. cpp:function:: gpu::StereoBM_GPU::StereoBM_GPU() .. cpp:function:: gpu::StereoBM_GPU::StereoBM_GPU()
.. cpp:function:: gpu::StereoBM_GPU::StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ) .. cpp:function:: gpu::StereoBM_GPU::StereoBM_GPU(int preset, int ndisparities = DEFAULT_NDISP, int winSize = DEFAULT_WINSZ)
@ -69,10 +66,10 @@ gpu::StereoBM_GPU::StereoBM_GPU
:param winSize: Block size. :param winSize: Block size.
.. index:: gpu::StereoBM_GPU::operator () .. index:: gpu::StereoBM_GPU::operator ()
.. _gpu::StereoBM_GPU::operator ():
gpu::StereoBM_GPU::operator () gpu::StereoBM_GPU::operator ()
---------------------------------- ----------------------------------
.. cpp:function:: void gpu::StereoBM_GPU::operator() (const GpuMat& left, const GpuMat& right, GpuMat& disparity) .. cpp:function:: void gpu::StereoBM_GPU::operator() (const GpuMat& left, const GpuMat& right, GpuMat& disparity)
@ -89,8 +86,6 @@ gpu::StereoBM_GPU::operator ()
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
.. index:: gpu::StereoBM_GPU::checkIfGpuCallReasonable .. index:: gpu::StereoBM_GPU::checkIfGpuCallReasonable
gpu::StereoBM_GPU::checkIfGpuCallReasonable gpu::StereoBM_GPU::checkIfGpuCallReasonable
@ -99,8 +94,6 @@ gpu::StereoBM_GPU::checkIfGpuCallReasonable
Some heuristics that tries to estmate if the current GPU will be faster then CPU in this algorithm. It queries current active device. Some heuristics that tries to estmate if the current GPU will be faster then CPU in this algorithm. It queries current active device.
.. index:: gpu::StereoBeliefPropagation .. index:: gpu::StereoBeliefPropagation
gpu::StereoBeliefPropagation gpu::StereoBeliefPropagation
@ -152,7 +145,7 @@ The class for computing stereo correspondence using belief propagation algorithm
The class implements Pedro F. Felzenszwalb algorithm [Pedro F. Felzenszwalb and Daniel P. Huttenlocher. Efficient belief propagation for early vision. International Journal of Computer Vision, 70(1), October 2006]. It can compute own data cost (using truncated linear model) or use user-provided data cost. The class implements Pedro F. Felzenszwalb algorithm [Pedro F. Felzenszwalb and Daniel P. Huttenlocher. Efficient belief propagation for early vision. International Journal of Computer Vision, 70(1), October 2006]. It can compute own data cost (using truncated linear model) or use user-provided data cost.
**Please note:** ``StereoBeliefPropagation`` requires a lot of memory: **Note:** ``StereoBeliefPropagation`` requires a lot of memory:
.. math:: .. math::
@ -166,8 +159,6 @@ for message storage and
for data cost storage. ``width_step`` is the number of bytes in a line including the padding. for data cost storage. ``width_step`` is the number of bytes in a line including the padding.
.. index:: gpu::StereoBeliefPropagation::StereoBeliefPropagation .. index:: gpu::StereoBeliefPropagation::StereoBeliefPropagation
gpu::StereoBeliefPropagation::StereoBeliefPropagation gpu::StereoBeliefPropagation::StereoBeliefPropagation
@ -176,7 +167,7 @@ gpu::StereoBeliefPropagation::StereoBeliefPropagation
.. cpp:function:: gpu::StereoBeliefPropagation::StereoBeliefPropagation( int ndisp, int iters, int levels, float max_data_term, float data_weight, float max_disc_term, float disc_single_jump, int msg_type = CV_32F) .. cpp:function:: gpu::StereoBeliefPropagation::StereoBeliefPropagation( int ndisp, int iters, int levels, float max_data_term, float data_weight, float max_disc_term, float disc_single_jump, int msg_type = CV_32F)
``StereoBeliefPropagation`` constructors. StereoBeliefPropagation constructors.
:param ndisp: Number of disparities. :param ndisp: Number of disparities.
@ -194,7 +185,7 @@ gpu::StereoBeliefPropagation::StereoBeliefPropagation
:param msg_type: Type for messages. Supports ``CV_16SC1`` and ``CV_32FC1``. :param msg_type: Type for messages. Supports ``CV_16SC1`` and ``CV_32FC1``.
:cpp:class:`StereoBeliefPropagation` uses truncated linear model for the data cost and discontinuity term: ``StereoBeliefPropagation`` uses truncated linear model for the data cost and discontinuity term:
.. math:: .. math::
@ -206,14 +197,12 @@ gpu::StereoBeliefPropagation::StereoBeliefPropagation
For more details please see [Pedro F. Felzenszwalb and Daniel P. Huttenlocher. Efficient belief propagation for early vision. International Journal of Computer Vision, 70(1), October 2006]. For more details please see [Pedro F. Felzenszwalb and Daniel P. Huttenlocher. Efficient belief propagation for early vision. International Journal of Computer Vision, 70(1), October 2006].
By default :cpp:class:`StereoBeliefPropagation` uses floating-point arithmetics and ``CV_32FC1`` type for messages. But also it can use fixed-point arithmetics and ``CV_16SC1`` type for messages for better perfomance. To avoid overflow in this case, the parameters must satisfy By default, :cpp:class:`StereoBeliefPropagation` uses floating-point arithmetics and ``CV_32FC1`` type for messages. But also it can use fixed-point arithmetics and ``CV_16SC1`` type for messages for better performance. To avoid overflow in this case, the parameters must satisfy
.. math:: .. math::
10 \cdot 2^{levels-1} \cdot max \_ data \_ term < SHRT \_ MAX 10 \cdot 2^{levels-1} \cdot max \_ data \_ term < SHRT \_ MAX
.. index:: gpu::StereoBeliefPropagation::estimateRecommendedParams .. index:: gpu::StereoBeliefPropagation::estimateRecommendedParams
gpu::StereoBeliefPropagation::estimateRecommendedParams gpu::StereoBeliefPropagation::estimateRecommendedParams
@ -223,8 +212,6 @@ gpu::StereoBeliefPropagation::estimateRecommendedParams
Some heuristics that tries to compute recommended parameters (``ndisp``, ``iters`` and ``levels``) for specified image size (``width`` and ``height``). Some heuristics that tries to compute recommended parameters (``ndisp``, ``iters`` and ``levels``) for specified image size (``width`` and ``height``).
.. index:: gpu::StereoBeliefPropagation::operator () .. index:: gpu::StereoBeliefPropagation::operator ()
gpu::StereoBeliefPropagation::operator () gpu::StereoBeliefPropagation::operator ()
@ -243,18 +230,16 @@ gpu::StereoBeliefPropagation::operator ()
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
.. cpp:function:: void StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disparity) .. cpp:function:: void gpu::StereoBeliefPropagation::operator()( const GpuMat& data, GpuMat& disparity)
.. cpp:function:: void StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disparity, Stream& stream) .. cpp:function:: void gpu::StereoBeliefPropagation::operator()( const GpuMat& data, GpuMat& disparity, Stream& stream)
:param data: The user specified data cost. It must have ``msg_type`` type and :math:`\texttt{imgRows} \cdot \texttt{ndisp} \times \texttt{imgCols}` size. :param data: The user specified data cost, a matrix of ``msg_type`` type and ``Size(<image columns>*ndisp, <image rows>)`` size.
:param disparity: Output disparity map. If ``disparity`` is empty output type will be ``CV_16SC1``, otherwise output type will be ``disparity.type()``. :param disparity: Output disparity map. If the matrix is empty, it will be created as ``CV_16SC1`` matrix, otherwise the type will be retained.
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
.. index:: gpu::StereoConstantSpaceBP .. index:: gpu::StereoConstantSpaceBP
gpu::StereoConstantSpaceBP gpu::StereoConstantSpaceBP
@ -314,17 +299,15 @@ The class for computing stereo correspondence using constant space belief propag
The class implements Q. Yang algorithm [Q. Yang, L. Wang, and N. Ahuja. A constant-space belief propagation algorithm for stereo matching. In CVPR, 2010]. ``StereoConstantSpaceBP`` supports both local minimum and global minimum data cost initialization algortihms. For more details please see the paper. By default local algorithm is used, and to enable global algorithm set ``use_local_init_data_cost`` to false. The class implements Q. Yang algorithm [Q. Yang, L. Wang, and N. Ahuja. A constant-space belief propagation algorithm for stereo matching. In CVPR, 2010]. ``StereoConstantSpaceBP`` supports both local minimum and global minimum data cost initialization algortihms. For more details please see the paper. By default local algorithm is used, and to enable global algorithm set ``use_local_init_data_cost`` to false.
.. index:: gpu::StereoConstantSpaceBP::StereoConstantSpaceBP .. index:: gpu::StereoConstantSpaceBP::StereoConstantSpaceBP
gpu::StereoConstantSpaceBP::StereoConstantSpaceBP gpu::StereoConstantSpaceBP::StereoConstantSpaceBP
----------------------------------------------------- -----------------------------------------------------
.. cpp:function:: gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP, int iters = DEFAULT_ITERS, int levels = DEFAULT_LEVELS, int nr_plane = DEFAULT_NR_PLANE, int msg_type = CV_32F) .. cpp:function:: gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int ndisp = DEFAULT_NDISP, int iters = DEFAULT_ITERS, int levels = DEFAULT_LEVELS, int nr_plane = DEFAULT_NR_PLANE, int msg_type = CV_32F)
.. cpp:function:: gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane, float max_data_term, float data_weight, float max_disc_term, float disc_single_jump, int min_disp_th = 0, int msg_type = CV_32F) .. cpp:function:: StereoConstantSpaceBP::StereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane, float max_data_term, float data_weight, float max_disc_term, float disc_single_jump, int min_disp_th = 0, int msg_type = CV_32F)
``StereoConstantSpaceBP`` constructors. StereoConstantSpaceBP constructors.
:param ndisp: Number of disparities. :param ndisp: Number of disparities.
@ -346,7 +329,7 @@ gpu::StereoConstantSpaceBP::StereoConstantSpaceBP
:param msg_type: Type for messages. Supports ``CV_16SC1`` and ``CV_32FC1`` . :param msg_type: Type for messages. Supports ``CV_16SC1`` and ``CV_32FC1`` .
:cpp:class:`StereoConstantSpaceBP` uses truncated linear model for the data cost and discontinuity term: ``StereoConstantSpaceBP`` uses truncated linear model for the data cost and discontinuity term:
.. math:: .. math::
@ -356,16 +339,16 @@ gpu::StereoConstantSpaceBP::StereoConstantSpaceBP
DiscTerm = \min (disc \_ single \_ jump \cdot \lvert f_1-f_2 \rvert , max \_ disc \_ term) DiscTerm = \min (disc \_ single \_ jump \cdot \lvert f_1-f_2 \rvert , max \_ disc \_ term)
For more details please see [Q. Yang, L. Wang, and N. Ahuja. A constant-space belief propagation algorithm for stereo matching. In CVPR, 2010]. For more details please see
qx_csbp
.
By default :cpp:class:`StereoConstantSpaceBP` uses floating-point arithmetics and ``CV_32FC1`` type for messages. But also it can use fixed-point arithmetics and ``CV_16SC1`` type for messages for better perfomance. To avoid overflow in this case, the parameters must satisfy By default ``StereoConstantSpaceBP`` uses floating-point arithmetics and ``CV_32FC1`` type for messages. But also it can use fixed-point arithmetics and ``CV_16SC1`` type for messages for better perfomance. To avoid overflow in this case, the parameters must satisfy
.. math:: .. math::
10 \cdot 2^{levels-1} \cdot max \_ data \_ term < SHRT \_ MAX 10 \cdot 2^{levels-1} \cdot max \_ data \_ term < SHRT \_ MAX
.. index:: gpu::StereoConstantSpaceBP::estimateRecommendedParams .. index:: gpu::StereoConstantSpaceBP::estimateRecommendedParams
gpu::StereoConstantSpaceBP::estimateRecommendedParams gpu::StereoConstantSpaceBP::estimateRecommendedParams
@ -373,8 +356,7 @@ gpu::StereoConstantSpaceBP::estimateRecommendedParams
.. cpp:function:: void gpu::StereoConstantSpaceBP::estimateRecommendedParams( int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane) .. cpp:function:: void gpu::StereoConstantSpaceBP::estimateRecommendedParams( int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane)
Some heuristics that tries to compute parameters (``ndisp``, ``iters``, ``levels`` and ``nr_plane``) for specified image size (``width`` and ``height``). Some heuristics that tries to compute parameters (ndisp, iters, levelsand nrplane) for specified image size (widthand height).
.. index:: gpu::StereoConstantSpaceBP::operator () .. index:: gpu::StereoConstantSpaceBP::operator ()
@ -394,17 +376,17 @@ gpu::StereoConstantSpaceBP::operator ()
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
.. index:: gpu::DisparityBilateralFilter .. index:: gpu::DisparityBilateralFilter
.. _gpu::DisparityBilateralFilter:
gpu::DisparityBilateralFilter gpu::DisparityBilateralFilter
----------------------------- -----------------------------
.. cpp:class:: gpu::DisparityBilateralFilter .. cpp:class:: gpu::DisparityBilateralFilter
The class for disparity map refinement using joint bilateral filtering. :: The class for disparity map refinement using joint bilateral filtering. ::
class DisparityBilateralFilter class CV_EXPORTS DisparityBilateralFilter
{ {
public: public:
enum { DEFAULT_NDISP = 64 }; enum { DEFAULT_NDISP = 64 };
@ -429,8 +411,6 @@ The class for disparity map refinement using joint bilateral filtering. ::
The class implements Q. Yang algorithm [Q. Yang, L. Wang, and N. Ahuja. A constant-space belief propagation algorithm for stereo matching. In CVPR, 2010]. The class implements Q. Yang algorithm [Q. Yang, L. Wang, and N. Ahuja. A constant-space belief propagation algorithm for stereo matching. In CVPR, 2010].
.. index:: gpu::DisparityBilateralFilter::DisparityBilateralFilter .. index:: gpu::DisparityBilateralFilter::DisparityBilateralFilter
gpu::DisparityBilateralFilter::DisparityBilateralFilter gpu::DisparityBilateralFilter::DisparityBilateralFilter
@ -453,8 +433,6 @@ gpu::DisparityBilateralFilter::DisparityBilateralFilter
:param sigma_range: Filter range. :param sigma_range: Filter range.
.. index:: gpu::DisparityBilateralFilter::operator () .. index:: gpu::DisparityBilateralFilter::operator ()
gpu::DisparityBilateralFilter::operator () gpu::DisparityBilateralFilter::operator ()
@ -473,8 +451,6 @@ gpu::DisparityBilateralFilter::operator ()
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
.. index:: gpu::drawColorDisp .. index:: gpu::drawColorDisp
gpu::drawColorDisp gpu::drawColorDisp
@ -493,9 +469,7 @@ gpu::drawColorDisp
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
This function converts :math:`[0..ndisp)` interval to :math:`[0..240, 1, 1]` in ``HSV`` color space, than convert ``HSV`` color space to ``RGB``. This function draws a colorized disparity map by converting disparity values from ``[0..ndisp)`` interval first to ``HSV`` color space (where different disparity values correspond to different hues) and then converting the pixels to ``RGB`` for visualization.
.. index:: gpu::reprojectImageTo3D .. index:: gpu::reprojectImageTo3D
@ -511,13 +485,11 @@ gpu::reprojectImageTo3D
:param xyzw: Output 4-channel floating-point image of the same size as ``disp`` . Each element of ``xyzw(x,y)`` will contain the 3D coordinates ``(x,y,z,1)`` of the point ``(x,y)`` , computed from the disparity map. :param xyzw: Output 4-channel floating-point image of the same size as ``disp`` . Each element of ``xyzw(x,y)`` will contain the 3D coordinates ``(x,y,z,1)`` of the point ``(x,y)`` , computed from the disparity map.
:param Q: :math:`4 \times 4` perspective transformation matrix that can be obtained via :c:func:`stereoRectify`. :param Q: :math:`4 \times 4` perspective transformation matrix that can be obtained via :ref:`StereoRectify` .
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
See also: :c:func:`reprojectImageTo3D`. See Also: :c:func:`reprojectImageTo3D` .
.. index:: gpu::solvePnPRansac .. index:: gpu::solvePnPRansac
@ -550,4 +522,5 @@ gpu::solvePnPRansac
:param inliers: Output vector of inlier indices. :param inliers: Output vector of inlier indices.
See also :c:func:`solvePnPRansac`. See Also :c:func:`solvePnPRansac`.

View File

@ -1,17 +1,14 @@
Data Structures Data Structures
=============== ===============
.. highlight:: cpp .. index:: gpu::DevMem2D\_
.. index:: gpu::DevMem2D_
gpu::DevMem2D\_ gpu::DevMem2D\_
--------------- ---------------
.. cpp:class:: gpu::DevMem2D_ .. cpp:class:: gpu::DevMem2D\_
This is a simple lightweight class that encapsulate pitched memory on GPU. It is intended to pass to nvcc-compiled code, i.e. CUDA kernels. So it is used internally by OpenCV and by users writes own device code. Its members can be called both from host and from device code. :: This lightweight class encapsulates pitched memory on a GPU and is passed to nvcc-compiled code (CUDA kernels). Typically, it is used internally by OpenCV and by users who write device code. You can call its members from both host and device code.
::
template <typename T> struct DevMem2D_ template <typename T> struct DevMem2D_
{ {
@ -31,7 +28,7 @@ This is a simple lightweight class that encapsulate pitched memory on GPU. It is
__CV_GPU_HOST_DEVICE__ size_t elemSize() const; __CV_GPU_HOST_DEVICE__ size_t elemSize() const;
/* returns pointer to the beggining of given image row */ /* returns pointer to the beggining of the given image row */
__CV_GPU_HOST_DEVICE__ T* ptr(int y = 0); __CV_GPU_HOST_DEVICE__ T* ptr(int y = 0);
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const; __CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const;
}; };
@ -41,14 +38,15 @@ This is a simple lightweight class that encapsulate pitched memory on GPU. It is
typedef DevMem2D_<int> DevMem2Di; typedef DevMem2D_<int> DevMem2Di;
.. index:: gpu::PtrStep\_
.. index:: gpu::PtrStep_
gpu::PtrStep\_ gpu::PtrStep\_
-------------- --------------
.. cpp:class:: gpu::PtrStep_ .. cpp:class:: gpu::PtrStep\_
This is structure is similar to :cpp:class:`gpu::DevMem2D_` but contains only pointer and row step. Width and height fields are excluded due to performance reasons. The structure is for internal use or for users who write own device code. :: This structure is similar to
:cpp:class:`DevMem2D_` but contains only a pointer and row step. Width and height fields are excluded due to performance reasons. The structure is intended for internal use or for users who write device code.
::
template<typename T> struct PtrStep_ template<typename T> struct PtrStep_
{ {
@ -71,14 +69,15 @@ This is structure is similar to :cpp:class:`gpu::DevMem2D_` but contains only po
typedef PtrStep_<int> PtrStepi; typedef PtrStep_<int> PtrStepi;
.. index:: gpu::PtrElemStrp\_
.. index:: gpu::PtrElemStep_ gpu::PtrElemStrp\_
gpu::PtrElemStep\_
------------------ ------------------
.. cpp:class:: gpu::PtrElemStep_ .. cpp:class:: gpu::PtrElemStrp\_
This is structure is similar to :cpp:class:`gpu::DevMem2D_` but contains only pointer and row step in elements. Width and height fields are excluded due to performance reasons. This class is can only be constructed if ``sizeof(T)`` is a multiple of 256. The structure is for internal use or for users who write own device code. :: This structure is similar to
:cpp:class:`DevMem2D_` but contains only pointer and 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.
::
template<typename T> struct PtrElemStep_ : public PtrStep_<T> template<typename T> struct PtrElemStep_ : public PtrStep_<T>
{ {
@ -87,11 +86,6 @@ This is structure is similar to :cpp:class:`gpu::DevMem2D_` but contains only po
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const; __CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const;
}; };
typedef PtrElemStep_<unsigned char> PtrElemStep;
typedef PtrElemStep_<float> PtrElemStepf;
typedef PtrElemStep_<int> PtrElemStepi;
.. index:: gpu::GpuMat .. index:: gpu::GpuMat
@ -99,11 +93,22 @@ gpu::GpuMat
----------- -----------
.. cpp:class:: gpu::GpuMat .. cpp:class:: gpu::GpuMat
The base storage class for GPU memory with reference counting. Its interface is almost :c:type:`Mat` interface with some limitations, so using it won't be a problem. The limitations are no arbitrary dimensions support (only 2D), no functions that returns references to its data (because references on GPU are not valid for CPU), no expression templates technique support. Because of last limitation please take care with overloaded matrix operators - they cause memory allocations. The ``GpuMat`` class is convertible to :cpp:class:`gpu::DevMem2D_` and :cpp:class:`gpu::PtrStep_` so it can be passed to directly to kernel. This is a base storage class for GPU memory with reference counting. Its interface matches the
:c:type:`Mat` interface with the following limitations:
**Please note:** In contrast with :c:type:`Mat`, in most cases ``GpuMat::isContinuous() == false`` , i.e. rows are aligned to size depending on hardware. Also single row ``GpuMat`` is always a continuous matrix. :: *
no arbitrary dimensions support (only 2D)
*
no functions that return references to their data (because references on GPU are not valid for CPU)
*
no expression templates technique support
class GpuMat Beware that the latter limitation may lead to overloaded matrix operators that cause memory allocations. The ``GpuMat`` class is convertible to :cpp:class:`gpu::DevMem2D_` and :cpp:class:`gpu::PtrStep_` so it can be passed to directly to kernel.
**Note:**
In contrast with :c:type:`Mat`, in most cases ``GpuMat::isContinuous() == false`` . This means that rows are aligned to size depending on the hardware. Single-row ``GpuMat`` is always a continuous matrix. ::
class CV_EXPORTS GpuMat
{ {
public: public:
//! default constructor //! default constructor
@ -114,7 +119,7 @@ The base storage class for GPU memory with reference counting. Its interface is
..... .....
//! builds GpuMat from Mat. Perfom blocking upload to device. //! builds GpuMat from Mat. Blocks uploading to device.
explicit GpuMat (const Mat& m); explicit GpuMat (const Mat& m);
//! returns lightweight DevMem2D_ structure for passing //! returns lightweight DevMem2D_ structure for passing
@ -122,7 +127,7 @@ The base storage class for GPU memory with reference counting. Its interface is
template <class T> operator DevMem2D_<T>() const; template <class T> operator DevMem2D_<T>() const;
template <class T> operator PtrStep_<T>() const; template <class T> operator PtrStep_<T>() const;
//! pefroms blocking upload data to GpuMat. //! blocks uploading data to GpuMat.
void upload(const cv::Mat& m); void upload(const cv::Mat& m);
void upload(const CudaMem& m, Stream& stream); void upload(const CudaMem& m, Stream& stream);
@ -135,11 +140,11 @@ The base storage class for GPU memory with reference counting. Its interface is
}; };
**Please note:** Is it a bad practice to leave static or global ``GpuMat`` variables allocated, i.e. to rely on its destructor. That is because destruction order of such variables and CUDA context is undefined and GPU memory release function returns error if CUDA context has been destroyed before. **Note:**
You are not recommended to leave static or global ``GpuMat`` variables allocated, that is to rely on its destructor. The destruction order of such variables and CUDA context is undefined. GPU memory release function returns error if the CUDA context has been destroyed before.
See also: :c:type:`Mat`.
See Also:
:func:`Mat`
.. index:: gpu::CudaMem .. index:: gpu::CudaMem
@ -147,17 +152,21 @@ gpu::CudaMem
------------ ------------
.. cpp:class:: gpu::CudaMem .. cpp:class:: gpu::CudaMem
This is a class with reference counting that wraps special memory type allocation functions from CUDA. Its interface is also :c:type:`Mat`-like but with additional memory type parameter: This class with reference counting wraps special memory type allocation functions from CUDA. Its interface is also
:func:`Mat`-like but with additional memory type parameters.
* ``ALLOC_PAGE_LOCKED`` Set page locked memory type, used commonly for fast and asynchronous upload/download data from/to GPU. *
``ALLOC_PAGE_LOCKED``: Sets a page locked memory type, used commonly for fast and asynchronous upload/download data from/to GPU.
*
``ALLOC_ZEROCOPY``: Specifies a zero copy memory allocation that enables mapping the host memory to GPU address space, if supported.
*
``ALLOC_WRITE_COMBINED``: Sets the write combined buffer that is not cached by CPU. Such buffers are used to supply GPU with data when GPU only reads it. The advantage is a better CPU cache utilization.
* ``ALLOC_ZEROCOPY`` Specifies zero copy memory allocation, i.e. with possibility to map host memory to GPU address space if supported. **Note:**
Allocation size of such memory types is usually limited. For more details please see "CUDA 2.2 Pinned Memory APIs" document or "CUDA_C Programming Guide".
::
* ``ALLOC_WRITE_COMBINED`` Sets write combined buffer which is not cached by CPU. Such buffers are used to supply GPU with data when GPU only reads it. The advantage is better CPU cache utilization. class CV_EXPORTS CudaMem
**Please note:** Allocation size of such memory types is usually limited. For more details please see "CUDA 2.2 Pinned Memory APIs" document or "CUDA_C Programming Guide". ::
class CudaMem
{ {
public: public:
enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2, enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2,
@ -180,14 +189,13 @@ This is a class with reference counting that wraps special memory type allocatio
GpuMat createGpuMatHeader() const; GpuMat createGpuMatHeader() const;
operator GpuMat() const; operator GpuMat() const;
//if host memory can be mapperd to gpu address space; //if host memory can be mapped to gpu address space;
static bool canMapHostMemory(); static bool canMapHostMemory();
int alloc_type; int alloc_type;
}; };
.. index:: gpu::CudaMem::createMatHeader .. index:: gpu::CudaMem::createMatHeader
gpu::CudaMem::createMatHeader gpu::CudaMem::createMatHeader
@ -195,11 +203,7 @@ gpu::CudaMem::createMatHeader
.. cpp:function:: Mat gpu::CudaMem::createMatHeader() const .. cpp:function:: Mat gpu::CudaMem::createMatHeader() const
.. cpp:function:: gpu::CudaMem::operator Mat() const Creates a header without reference counting to :cpp:class:`gpu::CudaMem` data.
Creates header without reference counting to :cpp:class:`gpu::CudaMem` data.
.. index:: gpu::CudaMem::createGpuMatHeader .. index:: gpu::CudaMem::createGpuMatHeader
@ -208,11 +212,7 @@ gpu::CudaMem::createGpuMatHeader
.. cpp:function:: GpuMat gpu::CudaMem::createGpuMatHeader() const .. cpp:function:: GpuMat gpu::CudaMem::createGpuMatHeader() const
.. cpp:function:: gpu::CudaMem::operator GpuMat() const Maps CPU memory to GPU address space and creates :cpp:class:`gpu::GpuMat` header without reference counting for it. This can be done only if memory was allocated with ``ALLOC_ZEROCOPY`` flag and if it is supported by the hardware (laptops often share video and CPU memory, so address spaces can be mapped, and that eliminates an extra copy).
Maps CPU memory to GPU address space and creates :cpp:class:`gpu::GpuMat` header without reference counting for it. This can be done only if memory was allocated with ``ALLOC_ZEROCOPY`` flag and if it is supported by hardware (laptops often share video and CPU memory, so address spaces can be mapped, and that eliminates extra copy).
.. index:: gpu::CudaMem::canMapHostMemory .. index:: gpu::CudaMem::canMapHostMemory
@ -222,19 +222,19 @@ gpu::CudaMem::canMapHostMemory
Returns true if the current hardware supports address space mapping and ``ALLOC_ZEROCOPY`` memory allocation. Returns true if the current hardware supports address space mapping and ``ALLOC_ZEROCOPY`` memory allocation.
.. index:: gpu::Stream .. index:: gpu::Stream
gpu::Stream gpu::Stream
----------- -----------
.. cpp:class:: gpu::Stream .. cpp:class:: gpu::Stream
This class encapsulated queue of the asynchronous calls. Some functions have overloads with additional ``gpu::Stream`` parameter. The overloads do initialization work (allocate output buffers, upload constants, etc.), start GPU kernel and return before results are ready. A check if all operation are complete can be performed via :cpp:func:`gpu::Stream::queryIfComplete`. Asynchronous upload/download have to be performed from/to page-locked buffers, i.e. using :cpp:class:`gpu::CudaMem` or :c:type:`Mat` header that points to a region of :cpp:class:`gpu::CudaMem`. This class encapsulated a queue of asynchronous calls. Some functions have overloads with the additional ``gpu::Stream`` parameter. The overloads do initialization work (allocate output buffers, upload constants, and so on), start the GPU kernel, and return before results are ready. You can check whether all operation are complete via :cpp:func:`gpu::Stream::queryIfComplete`. You can asynchronously upload/download data from/to page-locked buffers, using :cpp:class:`gpu::CudaMem` or :c:type:`Mat` header that points to a region of :cpp:class:`gpu::CudaMem`.
**Please note the limitation**: currently it is not guaranteed that all will work properly if one operation will be enqueued twice with different data. Some functions use constant GPU memory and next call may update the memory before previous has been finished. But calling asynchronously different operations is safe because each operation has own constant buffer. Memory copy/upload/download/set operations to buffers hold by user are also safe. :: **Note:**
Currently, you may face problems if an operation is enqueued twice with different data. Some functions use the constant GPU memory, and next call may update the memory before the previous one has been finished. But calling different operations asynchronously is safe because each operation has its own constant buffer. Memory copy/upload/download/set operations to the buffers you hold are also safe.
::
class Stream class CV_EXPORTS Stream
{ {
public: public:
Stream(); Stream();
@ -269,7 +269,6 @@ This class encapsulated queue of the asynchronous calls. Some functions have ove
}; };
.. index:: gpu::Stream::queryIfComplete .. index:: gpu::Stream::queryIfComplete
gpu::Stream::queryIfComplete gpu::Stream::queryIfComplete
@ -278,8 +277,6 @@ gpu::Stream::queryIfComplete
Returns true if the current stream queue is finished, otherwise false. Returns true if the current stream queue is finished, otherwise false.
.. index:: gpu::Stream::waitForCompletion .. index:: gpu::Stream::waitForCompletion
gpu::Stream::waitForCompletion gpu::Stream::waitForCompletion
@ -288,30 +285,28 @@ gpu::Stream::waitForCompletion
Blocks until all operations in the stream are complete. Blocks until all operations in the stream are complete.
.. index:: gpu::StreamAccessor .. index:: gpu::StreamAccessor
gpu::StreamAccessor gpu::StreamAccessor
------------------- -------------------
.. cpp:class:: gpu::StreamAccessor .. cpp:class:: gpu::StreamAccessor
This class provides possibility to get ``cudaStream_t`` from :cpp:class:`gpu::Stream`. This class is declared in ``stream_accessor.hpp`` because that is only public header that depend on Cuda Runtime API. Including it will bring the dependency to your code. :: This class enables getting ``cudaStream_t`` from :cpp:class:`gpu::Stream` and is declared in ``stream_accessor.hpp`` because it is the only public header that depends on the CUDA Runtime API. Including it brings a dependency to your code.
::
struct StreamAccessor struct StreamAccessor
{ {
static cudaStream_t getStream(const Stream& stream); CV_EXPORTS static cudaStream_t getStream(const Stream& stream);
}; };
.. index:: gpu::createContinuous .. index:: gpu::createContinuous
gpu::createContinuous gpu::createContinuous
------------------------- -------------------------
.. cpp:function:: void gpu::createContinuous(int rows, int cols, int type, GpuMat& m) .. cpp:function:: void gpu::createContinuous(int rows, int cols, int type, GpuMat& m)
Creates continuous matrix in GPU memory. Creates a continuous matrix in the GPU memory.
:param rows: Row count. :param rows: Row count.
@ -319,19 +314,18 @@ gpu::createContinuous
:param type: Type of the matrix. :param type: Type of the matrix.
:param m: Destination matrix. Will be only reshaped if it has proper type and area (``rows`` :math:`\times` ``cols``). :param m: Destination matrix. This parameter changes only if it has a proper type and area (``rows x cols``).
Also the following wrappers are available: The following wrappers are also available:
*
.. cpp:function:: GpuMat gpu::createContinuous(int rows, int cols, int type) .. cpp:function:: GpuMat gpu::createContinuous(int rows, int cols, int type)
*
.. cpp:function:: void gpu::createContinuous(Size size, int type, GpuMat& m) .. cpp:function:: void gpu::createContinuous(Size size, int type, GpuMat& m)
*
.. cpp:function:: GpuMat gpu::createContinuous(Size size, int type) .. cpp:function:: GpuMat gpu::createContinuous(Size size, int type)
Matrix is called continuous if its elements are stored continuously, i.e. wuthout gaps in the end of each row. Matrix is called continuous if its elements are stored continuously, that is wuthout gaps in the end of each row.
.. index:: gpu::ensureSizeIsEnough .. index:: gpu::ensureSizeIsEnough
@ -339,16 +333,21 @@ gpu::ensureSizeIsEnough
--------------------------- ---------------------------
.. cpp:function:: void gpu::ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m) .. cpp:function:: void gpu::ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m)
Ensures that size of matrix is big enough and matrix has proper type. The function doesn't reallocate memory if the matrix has proper attributes already. .. cpp:function:: void gpu::ensureSizeIsEnough(Size size, int type, GpuMat& m)
Ensures that the size of a matrix is big enough and the matrix has a proper type. The function does not reallocate memory if the matrix has proper attributes already.
:param rows: Minimum desired number of rows. :param rows: Minimum desired number of rows.
:param cols: Minimum desired number of cols. :param cols: Minimum desired number of columns.
:param size: rows and cols passed as a structure
:param type: Desired matrix type. :param type: Desired matrix type.
:param m: Destination matrix. :param m: Destination matrix.
Also the following wrapper is available: The following wrapper is also available:
.. cpp:function:: void gpu::ensureSizeIsEnough(Size size, int type, GpuMat& m)

View File

@ -3,19 +3,20 @@ Image Processing
.. highlight:: cpp .. highlight:: cpp
.. index:: gpu::meanShiftFiltering .. index:: gpu::meanShiftFiltering
gpu::meanShiftFiltering gpu::meanShiftFiltering
--------------------------- ---------------------------
.. cpp:function:: void gpu::meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1)) .. cpp:function:: void gpu::meanShiftFiltering(const GpuMat& src, GpuMat& dst,
int sp, int sr,
TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER
+ TermCriteria::EPS, 5, 1))
Performs mean-shift filtering for each point of the source image. It maps each point of the source image into another point, and as the result we have new color and new position of each point. Performs mean-shift filtering for each point of the source image. It maps each point of the source image into another point. As a result, we have a new color and new position of each point.
:param src: Source image. Only ``CV_8UC4`` images are supported for now. :param src: Source image. Only ``CV_8UC4`` images are supported for now.
:param dst: Destination image, containing color of mapped points. Will have the same size and type as ``src``. :param dst: Destination image containing the color of mapped points. The size and type is the same as ``src`` .
:param sp: Spatial window radius. :param sp: Spatial window radius.
@ -23,21 +24,21 @@ gpu::meanShiftFiltering
:param criteria: Termination criteria. See :c:type:`TermCriteria`. :param criteria: Termination criteria. See :c:type:`TermCriteria`.
.. index:: gpu::meanShiftProc .. index:: gpu::meanShiftProc
gpu::meanShiftProc gpu::meanShiftProc
---------------------- ----------------------
.. cpp: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)) .. cpp: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))
Performs mean-shift procedure and stores information about processed points (i.e. their colors and positions) into two images. Performs a mean-shift procedure and stores information about processed points (their colors and positions) in two images.
:param src: Source image. Only ``CV_8UC4`` images are supported for now. :param src: Source image. Only ``CV_8UC4`` images are supported for now.
:param dstr: Destination image, containing color of mapped points. Will have the same size and type as ``src``. :param dstr: Destination image containing the color of mapped points. The size and type is the same as ``src`` .
:param dstsp: Destination image, containing position of mapped points. Will have the same size as ``src`` and ``CV_16SC2`` type. :param dstsp: Destination image containing the position of mapped points. The size is the same as ``src``. The type is ``CV_16SC2``.
:param sp: Spatial window radius. :param sp: Spatial window radius.
@ -45,9 +46,8 @@ gpu::meanShiftProc
:param criteria: Termination criteria. See :c:type:`TermCriteria`. :param criteria: Termination criteria. See :c:type:`TermCriteria`.
See also: :cpp:func:`gpu::meanShiftFiltering`. See Also:
:c:func:`gpu::meanShiftFiltering` .
.. index:: gpu::meanShiftSegmentation .. index:: gpu::meanShiftSegmentation
@ -55,22 +55,20 @@ gpu::meanShiftSegmentation
------------------------------ ------------------------------
.. cpp: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)) .. cpp: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))
Performs mean-shift segmentation of the source image and eliminates small segments. Performs a mean-shift segmentation of the source image and eleminates small segments.
:param src: Source ``CV_8UC4`` image. :param src: Source image. Only ``CV_8UC4`` images are supported for now.
:param dst: Segmented image. Will have the same size and type as ``src``. :param dst: Segmented image. The size and type is the same as ``src`` .
:param sp: Spatial window radius. :param sp: Spatial window radius.
:param sr: Color window radius. :param sr: Color window radius.
:param minsize: Minimum segment size. Smaller segements will be eliminated. :param minsize: Minimum segment size. Smaller segements are merged.
:param criteria: Termination criteria. See :c:type:`TermCriteria`. :param criteria: Termination criteria. See :c:type:`TermCriteria`.
.. index:: gpu::integral .. index:: gpu::integral
gpu::integral gpu::integral
@ -79,17 +77,16 @@ gpu::integral
.. cpp:function:: void gpu::integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum) .. cpp:function:: void gpu::integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum)
Computes integral image and squared integral image. Computes an integral image and a squared integral image.
:param src: Source image. Only ``CV_8UC1`` images are supported for now. :param src: Source image. Only ``CV_8UC1`` images are supported for now.
:param sum: Integral image. Will contain 32-bit unsigned integer values packed into ``CV_32SC1``. :param sum: Integral image containing 32-bit unsigned integer values packed into ``CV_32SC1`` .
:param sqsum: Squared integral image. Will have ``CV_32FC1`` type.
See also: :c:func:`integral`.
:param sqsum: Squared integral image of the ``CV_32FC1`` type.
See Also:
:c:func:`integral` .
.. index:: gpu::sqrIntegral .. index:: gpu::sqrIntegral
@ -97,13 +94,11 @@ gpu::sqrIntegral
-------------------- --------------------
.. cpp:function:: void gpu::sqrIntegral(const GpuMat& src, GpuMat& sqsum) .. cpp:function:: void gpu::sqrIntegral(const GpuMat& src, GpuMat& sqsum)
Computes squared integral image. Computes a squared integral image.
:param src: Source image. Only ``CV_8UC1`` images are supported for now. :param src: Source image. Only ``CV_8UC1`` images are supported for now.
:param sqsum: Squared integral image. Will contain 64-bit unsigned integer values packed into ``CV_64FC1``. :param sqsum: Squared integral image containing 64-bit unsigned integer values packed into ``CV_64FC1`` .
.. index:: gpu::columnSum .. index:: gpu::columnSum
@ -111,25 +106,25 @@ gpu::columnSum
------------------ ------------------
.. cpp:function:: void gpu::columnSum(const GpuMat& src, GpuMat& sum) .. cpp:function:: void gpu::columnSum(const GpuMat& src, GpuMat& sum)
Computes vertical (column) sum. Computes a vertical (column) sum.
:param src: Source image. Only ``CV_32FC1`` images are supported for now. :param src: Source image. Only ``CV_32FC1`` images are supported for now.
:param sum: Destination image. Will have ``CV_32FC1`` type. :param sum: Destination image of the ``CV_32FC1`` type.
.. index:: gpu::cornerHarris .. index:: gpu::cornerHarris
gpu::cornerHarris gpu::cornerHarris
--------------------- ---------------------
.. cpp:function:: void gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101) .. cpp:function:: void gpu::cornerHarris(const GpuMat& src, GpuMat& dst,
int blockSize, int ksize, double k,
int borderType=BORDER_REFLECT101)
Computes Harris cornerness criteria at each image pixel. Computes the Harris cornerness criteria at each image pixel.
:param src: Source image. Only ``CV_8UC1`` and ``CV_32FC1`` images are supported for now. :param src: Source image. Only ``CV_8UC1`` and ``CV_32FC1`` images are supported for now.
:param dst: Destination image. Will have the same size and ``CV_32FC1`` type and contain cornerness values. :param dst: Destination image containing cornerness values. The size is the same. The type is ``CV_32FC1`` .
:param blockSize: Neighborhood size. :param blockSize: Neighborhood size.
@ -139,21 +134,22 @@ gpu::cornerHarris
: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.
See also: :c:func:`cornerHarris`. See Also:
:c:func:`cornerHarris` .
.. index:: gpu::cornerMinEigenVal .. index:: gpu::cornerMinEigenVal
gpu::cornerMinEigenVal gpu::cornerMinEigenVal
-------------------------- --------------------------
.. cpp:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101) .. cpp:function:: void gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst,
int blockSize, int ksize,
int borderType=BORDER_REFLECT101)
Computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria. Computes the minimum eigen value of 2x2 derivative covariation matrix at each pixel (the cornerness criteria).
:param src: Source image. Only ``CV_8UC1`` and ``CV_32FC1`` images are supported for now. :param src: Source image. Only ``CV_8UC1`` and ``CV_32FC1`` images are supported for now.
:param dst: Destination image. Will have the same size and ``CV_32FC1`` type and contain cornerness values. :param dst: Destination image containing cornerness values. The size is the same. The type is ``CV_32FC1``.
:param blockSize: Neighborhood size. :param blockSize: Neighborhood size.
@ -165,57 +161,55 @@ gpu::cornerMinEigenVal
See also: :c:func:`cornerMinEigenVal`. See also: :c:func:`cornerMinEigenVal`.
.. index:: gpu::mulSpectrums .. index:: gpu::mulSpectrums
gpu::mulSpectrums gpu::mulSpectrums
--------------------- ---------------------
.. cpp:function:: void gpu::mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB=false) .. cpp:function:: void gpu::mulSpectrums(const GpuMat& a, const GpuMat& b,
GpuMat& c, int flags, bool conjB=false)
Performs per-element multiplication of two Fourier spectrums. Performs a per-element multiplication of two Fourier spectrums.
:param a: First spectrum. :param a: First spectrum.
:param b: Second spectrum. Must have the same size and type as ``a``. :param b: Second spectrum. The size and type is the same as ``a`` .
:param c: Destination spectrum. :param c: Destination spectrum.
:param flags: Mock paramter is kept for CPU/GPU interfaces similarity. :param flags: Mock parameter used for CPU/GPU interfaces similarity.
:param conjB: Optional flag which indicates the second spectrum must be conjugated before the multiplication. :param conjB: Optional flag to specify if the second spectrum needs to be conjugated before the multiplication.
Only full (i.e. not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
See also: :c:func:`mulSpectrums`.
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
See Also:
:c:func:`mulSpectrums` .
.. index:: gpu::mulAndScaleSpectrums .. index:: gpu::mulAndScaleSpectrums
gpu::mulAndScaleSpectrums gpu::mulAndScaleSpectrums
----------------------------- -----------------------------
.. cpp:function:: void gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, float scale, bool conjB=false) .. cpp:function:: void gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b,
GpuMat& c, int flags, float scale, bool conjB=false)
Performs per-element multiplication of two Fourier spectrums and scales the result. Performs a per-element multiplication of two Fourier spectrums and scales the result.
:param a: First spectrum. :param a: First spectrum.
:param b: Second spectrum. Must have the same size and type as ``a``. :param b: Second spectrum. The size and type is the same as ``a`` .
:param c: Destination spectrum. :param c: Destination spectrum.
:param flags: Mock paramter is kept for CPU/GPU interfaces similarity. :param flags: Mock parameter used for CPU/GPU interfaces similarity.
:param scale: Scale constant. :param scale: Scale constant.
:param conjB: Optional flag which indicates the second spectrum must be conjugated before the multiplication. :param conjB: Optional flag to specify if the second spectrum needs to be conjugated before the multiplication.
Only full (i.e. not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
See also: :c:func:`mulSpectrums`.
Only full (not packed) ``CV_32FC2`` complex spectrums in the interleaved format are supported for now.
See Also:
:c:func:`mulSpectrums` .
.. index:: gpu::dft .. index:: gpu::dft
@ -223,7 +217,7 @@ gpu::dft
------------ ------------
.. cpp:function:: void gpu::dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0) .. cpp:function:: void gpu::dft(const GpuMat& src, GpuMat& dst, Size dft_size, int flags=0)
Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix. Can handle real matrices ``CV32FC1`` and complex matrices in the interleaved format ``CV32FC2``. Performs a forward or inverse discrete Fourier transform (1D or 2D) of the floating point matrix. Use to handle real matrices (CV32FC1) and complex matrices in the interleaved format (CV32FC2).
:param src: Source matrix (real or complex). :param src: Source matrix (real or complex).
@ -235,55 +229,62 @@ gpu::dft
* **DFT_ROWS** Transform each individual row of the source matrix. * **DFT_ROWS** Transform each individual row of the source matrix.
* **DFT_SCALE** Scale the result: divide it by the number of elements in the transform (it's obtained from ``dft_size``). * **DFT_SCALE** Scale the result: divide it by the number of elements in the transform (obtained from ``dft_size`` ).
* **DFT_INVERSE** Inverse DFT must be perfromed for complex-complex case (real-complex and complex-real cases are respectively forward and inverse always). * **DFT_INVERSE** Invert DFT. Use for complex-complex cases (real-complex and complex-real cases are respectively forward and inverse always).
* **DFT_REAL_OUTPUT** The source matrix is the result of real-complex transform, so the destination matrix must be real. * **DFT_REAL_OUTPUT** Specify the output as real. The source matrix is the result of real-complex transform, so the destination matrix must be real.
The source matrix should be continuous, otherwise reallocation and data copying will be performed. Function chooses the operation mode depending on the flags, size and channel count of the source matrix:
* If the source matrix is complex and the output isn't specified as real then the destination matrix will be complex, will have ``dft_size`` size and ``CV_32FC2`` type. It will contain full result of the DFT (forward or inverse).
* If the source matrix is complex and the output is specified as real then function assumes that its input is the result of the forward transform (see next item). The destionation matrix will have ``dft_size`` size and ``CV_32FC1`` type. It will contain result of the inverse DFT.
* If the source matrix is real (i.e. its type is ``CV_32FC1``) then forward DFT will be performed. The result of the DFT will be packed into complex (``CV_32FC2``) matrix so its width will be ``dft_size.width / 2 + 1``, but if the source is a single column then height will be reduced instead of width.
See also: :c:func:`dft`.
The source matrix should be continuous, otherwise reallocation and data copying is performed. The function chooses an operation mode depending on the flags, size, and channel count of the source matrix:
*
If the source matrix is complex and the output is not specified as real, the destination matrix is complex, has the ``dft_size`` size and ``CV_32FC2`` type. The destination matrix contains a full result of the DFT (forward or inverse).
*
If the source matrix is complex and the output is specified as real, the function assumes that its input is the result of the forward transform (see next item). The destionation matrix has the ``dft_size`` size and ``CV_32FC1`` type. It contains the result of the inverse DFT.
*
If the source matrix is real (its type is ``CV_32FC1`` ), forward DFT is performed. The result of the DFT is packed into complex ( ``CV_32FC2`` ) matrix. So, the width of the destination matrix is ``dft_size.width / 2 + 1`` . But if the source is a single column, the height is reduced instead of the width.
See Also:
:c:func:`dft` .
.. index:: gpu::convolve .. index:: gpu::convolve
gpu::convolve gpu::convolve
----------------- -----------------
.. cpp:function:: void gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr=false) .. cpp:function:: void gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
bool ccorr=false)
.. cpp:function:: void gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result, bool ccorr, ConvolveBuf& buf) .. cpp:function:: void gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
bool ccorr, ConvolveBuf& buf)
Computes convolution (or cross-correlation) of two images. Computes convolution (or cross-correlation) of two images.
:param image: Source image. Only ``CV_32FC1`` images are supported for now. :param image: Source image. Only ``CV_32FC1`` images are supported for now.
:param templ: Template image. Must have size not greater then ``image`` size and be the same type as ``image``. :param templ: Template image. The size is not greater than the ``image`` size. The type is the same as ``image`` .
:param result: Result image. Will have the same size and type as ``image``. :param result: Result image. The size and type is the same as ``image`` .
:param ccorr: Flags which indicates cross-correlation must be evaluated instead of convolution. :param ccorr: Flags to evaluate cross-correlation instead of convolution.
:param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes). :param buf: Optional buffer to avoid extra memory allocations (for many calls with the same sizes).
.. index:: gpu::ConvolveBuf .. index:: gpu::ConvolveBuf
.. _gpu::ConvolveBuf:
gpu::ConvolveBuf gpu::ConvolveBuf
---------------- ----------------
.. cpp:class:: gpu::ConvolveBuf .. cpp:class:: gpu::ConvolveBuf
Memory buffer for the :cpp:func:`gpu::convolve` function. :: Provides a memory buffer for the
:c:func:`gpu::convolve` function.
::
struct ConvolveBuf struct CV_EXPORTS ConvolveBuf
{ {
ConvolveBuf() {} ConvolveBuf() {}
ConvolveBuf(Size image_size, Size templ_size) ConvolveBuf(Size image_size, Size templ_size)
@ -295,38 +296,38 @@ Memory buffer for the :cpp:func:`gpu::convolve` function. ::
}; };
.. index:: gpu::ConvolveBuf::ConvolveBuf .. index:: gpu::ConvolveBuf::ConvolveBuf
gpu::ConvolveBuf::ConvolveBuf gpu::ConvolveBuf::ConvolveBuf
--------------------------------- ---------------------------------
.. cpp:function:: gpu::ConvolveBuf::ConvolveBuf() .. cpp:function:: ConvolveBuf::ConvolveBuf()
Constructs an empty buffer which will be properly resized after first call of the convolve function. Constructs an empty buffer that will be properly resized after the first call of the
:c:func:`convolve` function.
.. cpp:function:: gpu::ConvolveBuf::ConvolveBuf(Size image_size, Size templ_size)
Constructs a buffer for the convolve function with respectively arguments.
.. cpp:function:: ConvolveBuf::ConvolveBuf(Size image_size, Size templ_size)
Constructs a buffer for the
:c:func:`convolve` function with respective arguments.
.. index:: gpu::matchTemplate .. index:: gpu::matchTemplate
gpu::matchTemplate gpu::matchTemplate
---------------------- ----------------------
.. cpp:function:: void gpu::matchTemplate(const GpuMat& image, const GpuMat& templ, GpuMat& result, int method) .. cpp:function:: void gpu::matchTemplate(const GpuMat& image, const GpuMat& templ,
GpuMat& result, int method)
Computes a proximity map for a raster template and an image where the template is searched for. Computes a proximity map for a raster template and an image where the template is searched for.
:param image: Source image. ``CV_32F`` and ``CV_8U`` depth images (1..4 channels) are supported for now. :param image: Source image. ``CV_32F`` and ``CV_8U`` depth images (1..4 channels) are supported for now.
:param templ: Template image. Must have the same size and type as ``image``. :param templ: Template image. The size and type is the same as ``image`` .
:param result: Map containing comparison results (``CV_32FC1``). If ``image`` is ``W`` :math:`\times` ``H`` and ``templ`` is ``w`` :math:`\times` ``h`` then ``result`` must be ``(W-w+1)`` :math:`\times` ``(H-h+1)``. :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 which the template must be compared with the image. :param method: Specifies the way to compare the template with the image.
Following methods are supported for the ``CV_8U`` depth images for now: The following methods are supported for the ``CV_8U`` depth images for now:
* CV_TM_SQDIFF * CV_TM_SQDIFF
* CV_TM_SQDIFF_NORMED * CV_TM_SQDIFF_NORMED
@ -335,14 +336,13 @@ Following methods are supported for the ``CV_8U`` depth images for now:
* CV_TM_CCOEFF * CV_TM_CCOEFF
* CV_TM_CCOEFF_NORMED * CV_TM_CCOEFF_NORMED
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_SQDIFF
* CV_TM_CCORR * CV_TM_CCORR
See also: :c:func:`matchTemplate`. See Also:
:c:func:`matchTemplate` .
.. index:: gpu::remap .. index:: gpu::remap
@ -354,7 +354,7 @@ gpu::remap
:param src: Source image. Only ``CV_8UC1`` and ``CV_8UC3`` source types are supported. :param src: Source image. Only ``CV_8UC1`` and ``CV_8UC3`` source types are supported.
:param dst: Destination image. It will have the same size as ``xmap`` and the same type as ``src``. :param dst: Destination image. The size is the same as ``xmap`` . The type is the same as ``src`` .
:param xmap: X values. Only ``CV_32FC1`` type is supported. :param xmap: X values. Only ``CV_32FC1`` type is supported.
@ -364,13 +364,11 @@ The function transforms the source image using the specified map:
.. math:: .. math::
dst(x,y) = src(xmap(x,y), ymap(x,y)) \texttt{dst} (x,y) = \texttt{src} (xmap(x,y), ymap(x,y))
Values of pixels with non-integer coordinates are computed using bilinear interpolation. Values of pixels with non-integer coordinates are computed using bilinear interpolation.
See also: :c:func:`remap`. See Also: :c:func:`remap` .
.. index:: gpu::cvtColor .. index:: gpu::cvtColor
@ -382,21 +380,20 @@ gpu::cvtColor
Converts image from one color space to another. Converts image from one color space to another.
:param src: Source image with ``CV_8U``, ``CV_16U`` or ``CV_32F`` depth and 1, 3 or 4 channels. :param src: Source image with ``CV_8U``, ``CV_16U``, or ``CV_32F`` depth and 1, 3, or 4 channels.
:param dst: Destination image; will have the same size and the same depth as ``src``. :param dst: Destination image. The size and depth is the same as ``src`` .
:param code: Color space conversion code. For details see :c:func:`cvtColor`. Conversion to/from Luv and Bayer color spaces doesn't supported. :param code: Color space conversion code. For details, see :func:`cvtColor` . Conversion to/from Luv and Bayer color spaces is not supported.
:param dcn: Number of channels in the destination image; if the parameter is 0, the number of the channels will be derived automatically from ``src`` and the ``code``. :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. :param stream: Stream for the asynchronous version.
3-channel color spaces (like ``HSV``, ``XYZ``, etc) can be stored to 4-channel image for better perfomance. 3-channel color spaces (like ``HSV``,``XYZ``, and so on) can be stored to a 4-channel image for better perfomance.
See also: :c:func:`cvtColor`.
See Also:
:func:`cvtColor` .
.. index:: gpu::threshold .. index:: gpu::threshold
@ -408,21 +405,20 @@ gpu::threshold
Applies a fixed-level threshold to each array element. Applies a fixed-level threshold to each array element.
:param src: Source array (single-channel, ``CV_64F`` depth isn't supported). :param src: Source array (single-channel). ``CV_64F`` depth is not supported.
:param dst: Destination array; will have the same size and the same type as ``src``. :param dst: Destination array. The size and type is the same as ``src`` .
:param thresh: Threshold value. :param thresh: Threshold value.
:param maxVal: Maximum value to use with ``THRESH_BINARY`` and ``THRESH_BINARY_INV`` thresholding types. :param maxVal: Maximum value to use with ``THRESH_BINARY`` and ``THRESH_BINARY_INV`` threshold types.
:param thresholdType: Thresholding type. For details see :c:func:`threshold`. ``THRESH_OTSU`` thresholding type doesn't supported. :param thresholdType: Threshold type. For details, see :func:`threshold` . The ``THRESH_OTSU`` threshold type is not supported.
:param stream: Stream for the asynchronous version. :param stream: Stream for the asynchronous version.
See also: :c:func:`threshold`. See Also:
:func:`threshold` .
.. index:: gpu::resize .. index:: gpu::resize
@ -432,35 +428,32 @@ gpu::resize
Resizes an image. Resizes an image.
:param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` types. :param src: Source image. Supports the ``CV_8UC1`` and ``CV_8UC4`` types.
:param dst: Destination image. It will have size ``dsize`` (when it is non-zero) or the size computed from ``src.size()`` and ``fx`` and ``fy``. The type of ``dst`` will be the same as of ``src``. :param dst: Destination image. The size is ``dsize`` (when it is non-zero) or the size is computed from ``src.size()``, ``fx``, and ``fy`` . The type is the same as ``src`` .
:param dsize: Destination image size. If it is zero, then it is computed as: :param dsize: Destination image size. If it is zero, it is computed as:
.. math::
\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}
Either ``dsize`` or both ``fx`` and ``fy`` must be non-zero.
:param fx: Scale factor along the horizontal axis. If it is zero, it is computed as:
.. math:: .. math::
dsize = Size(round(fx*src.cols), round(fy*src.rows)) \texttt{(double)dsize.width/src.cols}
Either ``dsize`` or both ``fx`` or ``fy`` must be non-zero. :param fy: Scale factor along the vertical axis. If it is zero, it is computed as:
:param fx: Scale factor along the horizontal axis. When 0, it is computed as
.. math:: .. math::
(double)dsize.width/src.cols \texttt{(double)dsize.height/src.rows}
:param fy: Scale factor along the vertical axis. When 0, it is computed as
.. math::
(double)dsize.height/src.rows
:param interpolation: Interpolation method. Supports only ``INTER_NEAREST`` and ``INTER_LINEAR``.
See also: :c:func:`resize`.
:param interpolation: Interpolation method. Only ``INTER_NEAREST`` and ``INTER_LINEAR`` are supported.
See Also: :func:`resize` .
.. index:: gpu::warpAffine .. index:: gpu::warpAffine
@ -470,19 +463,18 @@ gpu::warpAffine
Applies an affine transformation to an image. Applies an affine transformation to an image.
:param src: Source image. Supports ``CV_8U``, ``CV_16U``, ``CV_32S`` or ``CV_32F`` depth and 1, 3 or 4 channels. :param src: Source image. Supports ``CV_8U``, ``CV_16U``, ``CV_32S``, or ``CV_32F`` depth and 1, 3, or 4 channels.
:param dst: Destination image; will have size ``dsize`` and the same type as ``src``. :param dst: Destination image. The size is ``dsize`` . The type is the same as ``src`` .
:param M: :math:`2 \times 3` transformation matrix. :param M: *2x3* transformation matrix.
:param dsize: Size of the destination image. :param dsize: Size of the destination image.
:param flags: Combination of interpolation methods, see :c:func:`resize`, and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation(:math:`dst \rightarrow src` ). Supports only ``INTER_NEAREST``, ``INTER_LINEAR`` and ``INTER_CUBIC`` interpolation methods. :param flags: Combination of interpolation methods (see :func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` specifying that ``M`` is the inverse transformation (``dst=>src``). Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` interpolation methods are supported.
See also: :c:func:`warpAffine`.
See Also:
:func:`warpAffine` .
.. index:: gpu::warpPerspective .. index:: gpu::warpPerspective
@ -492,19 +484,18 @@ gpu::warpPerspective
Applies a perspective transformation to an image. Applies a perspective transformation to an image.
:param src: Source image. Supports ``CV_8U``, ``CV_16U``, ``CV_32S`` or ``CV_32F`` depth and 1, 3 or 4 channels. :param src: Source image. Supports ``CV_8U``, ``CV_16U``, ``CV_32S``, or ``CV_32F`` depth and 1, 3, or 4 channels.
:param dst: Destination image; will have size ``dsize`` and the same type as ``src``. :param dst: Destination image. The size is ``dsize`` . The type is the same as ``src`` .
:param M: :math:`2 \times 3` transformation matrix. :param M: *3x3* transformation matrix.
:param dsize: Size of the destination image. :param dsize: Size of the destination image.
:param flags: Combination of interpolation methods, see :c:func:`resize`, and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation (:math:`dst \rightarrow src` ). Supports only ``INTER_NEAREST``, ``INTER_LINEAR`` and ``INTER_CUBIC`` interpolation methods. :param flags: Combination of interpolation methods (see :func:`resize` ) and the optional flag ``WARP_INVERSE_MAP`` specifying that ``M`` is the inverse transformation (``dst => src``). Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` interpolation methods are supported.
See also: :c:func:`warpPerspective`.
See Also:
:func:`warpPerspective` .
.. index:: gpu::rotate .. index:: gpu::rotate
@ -516,21 +507,20 @@ gpu::rotate
:param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` types. :param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` types.
:param dst: Destination image; will have size ``dsize`` and the same type as ``src``. :param dst: Destination image. The size is ``dsize`` . The type is the same as ``src`` .
:param dsize: Size of the destination image. :param dsize: Size of the destination image.
:param angle: Angle of rotation in degrees. :param angle: Angle of rotation in degrees.
:param xShift: Shift along horizontal axis. :param xShift: Shift along the horizontal axis.
:param yShift: Shift along vertical axis. :param yShift: Shift along the vertical axis.
:param interpolation: Interpolation method. Supports only ``INTER_NEAREST``, ``INTER_LINEAR`` and ``INTER_CUBIC``.
See also: :cpp:func:`gpu::warpAffine`.
:param interpolation: Interpolation method. Only ``INTER_NEAREST``, ``INTER_LINEAR``, and ``INTER_CUBIC`` are supported.
See Also:
:func:`gpu::warpAffine` .
.. index:: gpu::copyMakeBorder .. index:: gpu::copyMakeBorder
@ -538,38 +528,34 @@ gpu::copyMakeBorder
----------------------- -----------------------
.. cpp:function:: void gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar()) .. cpp:function:: void gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar())
Copies 2D array to a larger destination array and pads borders with the given constant. Copies a 2D array to a larger destination array and pads borders with the given constant.
:param src: Source image. Supports ``CV_8UC1``, ``CV_8UC4``, ``CV_32SC1`` and ``CV_32FC1`` types. :param src: Source image. ``CV_8UC1``, ``CV_8UC4``, ``CV_32SC1``, and ``CV_32FC1`` types are supported.
:param dst: The destination image; will have the same type as ``src`` and the size ``Size(src.cols+left+right, src.rows+top+bottom)``. :param dst: Destination image. The type is the same as ``src`` . The size is ``Size(src.cols+left+right, src.rows+top+bottom)`` .
:param top, bottom, left, right: Specify how much pixels in each direction from the source image rectangle one needs to extrapolate, e.g. ``top=1, bottom=1, left=1, right=1`` mean that 1 pixel-wide border needs to be built. :param top, bottom, left, 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 value: Border value. :param value: Border value.
See also: :c:func:`copyMakeBorder`. See Also:
:func:`copyMakeBorder`
.. index:: gpu::rectStdDev .. index:: gpu::rectStdDev
gpu::rectStdDev gpu::rectStdDev
------------------- -------------------
.. cpp:function:: void gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect) .. cpp:function:: void gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect)
Computes standard deviation of integral images. Computes a standard deviation of integral images.
:param src: Source image. Supports only ``CV_32SC1`` type. :param src: Source image. Only the ``CV_32SC1`` type is supported.
:param sqr: Squared source image. Supports only ``CV_32FC1`` type. :param sqr: Squared source image. Only the ``CV_32FC1`` type is supported.
:param dst: Destination image; will have the same type and the same size as ``src``. :param dst: Destination image. The type and size is the same as ``src`` .
:param rect: Rectangular window. :param rect: Rectangular window.
.. index:: gpu::evenLevels .. index:: gpu::evenLevels
gpu::evenLevels gpu::evenLevels
@ -578,16 +564,14 @@ gpu::evenLevels
Computes levels with even distribution. Computes levels with even distribution.
:param levels: Destination array. ``levels`` will have 1 row and ``nLevels`` cols and ``CV_32SC1`` type. :param levels: Destination array. ``levels`` has 1 row, ``nLevels`` columns, and the ``CV_32SC1`` type.
:param nLevels: Number of levels being computed. ``nLevels`` must be at least 2. :param nLevels: Number of computed levels. ``nLevels`` must be at least 2.
:param lowerLevel: Lower boundary value of the lowest level. :param lowerLevel: Lower boundary value of the lowest level.
:param upperLevel: Upper boundary value of the greatest level. :param upperLevel: Upper boundary value of the greatest level.
.. index:: gpu::histEven .. index:: gpu::histEven
gpu::histEven gpu::histEven
@ -596,19 +580,17 @@ gpu::histEven
.. cpp:function:: void gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]) .. cpp:function:: void gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4])
Calculates histogram with evenly distributed bins. Calculates a histogram with evenly distributed bins.
:param src: Source image. Supports ``CV_8U``, ``CV_16U`` or ``CV_16S`` depth and 1 or 4 channels. For four-channel image all channels are processed separately. :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.
:param hist: Destination histogram. Will have one row, ``histSize`` cols and ``CV_32S`` type. :param hist: Destination histogram with one row, ``histSize`` columns, and the ``CV_32S`` type.
:param histSize: Size of histogram. :param histSize: Size of the histogram.
:param lowerLevel: Lower boundary of lowest level bin.
:param upperLevel: Upper boundary of highest level bin.
:param lowerLevel: Lower boundary of lowest-level bin.
:param upperLevel: Upper boundary of highest-level bin.
.. index:: gpu::histRange .. index:: gpu::histRange
@ -618,10 +600,11 @@ gpu::histRange
.. cpp:function:: void gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]) .. cpp:function:: void gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])
Calculates histogram with bins determined by levels array. Calculates a histogram with bins determined by the `levels` array.
:param src: Source image. Supports ``CV_8U``, ``CV_16U`` or ``CV_16S`` depth and 1 or 4 channels. For four-channel image all channels are processed separately. :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.
:param hist: Destination histogram. Will have one row, ``(levels.cols-1)`` cols and ``CV_32SC1`` type. :param hist: Destination histogram with one row, ``(levels.cols-1)`` columns, and the ``CV_32SC1`` type.
:param levels: Number of levels in the histogram.
:param levels: Number of levels in histogram.

View File

@ -1,41 +1,33 @@
Initalization and Information Initalization and Information
============================= =============================
.. highlight:: cpp .. highlight:: cpp
.. index:: gpu::getCudaEnabledDeviceCount .. index:: gpu::getCudaEnabledDeviceCount
gpu::getCudaEnabledDeviceCount gpu::getCudaEnabledDeviceCount
---------------------------------- ----------------------------------
.. cpp:function:: int gpu::getCudaEnabledDeviceCount()
Returns number of CUDA-enabled devices installed. It is to be used before any other GPU functions calls. If OpenCV is compiled without GPU support this function returns 0.
.. cpp:function:: int getCudaEnabledDeviceCount()
Returns the number of installed CUDA-enabled devices. Use this function before any other GPU functions calls. If OpenCV is compiled without GPU support, this function returns 0.
.. index:: gpu::setDevice .. index:: gpu::setDevice
gpu::setDevice gpu::setDevice
------------------ ------------------
.. cpp:function:: void gpu::setDevice(int device) .. cpp:function:: void setDevice(int device)
Sets device and initializes it for the current thread. Call of this function can be omitted, but in this case a default device will be initialized on fist GPU usage.
:param device: index of GPU device in system starting with 0.
Sets a device and initializes it for the current thread. If call of this function is omitted, a default device is initialized at the fist GPU usage.
:param device: System index of a GPU device starting with 0.
.. index:: gpu::getDevice .. index:: gpu::getDevice
gpu::getDevice gpu::getDevice
------------------ ------------------
.. cpp:function:: int gpu::getDevice() .. cpp:function:: int getDevice()
Returns the current device index, which was set by :cpp:func:`gpu::setDevice` or initialized by default.
Returns the current device index that was set by {gpu::getDevice} or initialized by default.
.. index:: gpu::GpuFeature .. index:: gpu::GpuFeature
@ -43,7 +35,8 @@ gpu::GpuFeature
--------------- ---------------
.. c:type:: gpu::GpuFeature .. c:type:: gpu::GpuFeature
GPU compute features. :: This class provides GPU computing features.
::
enum GpuFeature enum GpuFeature
{ {
@ -54,16 +47,16 @@ GPU compute features. ::
}; };
.. index:: gpu::DeviceInfo .. index:: gpu::DeviceInfo
gpu::DeviceInfo gpu::DeviceInfo
--------------- ---------------
.. cpp:class:: gpu::DeviceInfo .. cpp:class:: gpu::DeviceInfo
This class provides functionality for querying the specified GPU properties. :: This class provides functionality for querying the specified GPU properties.
::
class DeviceInfo class CV_EXPORTS DeviceInfo
{ {
public: public:
DeviceInfo(); DeviceInfo();
@ -84,20 +77,18 @@ This class provides functionality for querying the specified GPU properties. ::
}; };
.. index:: gpu::DeviceInfo::DeviceInfo .. index:: gpu::DeviceInfo::DeviceInfo
.. Comment: two lines below look like a bug
gpu::DeviceInfo::DeviceInfo gpu::DeviceInfo::DeviceInfo
------------------------------- ------------------------------- ``_``
.. cpp:function:: gpu::DeviceInfo::DeviceInfo() .. cpp:function:: gpu::DeviceInfo::DeviceInfo()
.. cpp:function:: gpu::DeviceInfo::DeviceInfo(int device_id) .. cpp:function:: gpu::DeviceInfo::DeviceInfo(int device_id)
Constructs :cpp:class:`gpu::DeviceInfo` object for the specified device. If ``device_id`` parameter is missed it constructs object for the current device. Constructs the ``DeviceInfo`` object for the specified device. If ``device_id`` parameter is missed, it constructs an object for the current device.
:param device_id: Index of the GPU device in system starting with 0.
:param device_id: System index of the GPU device starting with 0.
.. index:: gpu::DeviceInfo::name .. index:: gpu::DeviceInfo::name
@ -107,8 +98,6 @@ gpu::DeviceInfo::name
Returns the device name. Returns the device name.
.. index:: gpu::DeviceInfo::majorVersion .. index:: gpu::DeviceInfo::majorVersion
gpu::DeviceInfo::majorVersion gpu::DeviceInfo::majorVersion
@ -117,8 +106,6 @@ gpu::DeviceInfo::majorVersion
Returns the major compute capability version. Returns the major compute capability version.
.. index:: gpu::DeviceInfo::minorVersion .. index:: gpu::DeviceInfo::minorVersion
gpu::DeviceInfo::minorVersion gpu::DeviceInfo::minorVersion
@ -127,8 +114,6 @@ gpu::DeviceInfo::minorVersion
Returns the minor compute capability version. Returns the minor compute capability version.
.. index:: gpu::DeviceInfo::multiProcessorCount .. index:: gpu::DeviceInfo::multiProcessorCount
gpu::DeviceInfo::multiProcessorCount gpu::DeviceInfo::multiProcessorCount
@ -137,8 +122,6 @@ gpu::DeviceInfo::multiProcessorCount
Returns the number of streaming multiprocessors. Returns the number of streaming multiprocessors.
.. index:: gpu::DeviceInfo::freeMemory .. index:: gpu::DeviceInfo::freeMemory
gpu::DeviceInfo::freeMemory gpu::DeviceInfo::freeMemory
@ -147,8 +130,6 @@ gpu::DeviceInfo::freeMemory
Returns the amount of free memory in bytes. Returns the amount of free memory in bytes.
.. index:: gpu::DeviceInfo::totalMemory .. index:: gpu::DeviceInfo::totalMemory
gpu::DeviceInfo::totalMemory gpu::DeviceInfo::totalMemory
@ -157,19 +138,15 @@ gpu::DeviceInfo::totalMemory
Returns the amount of total memory in bytes. Returns the amount of total memory in bytes.
.. index:: gpu::DeviceInfo::supports .. index:: gpu::DeviceInfo::supports
gpu::DeviceInfo::supports gpu::DeviceInfo::supports
----------------------------- -----------------------------
.. cpp:function:: bool gpu::DeviceInfo::supports(GpuFeature feature) .. cpp:function:: bool gpu::DeviceInfo::supports(GpuFeature feature)
Returns true if the device has the given GPU feature, otherwise false. Provides information on GPU feature support. This function returns true if the device has the specified GPU feature, otherwise returns false.
:param feature: Feature to be checked. See :c:type:`gpu::GpuFeature`.
:param feature: Feature to be checked. See ?.
.. index:: gpu::DeviceInfo::isCompatible .. index:: gpu::DeviceInfo::isCompatible
@ -177,25 +154,25 @@ gpu::DeviceInfo::isCompatible
--------------------------------- ---------------------------------
.. cpp:function:: bool gpu::DeviceInfo::isCompatible() .. cpp:function:: bool gpu::DeviceInfo::isCompatible()
Returns true if the GPU module can be run on the specified device, otherwise false. Checks the GPU module and device compatibility. This function returns true if the GPU module can be run on the specified device, otherwise returns false.
.. index:: gpu::TargetArchs .. index:: gpu::TargetArchs
.. _gpu::TargetArchs:
gpu::TargetArchs gpu::TargetArchs
---------------- ----------------
.. cpp:class:: gpu::TargetArchs .. cpp:class:: gpu::TargetArchs
This class provides functionality (as set of static methods) for checking which NVIDIA card architectures the GPU module was built for. This class provides a set of static methods to check what NVIDIA card architecture the GPU module was built for.
The following method checks whether the module was built with the support of the given feature: The following method checks whether the module was built with the support of the given feature:
.. cpp:function:: static bool gpu::TargetArchs::builtWith(GpuFeature feature) .. cpp:function:: static bool gpu::TargetArchs::builtWith(GpuFeature feature)
:param feature: Feature to be checked. See :c:type:`gpu::GpuFeature`. :param feature: Feature to be checked. See ?.
There are a set of methods for checking whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s): There is a set of methods to check whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s):
.. cpp:function:: static bool gpu::TargetArchs::has(int major, int minor) .. cpp:function:: static bool gpu::TargetArchs::has(int major, int minor)
@ -211,14 +188,13 @@ There are a set of methods for checking whether the module contains intermediate
.. cpp:function:: static bool gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor) .. cpp:function:: static bool gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
:param major: Major compute capability version. * **major** Major compute capability version.
:param minor: Minor compute capability version. * **minor** Minor compute capability version.
According to the CUDA C Programming Guide Version 3.2: "PTX code produced for some specific compute capability can always be compiled to binary code of greater or equal compute capability". According to the CUDA C Programming Guide Version 3.2: "PTX code produced for some specific compute capability can always be compiled to binary code of greater or equal compute capability".
.. index:: gpu::MultiGpuManager .. index:: gpu::MultiGpuManager
gpu::MultiGpuManager gpu::MultiGpuManager
@ -296,3 +272,4 @@ gpu::MultiGpuManager::gpuOff
.. cpp:function:: void gpu::MultiGpuManager::gpuOff() .. cpp:function:: void gpu::MultiGpuManager::gpuOff()
Finishes the piece of work on the current GPU. Finishes the piece of work on the current GPU.