@@ -3,13 +3,13 @@ Camera Calibration and 3d Reconstruction
...
@@ -3,13 +3,13 @@ Camera Calibration and 3d Reconstruction
.. highlight:: cpp
.. highlight:: cpp
.. index:: gpu::StereoBM_GPU
.. _gpu::StereoBM_GPU:
.. index:: gpu::StereoBM_GPU
gpu::StereoBM_GPU
gpu::StereoBM_GPU
-----------------
-----------------
.. c:type:: gpu::StereoBM_GPU
.. cpp:class:: gpu::StereoBM_GPU
The class for computing stereo correspondence using block matching algorithm. ::
The class for computing stereo correspondence using block matching algorithm. ::
...
@@ -40,22 +40,24 @@ The class for computing stereo correspondence using block matching algorithm. ::
...
@@ -40,22 +40,24 @@ 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
.. math::
: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
\sum HorizontalGradiensInWindow(x, y, winSize) < (winSize \cdot winSize) \cdot avergeTexThreshold
:math:`\sum HorizontalGradiensInWindow(x, y, winSize) < (winSize \cdot winSize) \cdot avergeTexThreshold` i.e. input left image is low textured.
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
.. _gpu::StereoBeliefPropagation:
.. index:: gpu::StereoBeliefPropagation
gpu::StereoBeliefPropagation
gpu::StereoBeliefPropagation
----------------------------
----------------------------
.. c:type:: gpu::StereoBeliefPropagation
.. cpp:class:: gpu::StereoBeliefPropagation
The class for computing stereo correspondence using belief propagation algorithm. ::
The class for computing stereo correspondence using belief propagation algorithm. ::
...
@@ -148,34 +150,33 @@ The class for computing stereo correspondence using belief propagation algorithm
...
@@ -148,34 +150,33 @@ 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
felzenszwalb_bp
. It can compute own data cost (using truncated linear model) or use user-provided data cost.
**Please note:** ``StereoBeliefPropagation`` requires a lot of memory:
**Please note:** ``StereoBeliefPropagation`` requires a lot of memory:
.. c:function:: StereoBeliefPropagation::StereoBeliefPropagation( int ndisp = DEFAULT_NDISP, int iters = DEFAULT_ITERS, int levels = DEFAULT_LEVELS, int msg_type = CV_32F)
.. cpp:function:: gpu::StereoBeliefPropagation::StereoBeliefPropagation(int ndisp = DEFAULT_NDISP, int iters = DEFAULT_ITERS, int levels = DEFAULT_LEVELS, int msg_type = CV_32F)
.. c:function:: 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)
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.].
felzenszwalb_bp
.
By default ``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 perfomance. To avoid overflow in this case, the parameters must satisfy
.. math::
.. math::
10 \cdot 2^{levels-1} \cdot max \_ data \_ term < SHRT \_ MAX
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, itersand levels) for specified image size (widthand height).
The stereo correspondence operator. Finds the disparity for the specified rectified stereo pair or data cost.
The stereo correspondence operator. Finds the disparity for the specified rectified stereo pair or data cost.
:param left: Left image; supports ``CV_8UC1`` , ``CV_8UC3`` and ``CV_8UC4`` types.
:param left: Left image; supports ``CV_8UC1``, ``CV_8UC3`` and ``CV_8UC4`` types.
:param right: Right image with the same size and the same type as the left one.
:param right: Right image with the same size and the same type as the left one.
: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 ``disparity`` is empty output type will be ``CV_16SC1``, otherwise output type will be ``disparity.type()``.
:param stream: Stream for the asynchronous version.
:param stream: Stream for the asynchronous version.
* **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. It must have ``msg_type`` type and :math:`\texttt{imgRows} \cdot \texttt{ndisp} \times \texttt{imgCols}` size.
* **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 ``disparity`` is empty output type will be ``CV_16SC1``, otherwise output type will be ``disparity.type()``.
:param stream: Stream for the asynchronous version.
* **stream** Stream for the asynchronous version.
.. index:: gpu::StereoConstantSpaceBP
.. _gpu::StereoConstantSpaceBP:
.. index:: gpu::StereoConstantSpaceBP
gpu::StereoConstantSpaceBP
gpu::StereoConstantSpaceBP
--------------------------
--------------------------
.. c:type:: gpu::StereoConstantSpaceBP
.. cpp:class:: gpu::StereoConstantSpaceBP
The class for computing stereo correspondence using constant space belief propagation algorithm. ::
The class for computing stereo correspondence using constant space belief propagation algorithm. ::
...
@@ -309,19 +312,19 @@ The class for computing stereo correspondence using constant space belief propag
...
@@ -309,19 +312,19 @@ The class for computing stereo correspondence using constant space belief propag
};
};
The class implements Q. Yang algorithm
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.
qx_csbp
. ``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.
For more details please see [Q. Yang, L. Wang, and N. Ahuja. A constant-space belief propagation algorithm for stereo matching. In CVPR, 2010].
qx_csbp
.
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
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
.. math::
.. math::
10 \cdot 2^{levels-1} \cdot max \_ data \_ term < SHRT \_ MAX
.. c:function:: void 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).
The stereo correspondence operator. Finds the disparity for the specified rectified stereo pair.
The stereo correspondence operator. Finds the disparity for the specified rectified stereo pair.
:param left: Left image; supports ``CV_8UC1`` , ``CV_8UC3`` and ``CV_8UC4`` types.
:param left: Left image; supports ``CV_8UC1``, ``CV_8UC3`` and ``CV_8UC4`` types.
:param right: Right image with the same size and the same type as the left one.
:param right: Right image with the same size and the same type as the left one.
: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 ``disparity`` is empty output type will be ``CV_16SC1``, otherwise output type will be ``disparity.type()``.
:param stream: Stream for the asynchronous version.
:param stream: Stream for the asynchronous version.
.. index:: gpu::DisparityBilateralFilter
.. _gpu::DisparityBilateralFilter:
.. index:: gpu::DisparityBilateralFilter
gpu::DisparityBilateralFilter
gpu::DisparityBilateralFilter
-----------------------------
-----------------------------
.. c:type:: 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 CV_EXPORTS DisparityBilateralFilter
class DisparityBilateralFilter
{
{
public:
public:
enum { DEFAULT_NDISP = 64 };
enum { DEFAULT_NDISP = 64 };
...
@@ -423,19 +427,19 @@ The class for disparity map refinement using joint bilateral filtering. ::
...
@@ -423,19 +427,19 @@ The class for disparity map refinement using joint bilateral filtering. ::
};
};
The class implements Q. Yang algorithm
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].
.. c:function:: DisparityBilateralFilter::DisparityBilateralFilter( int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS)
.. cpp:function:: gpu::DisparityBilateralFilter::DisparityBilateralFilter(int ndisp = DEFAULT_NDISP, int radius = DEFAULT_RADIUS, int iters = DEFAULT_ITERS)
.. c:function:: DisparityBilateralFilter::DisparityBilateralFilter( int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range)
.. cpp:function:: gpu::DisparityBilateralFilter::DisparityBilateralFilter(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, float sigma_range)
:param disp: Input disparity image; supports ``CV_8U`` and ``CV_16S`` types.
:param disp: Input disparity image; supports ``CV_8U`` and ``CV_16S`` types.
: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 :ref:`StereoRectify` .
:param Q: :math:`4 \times 4` perspective transformation matrix that can be obtained via :c:func:`stereoRectify`.
:param stream: Stream for the asynchronous version.
:param stream: Stream for the asynchronous version.
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 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. ::
...
@@ -36,16 +36,19 @@ This is a simple lightweight class that encapsulate pitched memory on GPU. It is
...
@@ -36,16 +36,19 @@ This is a simple lightweight class that encapsulate pitched memory on GPU. It is
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const;
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const;
};
};
typedef DevMem2D_<unsigned char> DevMem2D;
typedef DevMem2D_<float> DevMem2Df;
typedef DevMem2D_<int> DevMem2Di;
.. index:: gpu::PtrStep\_
.. gpu::PtrStep\_:
.. index:: gpu::PtrStep_
gpu::PtrStep\_
gpu::PtrStep\_
--------------
--------------
.. c:type:: gpu::PtrStep\_
.. cpp:class:: gpu::PtrStep_
This is structure is similar to 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 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. ::
template<typename T> struct PtrStep_
template<typename T> struct PtrStep_
{
{
...
@@ -63,16 +66,19 @@ This is structure is similar to DevMem2D\_ but contains only pointer and row ste
...
@@ -63,16 +66,19 @@ This is structure is similar to DevMem2D\_ but contains only pointer and row ste
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const;
__CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const;
};
};
typedef PtrStep_<unsigned char> PtrStep;
typedef PtrStep_<float> PtrStepf;
typedef PtrStep_<int> PtrStepi;
.. index:: gpu::PtrElemStrp\_
.. gpu::PtrElemStrp\_:
gpu::PtrElemStrp\_
.. index:: gpu::PtrElemStep_
gpu::PtrElemStep\_
------------------
------------------
.. c:type:: gpu::PtrElemStrp\_
.. cpp:class:: gpu::PtrElemStep_
This is structure is similar to 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 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. ::
template<typename T> struct PtrElemStep_ : public PtrStep_<T>
template<typename T> struct PtrElemStep_ : public PtrStep_<T>
{
{
...
@@ -81,23 +87,23 @@ This is structure is similar to DevMem2D_but contains only pointer and row step
...
@@ -81,23 +87,23 @@ This is structure is similar to DevMem2D_but contains only pointer and row step
__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
gpu::GpuMat
gpu::GpuMat
-----------
-----------
.. c:type:: gpu::GpuMat
.. cpp:class:: gpu::GpuMat
The base storage class for GPU memory with reference counting. Its interface is almost
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.
:func:`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
and
so it can be passed to directly to kernel.
**Please note:**
**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. ::
In contrast with
:func:`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. ::
class CV_EXPORTS GpuMat
class GpuMat
{
{
public:
public:
//! default constructor
//! default constructor
...
@@ -129,20 +135,19 @@ In contrast with
...
@@ -129,20 +135,19 @@ In contrast with
};
};
**Please note:**
**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.
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.
See also: :c:type:`Mat`.
See also:
:func:`Mat`
.. index:: gpu::CudaMem
.. index:: gpu::CudaMem
gpu::CudaMem
gpu::CudaMem
------------
------------
.. c:type:: 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
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:
:func:`Mat` -like but with additional memory type parameter:
* ``ALLOC_PAGE_LOCKED`` Set page locked memory type, used commonly for fast and asynchronous upload/download data from/to GPU.
* ``ALLOC_PAGE_LOCKED`` Set page locked memory type, used commonly for fast and asynchronous upload/download data from/to GPU.
...
@@ -150,9 +155,9 @@ This is a class with reference counting that wraps special memory type allocatio
...
@@ -150,9 +155,9 @@ This is a class with reference counting that wraps special memory type allocatio
* ``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.
* ``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.
Please note that 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". ::
**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 CV_EXPORTS CudaMem
class CudaMem
{
{
public:
public:
enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2,
enum { ALLOC_PAGE_LOCKED = 1, ALLOC_ZEROCOPY = 2,
...
@@ -182,53 +187,54 @@ Please note that allocation size of such memory types is usually limited. For mo
...
@@ -182,53 +187,54 @@ Please note that allocation size of such memory types is usually limited. For mo
};
};
.. index:: gpu::CudaMem::createMatHeader
.. index:: gpu::CudaMem::createMatHeader
gpu::CudaMem::createMatHeader
gpu::CudaMem::createMatHeader
---------------------------------
---------------------------------
.. cpp:function:: Mat CudaMem::createMatHeader() const
.. cpp:function:: Mat gpu::CudaMem::createMatHeader() 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 hardware (laptops often share video and CPU memory, so address spaces can be mapped, and that eliminates extra copy).
Maps CPU memory to GPU address space and creates header without reference counting for it. This can be done only if memory was allocated with ALLOCZEROCOPYflag 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).
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 ALLOCZEROCOPYmemory allocation
.. index:: gpu::Stream
.. index:: gpu::Stream
gpu::Stream
gpu::Stream
-----------
-----------
.. c:type:: gpu::Stream
.. cpp:class:: gpu::Stream
This class encapsulated queue of the asynchronous calls. Some functions have overloads with additional
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`.
:func:`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
:func:`gpu::Stream::queryIfComplete()` . Asynchronous upload/download have to be performed from/to page-locked buffers, i.e. using
:func:`gpu::CudaMem` or
:func:`Mat` header that points to a region of
:func:`gpu::CudaMem` .
**Please note the limitation**
**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. ::
: 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. ::
class CV_EXPORTS Stream
class Stream
{
{
public:
public:
Stream();
Stream();
...
@@ -263,44 +269,47 @@ This class encapsulated queue of the asynchronous calls. Some functions have ove
...
@@ -263,44 +269,47 @@ This class encapsulated queue of the asynchronous calls. Some functions have ove
Blocks until all operations in the stream are complete.
Blocks until all operations in the stream are complete.
.. index:: gpu::StreamAccessor
.. _gpu::StreamAccessor:
.. index:: gpu::StreamAccessor
gpu::StreamAccessor
gpu::StreamAccessor
-------------------
-------------------
.. c:type:: gpu::StreamAccessor
.. c:type:: gpu::StreamAccessor
This class provides possibility to get ``cudaStream_t`` from
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. ::
:func:`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. ::
.. c:function:: void 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 continuous matrix in GPU memory.
...
@@ -310,23 +319,25 @@ gpu::createContinuous
...
@@ -310,23 +319,25 @@ 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. Will be only reshaped if it has proper type and area (``rows`` :math:`\times` ``cols``).
Also the following wrappers are available:
Also the following wrappers are available:
.. c:function:: GpuMat createContinuous(int rows, int cols, int type)
.. cpp:function:: GpuMat gpu::createContinuous(int rows, int cols, int type)
.. c:function:: void createContinuous(Size size, int type, GpuMat\& m)
.. cpp:function:: void gpu::createContinuous(Size size, int type, GpuMat& m)
.. c:function:: GpuMat 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, i.e. wuthout gaps in the end of each row.
.. index:: gpu::ensureSizeIsEnough
.. index:: gpu::ensureSizeIsEnough
gpu::ensureSizeIsEnough
gpu::ensureSizeIsEnough
---------------------------
---------------------------
.. c:function:: void 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.
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.
...
@@ -340,5 +351,4 @@ gpu::ensureSizeIsEnough
...
@@ -340,5 +351,4 @@ gpu::ensureSizeIsEnough
Also the following wrapper is available:
Also the following wrapper is available:
.. c:function:: void ensureSizeIsEnough(Size size, int type, GpuMat\& m)
.. cpp:function:: void gpu::ensureSizeIsEnough(Size size, int type, GpuMat& m)
@@ -3,13 +3,13 @@ Feature Detection and Description
...
@@ -3,13 +3,13 @@ Feature Detection and Description
.. highlight:: cpp
.. highlight:: cpp
.. index:: gpu::SURF_GPU
.. gpu::SURF_GPU:
.. index:: gpu::SURF_GPU
gpu::SURF_GPU
gpu::SURF_GPU
-------------
-------------
.. c:type:: gpu::SURF_GPU
.. cpp:class:: gpu::SURF_GPU
Class for extracting Speeded Up Robust Features from an image. ::
Class for extracting Speeded Up Robust Features from an image. ::
...
@@ -20,7 +20,8 @@ Class for extracting Speeded Up Robust Features from an image. ::
...
@@ -20,7 +20,8 @@ Class for extracting Speeded Up Robust Features from an image. ::
SURF_GPU();
SURF_GPU();
//! the full constructor taking all the necessary parameters
//! the full constructor taking all the necessary parameters
explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f);
int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f,
bool _upright = false);
//! returns the descriptor size in float's (64 or 128)
//! returns the descriptor size in float's (64 or 128)
int descriptorSize() const;
int descriptorSize() const;
...
@@ -61,6 +62,8 @@ Class for extracting Speeded Up Robust Features from an image. ::
...
@@ -61,6 +62,8 @@ Class for extracting Speeded Up Robust Features from an image. ::
//! max keypoints = keypointsRatio * img.size().area()
//! max keypoints = keypointsRatio * img.size().area()
float keypointsRatio;
float keypointsRatio;
bool upright;
GpuMat sum, mask1, maskSum, intBuffer;
GpuMat sum, mask1, maskSum, intBuffer;
GpuMat det, trace;
GpuMat det, trace;
...
@@ -70,25 +73,21 @@ Class for extracting Speeded Up Robust Features from an image. ::
...
@@ -70,25 +73,21 @@ Class for extracting Speeded Up Robust Features from an image. ::
GpuMat keypointsBuffer;
GpuMat keypointsBuffer;
};
};
The class ``SURF_GPU`` implements Speeded Up Robust Features descriptor. There is fast multi-scale Hessian keypoint detector that can be used to find the keypoints (which is the default option), but the descriptors can be also computed for the user-specified keypoints. Supports only 8 bit grayscale images.
The class ``SURF_GPU`` implements Speeded Up Robust Features descriptor. There is fast multi-scale Hessian keypoint detector that can be used to find the keypoints (which is the default option), but the descriptors can be also computed for the user-specified keypoints. Supports only 8 bit grayscale images.
The class ``SURF_GPU`` can store results to GPU and CPU memory and provides functions to convert results between CPU and GPU version ( ``uploadKeypoints``,``downloadKeypoints``,``downloadDescriptors`` ). CPU results has the same format as ``SURF``
The class ``SURF_GPU`` can store results to GPU and CPU memory and provides functions to convert results between CPU and GPU version (``uploadKeypoints``, ``downloadKeypoints``, ``downloadDescriptors``). CPU results has the same format as :c:type:`SURF` results. GPU results are stored to :cpp:class:`gpu::GpuMat`. ``keypoints`` matrix is one row matrix with ``CV_32FC6`` type. It contains 6 float values per feature: ``x, y, laplacian, size, dir, hessian``. ``descriptors`` matrix is ``nFeatures`` :math:`\times` ``descriptorSize`` matrix with ``CV_32FC1`` type.
results. GPU results are stored to ``GpuMat`` . ``keypoints`` matrix is one row matrix with ``CV_32FC6`` type. It contains 6 float values per feature: ``x, y, laplacian, size, dir, hessian`` . ``descriptors`` matrix is
:math:`\texttt{nFeatures} \times \texttt{descriptorSize}` matrix with ``CV_32FC1`` type.
The class ``SURF_GPU`` uses some buffers and provides access to it. All buffers can be safely released between function calls.
The class ``SURF_GPU`` uses some buffers and provides access to it. All buffers can be safely released between function calls.
See also:
See also: :c:type:`SURF`.
.
.. index:: gpu::BruteForceMatcher_GPU
.. gpu::BruteForceMatcher_GPU:
.. index:: gpu::BruteForceMatcher_GPU
gpu::BruteForceMatcher_GPU
gpu::BruteForceMatcher_GPU
--------------------------
--------------------------
.. c:type:: gpu::BruteForceMatcher_GPU
.. cpp:class:: gpu::BruteForceMatcher_GPU
Brute-force descriptor matcher. For each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each one. This descriptor matcher supports masking permissible matches between descriptor sets. ::
Brute-force descriptor matcher. For each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each one. This descriptor matcher supports masking permissible matches between descriptor sets. ::
...
@@ -174,182 +173,171 @@ Brute-force descriptor matcher. For each descriptor in the first set, this match
...
@@ -174,182 +173,171 @@ Brute-force descriptor matcher. For each descriptor in the first set, this match
std::vector<GpuMat> trainDescCollection;
std::vector<GpuMat> trainDescCollection;
};
};
The class ``BruteForceMatcher_GPU`` has the similar interface to class :c:type:`DescriptorMatcher`. It has two groups of match methods: for matching descriptors of one image with other image or with image set. Also all functions have alternative: save results to GPU memory or to CPU memory.
The class ``BruteForceMatcher_GPU`` has the similar interface to class. It has two groups of match methods: for matching descriptors of one image with other image or with image set. Also all functions have alternative: save results to GPU memory or to CPU memory. ``Distance`` template parameter is kept for CPU/GPU interfaces similarity. ``BruteForceMatcher_GPU`` supports only ``L1<float>`` and ``L2<float>`` distance types.
``Distance`` template parameter is kept for CPU/GPU interfaces similarity. ``BruteForceMatcher_GPU`` supports only ``L1<float>`` and ``L2<float>`` distance types.
.. index:: gpu::BruteForceMatcher_GPU::match
See also: :c:type:`DescriptorMatcher`, :c:type:`BruteForceMatcher`.
Finds the best match for each query descriptor. Results will be stored to GPU memory.
Finds the best match for each query descriptor. Results will be stored to GPU memory.
{Query set of descriptors.}
:param queryDescs: Query set of descriptors.
{Train set of descriptors. This will not be added to train descriptors collection stored in class object.}
{One row ``CV_32SC1`` matrix. Will contain the best train index for each query. If some query descriptors are masked out in ``mask`` it will contain -1.}
:param trainDescs: Train set of descriptors. This will not be added to train descriptors collection stored in class object.
{One row ``CV_32FC1`` matrix. Will contain the best distance for each query. If some query descriptors are masked out in ``mask`` it will contain ``FLT_MAX`` .}
:param trainIdx: One row ``CV_32SC1`` matrix. Will contain the best train index for each query. If some query descriptors are masked out in ``mask`` it will contain -1.
:param distance: One row ``CV_32FC1`` matrix. Will contain the best distance for each query. If some query descriptors are masked out in ``mask`` it will contain ``FLT_MAX``.
:param mask: Mask specifying permissible matches between input query and train matrices of descriptors.
:param mask: Mask specifying permissible matches between input query and train matrices of descriptors.
Find the best match for each query descriptor from train collection. Results will be stored to GPU memory.
Find the best match for each query descriptor from train collection. Results will be stored to GPU memory.
{Query set of descriptors.}
:param queryDescs: Query set of descriptors.
{ ``GpuMat`` containing train collection. It can be obtained from train descriptors collection that was set using ``add`` method by
. Or it can contain user defined collection. It must be one row matrix, each element is a ``DevMem2D`` that points to one train descriptors matrix.}
{One row ``CV_32SC1`` matrix. Will contain the best train index for each query. If some query descriptors are masked out in ``maskCollection`` it will contain -1.}
{One row ``CV_32SC1`` matrix. Will contain image train index for each query. If some query descriptors are masked out in ``maskCollection`` it will contain -1.}
{One row ``CV_32FC1`` matrix. Will contain the best distance for each query. If some query descriptors are masked out in ``maskCollection`` it will contain ``FLT_MAX`` .}
:param maskCollection: ``GpuMat`` containing set of masks. It can be obtained from ``std::vector<GpuMat>`` by . Or it can contain user defined mask set. It must be empty matrix or one row matrix, each element is a ``PtrStep`` that points to one mask.
:param trainCollection: :cpp:class:`gpu::GpuMat` containing train collection. It can be obtained from train descriptors collection that was set using ``add`` method by :cpp:func:`gpu::BruteForceMatcher_GPU::makeGpuCollection`. Or it can contain user defined collection. It must be one row matrix, each element is a :cpp:class:`gpu::DevMem2D_` that points to one train descriptors matrix.
:param trainIdx: One row ``CV_32SC1`` matrix. Will contain the best train index for each query. If some query descriptors are masked out in ``maskCollection`` it will contain -1.
:param imgIdx: One row ``CV_32SC1`` matrix. Will contain image train index for each query. If some query descriptors are masked out in ``maskCollection`` it will contain -1.
:param distance: One row ``CV_32FC1`` matrix. Will contain the best distance for each query. If some query descriptors are masked out in ``maskCollection`` it will contain ``FLT_MAX``.
:param maskCollection: :cpp:class:`gpu::GpuMat` containing set of masks. It can be obtained from ``vector<GpuMat>`` by :cpp:func:`gpu::BruteForceMatcher_GPU::makeGpuCollection`. Or it can contain user defined mask set. It must be empty matrix or one row matrix, each element is a :cpp:class:`gpu::PtrStep_` that points to one mask.
Downloads trainIdx, imgIdxand distancematrices obtained via or to CPU vector with .
Downloads ``trainIdx``, ``imgIdx`` and ``distance`` matrices obtained via :cpp:func:`gpu::BruteForceMatcher_GPU::matchSingle` or :cpp:func:`gpu::BruteForceMatcher_GPU::matchCollection` to CPU vector with :c:type:`DMatch`.
Finds the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order.
Finds the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order.
Finds the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order. Results will be stored to GPU memory.
:func:`DescriptorMatcher::knnMatch` .
.. index:: gpu::BruteForceMatcher_GPU::knnMatch
:param queryDescs: Query set of descriptors.
.. gpu::BruteForceMatcher_GPU::knnMatch:
:param trainDescs; Train set of descriptors. This will not be added to train descriptors collection stored in class object.
gpu::BruteForceMatcher_GPU::knnMatch
:param trainIdx: Matrix with ``nQueries`` :math:`\times` ``k`` size and ``CV_32SC1`` type. ``trainIdx.at<int>(queryIdx, i)`` will contain index of the i'th best trains. If some query descriptors are masked out in ``mask`` it will contain -1.
Finds the k best matches for each descriptor from a query set with train descriptors. Found k (or less if not possible) matches are returned in distance increasing order. Results will be stored to GPU memory.
:param distance: Matrix with ``nQuery`` :math:`\times` ``k`` and ``CV_32FC1`` type. Will contain distance for each query and the i'th best trains. If some query descriptors are masked out in ``mask`` it will contain ``FLT_MAX``.
{Query set of descriptors.}
:param allDist: Buffer to store all distances between query descriptors and train descriptors. It will have ``nQuery`` :math:`\times` ``nTrain`` size and ``CV_32FC1`` type. ``allDist.at<float>(queryIdx, trainIdx)`` will contain ``FLT_MAX``, if ``trainIdx`` is one from k best, otherwise it will contain distance between ``queryIdx`` and ``trainIdx`` descriptors.
{Train set of descriptors. This will not be added to train descriptors collection stored in class object.}
{Matrix with
:math:`\texttt{nQueries} \times \texttt{k}` size and ``CV_32SC1`` type. ``trainIdx.at<int>(queryIdx, i)`` will contain index of the i'th best trains. If some query descriptors are masked out in ``mask`` it will contain -1.}
{Matrix with
:math:`\texttt{nQuery} \times \texttt{k}` and ``CV_32FC1`` type. Will contain distance for each query and the i'th best trains. If some query descriptors are masked out in ``mask`` it will contain ``FLT_MAX`` .}
{Buffer to store all distances between query descriptors and train descriptors. It will have
:math:`\texttt{nQuery} \times \texttt{nTrain}` size and ``CV_32FC1`` type. ``allDist.at<float>(queryIdx, trainIdx)`` will contain ``FLT_MAX`` , if ``trainIdx`` is one from k best, otherwise it will contain distance between ``queryIdx`` and ``trainIdx`` descriptors.}
:param k: Number of the best matches will be found per each query descriptor (or less if it's not possible).
:param k: Number of the best matches will be found per each query descriptor (or less if it's not possible).
:param mask: Mask specifying permissible matches between input query and train matrices of descriptors.
:param mask: Mask specifying permissible matches between input query and train matrices of descriptors.
Downloads trainIdxand distancematrices obtained via to CPU vector with . If compactResultis true matchesvector will not contain matches for fully masked out query descriptors.
Downloads ``trainIdx`` and ``distance`` matrices obtained via :cpp:func:`gpu::BruteForceMatcher_GPU::knnMatch` to CPU vector with :c:type:`DMatch`. If ``compactResult`` is true ``matches`` vector will not contain matches for fully masked out query descriptors.
Finds the best matches for each query descriptor which have distance less than given threshold. Found matches are returned in distance increasing order.
Finds the best matches for each query descriptor which have distance less than given threshold. Found matches are returned in distance increasing order.
This function works only on devices with Compute Capability
Finds the best matches for each query descriptor which have distance less than given threshold. Results will be stored to GPU memory. Results are not sorted by distance increasing order.
:param trainDescs: Train set of descriptors. This will not be added to train descriptors collection stored in class object.
.. gpu::BruteForceMatcher_GPU::radiusMatch:
:param trainIdx: ``trainIdx.at<int>(queryIdx, i)`` will contain i'th train index ``(i < min(nMatches.at<unsigned int>(0, queryIdx), trainIdx.cols)``. If ``trainIdx`` is empty, it will be created with size ``nQuery`` :math:`\times` ``nTrain``. Or it can be allocated by user (it must have ``nQuery`` rows and ``CV_32SC1`` type). Cols can be less than ``nTrain``, but it can be that matcher won't find all matches, because it haven't enough memory to store results.
gpu::BruteForceMatcher_GPU::radiusMatch
:param nMatches: ``nMatches.at<unsigned int>(0, queryIdx)`` will contain matches count for ``queryIdx``. Carefully, ``nMatches`` can be greater than ``trainIdx.cols`` - it means that matcher didn't find all matches, because it didn't have enough memory.
Finds the best matches for each query descriptor which have distance less than given threshold. Results will be stored to GPU memory.
{Query set of descriptors.}
:param distance: ``distance.at<int>(queryIdx, i)`` will contain i'th distance ``(i < min(nMatches.at<unsigned int>(0, queryIdx), trainIdx.cols)``. If ``trainIdx`` is empty, it will be created with size ``nQuery`` :math:`\times` ``nTrain``. Otherwise it must be also allocated by user (it must have the same size as ``trainIdx`` and ``CV_32FC1`` type).
{Train set of descriptors. This will not be added to train descriptors collection stored in class object.}
{ ``trainIdx.at<int>(queryIdx, i)`` will contain i'th train index ``(i < min(nMatches.at<unsigned int>(0, queryIdx), trainIdx.cols)`` . If ``trainIdx`` is empty, it will be created with size
:math:`\texttt{nQuery} \times \texttt{nTrain}` . Or it can be allocated by user (it must have ``nQuery`` rows and ``CV_32SC1`` type). Cols can be less than ``nTrain`` , but it can be that matcher won't find all matches, because it haven't enough memory to store results.}
{ ``nMatches.at<unsigned int>(0, queryIdx)`` will contain matches count for ``queryIdx`` . Carefully, ``nMatches`` can be greater than ``trainIdx.cols`` - it means that matcher didn't find all matches, because it didn't have enough memory.}
{ ``distance.at<int>(queryIdx, i)`` will contain i'th distance ``(i < min(nMatches.at<unsigned int>(0, queryIdx), trainIdx.cols)`` . If ``trainIdx`` is empty, it will be created with size
:math:`\texttt{nQuery} \times \texttt{nTrain}` . Otherwise it must be also allocated by user (it must have the same size as ``trainIdx`` and ``CV_32FC1`` type).}
:param maxDistance: Distance threshold.
:param maxDistance: Distance threshold.
:param mask: Mask specifying permissible matches between input query and train matrices of descriptors.
:param mask: Mask specifying permissible matches between input query and train matrices of descriptors.
In contrast to results are not sorted by distance increasing order.
**Please note:** This function works only on devices with Compute Capability :math:`>=` 1.1.
This function works only on devices with Compute Capability
See also: :c:func:`DescriptorMatcher::radiusMatch`.
Downloads trainIdx, nMatchesand distancematrices obtained via to CPU vector with . If compactResultis true matchesvector will not contain matches for fully masked out query descriptors.
Downloads ``trainIdx``, ``nMatches`` and ``distance`` matrices obtained via :cpp:func:`gpu::BruteForceMatcher_GPU::radiusMatch` to CPU vector with :c:type:`DMatch`. If ``compactResult`` is true ``matches`` vector will not contain matches for fully masked out query descriptors.
Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images.
Functions and classes described in this section are used to perform various linear or non-linear filtering operations on 2D images.
See also:
See also: :ref:`ImageFiltering`.
.. index:: gpu::BaseRowFilter_GPU
.. index:: gpu::BaseRowFilter_GPU
gpu::BaseRowFilter_GPU
gpu::BaseRowFilter_GPU
----------------------
----------------------
.. c:type:: gpu::BaseRowFilter_GPU
.. cpp:class:: gpu::BaseRowFilter_GPU
The base class for linear or non-linear filters that processes rows of 2D arrays. Such filters are used for the "horizontal" filtering passes in separable filters. ::
The base class for linear or non-linear filters that processes rows of 2D arrays. Such filters are used for the "horizontal" filtering passes in separable filters. ::
...
@@ -24,16 +28,15 @@ The base class for linear or non-linear filters that processes rows of 2D arrays
...
@@ -24,16 +28,15 @@ The base class for linear or non-linear filters that processes rows of 2D arrays
int ksize, anchor;
int ksize, anchor;
};
};
**Please note:** This class doesn't allocate memory for destination image. Usually this class is used inside :cpp:class:`gpu::FilterEngine_GPU`.
**Please note:**
This class doesn't allocate memory for destination image. Usually this class is used inside
.
.. index:: gpu::BaseColumnFilter_GPU
.. index:: gpu::BaseColumnFilter_GPU
gpu::BaseColumnFilter_GPU
gpu::BaseColumnFilter_GPU
-------------------------
-------------------------
.. c:type:: gpu::BaseColumnFilter_GPU
.. cpp:class:: gpu::BaseColumnFilter_GPU
The base class for linear or non-linear filters that processes columns of 2D arrays. Such filters are used for the "vertical" filtering passes in separable filters. ::
The base class for linear or non-linear filters that processes columns of 2D arrays. Such filters are used for the "vertical" filtering passes in separable filters. ::
...
@@ -46,16 +49,15 @@ The base class for linear or non-linear filters that processes columns of 2D arr
...
@@ -46,16 +49,15 @@ The base class for linear or non-linear filters that processes columns of 2D arr
int ksize, anchor;
int ksize, anchor;
};
};
**Please note:** This class doesn't allocate memory for destination image. Usually this class is used inside :cpp:class:`gpu::FilterEngine_GPU`.
**Please note:**
This class doesn't allocate memory for destination image. Usually this class is used inside
.
.. index:: gpu::BaseFilter_GPU
.. index:: gpu::BaseFilter_GPU
gpu::BaseFilter_GPU
gpu::BaseFilter_GPU
-------------------
-------------------
.. c:type:: gpu::BaseFilter_GPU
.. cpp:class:: gpu::BaseFilter_GPU
The base class for non-separable 2D filters. ::
The base class for non-separable 2D filters. ::
...
@@ -70,15 +72,15 @@ The base class for non-separable 2D filters. ::
...
@@ -70,15 +72,15 @@ The base class for non-separable 2D filters. ::
};
};
**Please note:**
**Please note:** This class doesn't allocate memory for destination image. Usually this class is used inside :cpp:class:`gpu::FilterEngine_GPU`.
This class doesn't allocate memory for destination image. Usually this class is used inside
.
.. index:: gpu::FilterEngine_GPU
.. index:: gpu::FilterEngine_GPU
gpu::FilterEngine_GPU
gpu::FilterEngine_GPU
---------------------
---------------------
.. c:type:: gpu::FilterEngine_GPU
.. cpp:class:: gpu::FilterEngine_GPU
The base class for Filter Engine. ::
The base class for Filter Engine. ::
...
@@ -91,9 +93,7 @@ The base class for Filter Engine. ::
...
@@ -91,9 +93,7 @@ The base class for Filter Engine. ::
Rect roi = Rect(0,0,-1,-1)) = 0;
Rect roi = Rect(0,0,-1,-1)) = 0;
};
};
The class can be used to apply an arbitrary filtering operation to an image. It contains all the necessary intermediate buffers. Pointers to the initialized ``FilterEngine_GPU`` instances are returned by various ``create*Filter_GPU`` functions, see below, and they are used inside high-level functions such as :cpp:func:`gpu::filter2D`, :cpp:func:`gpu::erode`, :cpp:func:`gpu::Sobel` etc.
The class can be used to apply an arbitrary filtering operation to an image. It contains all the necessary intermediate buffers. Pointers to the initialized ``FilterEngine_GPU`` instances are returned by various ``create*Filter_GPU`` functions, see below, and they are used inside high-level functions such as
:func:`gpu::filter2D`,:func:`gpu::erode`,:func:`gpu::Sobel` etc.
By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary memory allocation for intermediate buffers and get much better performance: ::
By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary memory allocation for intermediate buffers and get much better performance: ::
...
@@ -117,52 +117,59 @@ By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary mem
...
@@ -117,52 +117,59 @@ By using ``FilterEngine_GPU`` instead of functions you can avoid unnecessary mem
// Release buffers only once
// Release buffers only once
filter.release();
filter.release();
``FilterEngine_GPU`` can process a rectangular sub-region of an image. By default, if ``roi == Rect(0,0,-1,-1)``,``FilterEngine_GPU`` processes inner region of image ( ``Rect(anchor.x, anchor.y, src_size.width - ksize.width, src_size.height - ksize.height)`` ), because some filters doesn't check if indices are outside the image for better perfomace. See below which filters supports processing the whole image and which not and image type limitations.
``FilterEngine_GPU`` can process a rectangular sub-region of an image. By default, if ``roi == Rect(0,0,-1,-1)``, ``FilterEngine_GPU`` processes inner region of image (``Rect(anchor.x, anchor.y, src_size.width - ksize.width, src_size.height - ksize.height)``), because some filters doesn't check if indices are outside the image for better perfomace. See below which filters supports processing the whole image and which not and image type limitations.
**Please note:** The GPU filters doesn't support the in-place mode.
:param anchor: Anchor point. The default value Point(-1, -1) means that the anchor is at the kernel center.
:param anchor: Anchor point. The default value ``(-1, -1)`` means that the anchor is at the kernel center.
**Please note:** This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
See also: :c:func:`createLinearFilter`.
**Please note:**
This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
See also:
:func:`createLinearFilter` .
.. index:: gpu::filter2D
.. index:: gpu::filter2D
gpu::filter2D
gpu::filter2D
-----------------
-----------------
.. c:function:: void gpu::filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1))
.. cpp:function:: void gpu::filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1))
Applies non-separable 2D linear filter to image.
Applies non-separable 2D linear filter to image.
:param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` source types.
:param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` source types.
:param dst: Destination image. It will have the same size and the same number of channels as ``src`` .
:param dst: Destination image. It will have the same size and the same number of channels as ``src``.
:param ddepth: The desired depth of the destination image. If it is negative, it will be the same as ``src.depth()`` . Supports only the same depth as source image.
:param ddepth: The desired depth of the destination image. If it is negative, it will be the same as ``src.depth()``. Supports only the same depth as source image.
:param kernel: 2D array of filter coefficients. This filter works with integers kernels, if ``kernel`` has ``float`` or ``double`` type it will use fixed point arithmetic.
:param kernel: 2D array of filter coefficients. This filter works with integers kernels, if ``kernel`` has ``float`` or ``double`` type it will use fixed point arithmetic.
:param anchor: Anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor should lie within the kernel. The special default value (-1,-1) means that the anchor is at the kernel center.
:param anchor: Anchor of the kernel that indicates the relative position of a filtered point within the kernel. The anchor should lie within the kernel. The special default value ``(-1,-1)`` means that the anchor is at the kernel center.
**Please note:** This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
See also: :c:func:`filter2D`, :cpp:func:`gpu::createLinearFilter_GPU`.
**Please note:**
This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
See also:
:func:`filter2D`,.
.. index:: gpu::Laplacian
.. index:: gpu::Laplacian
gpu::Laplacian
gpu::Laplacian
------------------
------------------
.. c:function:: void gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1)
.. cpp:function:: void gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1)
Applies Laplacian operator to image.
Applies Laplacian operator to image.
:param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` source types.
:param src: Source image. Supports ``CV_8UC1`` and ``CV_8UC4`` source types.
:param dst: Destination image; will have the same size and the same number of channels as ``src`` .
:param dst: Destination image; will have the same size and the same number of channels as ``src``.
:param ddepth: Desired depth of the destination image. Supports only tha same depth as source image depth.
:param ddepth: Desired depth of the destination image. Supports only tha same depth as source image depth.
:param ksize: Aperture size used to compute the second-derivative filters, see :func:`getDerivKernels` . It must be positive and odd. Supports only ``ksize`` = 1 and ``ksize`` = 3.
:param ksize: Aperture size used to compute the second-derivative filters, see :c:func:`getDerivKernels`. It must be positive and odd. Supports only ``ksize`` = 1 and ``ksize`` = 3.
:param scale: Optional scale factor for the computed Laplacian values (by default, no scaling is applied, see :c:func:`getDerivKernels`).
**Please note:** This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
:param scale: Optional scale factor for the computed Laplacian values (by default, no scaling is applied, see :func:`getDerivKernels` ).
See also: :c:func:`Laplacian`, :cpp:func:`gpu::filter2D`.
**Please note:**
This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
See also:
:func:`Laplacian`,:func:`gpu::filter2D` .
.. index:: gpu::getLinearRowFilter_GPU
.. index:: gpu::getLinearRowFilter_GPU
gpu::getLinearRowFilter_GPU
gpu::getLinearRowFilter_GPU
-------------------------------
-------------------------------
.. c:function:: Ptr<BaseRowFilter_GPU> getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel, int anchor = -1, int borderType = BORDER_CONSTANT)
.. cpp:function:: Ptr<BaseRowFilter_GPU> gpu::getLinearRowFilter_GPU(int srcType, int bufType, const Mat& rowKernel, int anchor = -1, int borderType = BORDER_CONSTANT)
Creates primitive row filter with the specified kernel.
Creates primitive row filter with the specified kernel.
:param bufType: Inermediate buffer type; must have as many channels as ``srcType`` .
:param bufType: Inermediate buffer type; must have as many channels as ``srcType``.
:param rowKernel: Filter coefficients.
:param rowKernel: Filter coefficients.
:param anchor: Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.
:param anchor: Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.
:param borderType: Pixel extrapolation method; see :func:`borderInterpolate` . About limitation see below.
:param borderType: Pixel extrapolation method; see :c:func:`borderInterpolate`. About limitation see below.
There are two version of algorithm: NPP and OpenCV. NPP calls when ``srcType == CV_8UC1`` or ``srcType == CV_8UC4`` and ``bufType == srcType``, otherwise calls OpenCV version. NPP supports only ``BORDER_CONSTANT`` border type and doesn't check indices outside image. OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE`` and ``BORDER_CONSTANT`` border types and checks indices outside image.
See also: :cpp:func:`gpu::getLinearColumnFilter_GPU`, :c:func:`createSeparableLinearFilter`.
There are two version of algorithm: NPP and OpenCV. NPP calls when ``srcType == CV_8UC1`` or ``srcType == CV_8UC4`` and ``bufType == srcType`` , otherwise calls OpenCV version. NPP supports only ``BORDER_CONSTANT`` border type and doesn't check indices outside image. OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE`` and ``BORDER_CONSTANT`` border types and checks indices outside image.
See also:,:func:`createSeparableLinearFilter` .
.. index:: gpu::getLinearColumnFilter_GPU
.. index:: gpu::getLinearColumnFilter_GPU
gpu::getLinearColumnFilter_GPU
gpu::getLinearColumnFilter_GPU
----------------------------------
----------------------------------
.. c:function:: Ptr<BaseColumnFilter_GPU> getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel, int anchor = -1, int borderType = BORDER_CONSTANT)
.. cpp:function:: Ptr<BaseColumnFilter_GPU> gpu::getLinearColumnFilter_GPU(int bufType, int dstType, const Mat& columnKernel, int anchor = -1, int borderType = BORDER_CONSTANT)
Creates the primitive column filter with the specified kernel.
Creates the primitive column filter with the specified kernel.
:param bufType: Inermediate buffer type; must have as many channels as ``dstType`` .
:param bufType: Inermediate buffer type; must have as many channels as ``dstType``.
:param anchor: Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.
:param anchor: Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.
:param borderType: Pixel extrapolation method; see :func:`borderInterpolate` . About limitation see below.
:param borderType: Pixel extrapolation method; see :c:func:`borderInterpolate`. About limitation see below.
There are two version of algorithm: NPP and OpenCV. NPP calls when ``dstType == CV_8UC1`` or ``dstType == CV_8UC4`` and ``bufType == dstType``, otherwise calls OpenCV version. NPP supports only ``BORDER_CONSTANT`` border type and doesn't check indices outside image. OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE`` and ``BORDER_CONSTANT`` border types and checks indices outside image.
See also: :cpp:func:`gpu::getLinearRowFilter_GPU`, :c:func:`createSeparableLinearFilter`.
There are two version of algorithm: NPP and OpenCV. NPP calls when ``dstType == CV_8UC1`` or ``dstType == CV_8UC4`` and ``bufType == dstType`` , otherwise calls OpenCV version. NPP supports only ``BORDER_CONSTANT`` border type and doesn't check indices outside image. OpenCV version supports only ``CV_32F`` buffer depth and ``BORDER_REFLECT101``,``BORDER_REPLICATE`` and ``BORDER_CONSTANT`` border types and checks indices outside image.
See also:,:func:`createSeparableLinearFilter` .
.. index:: gpu::createSeparableLinearFilter_GPU
.. index:: gpu::createSeparableLinearFilter_GPU
gpu::createSeparableLinearFilter_GPU
gpu::createSeparableLinearFilter_GPU
----------------------------------------
----------------------------------------
.. c:function:: Ptr<FilterEngine_GPU> createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel, const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. cpp:function:: Ptr<FilterEngine_GPU> gpu::createSeparableLinearFilter_GPU(int srcType, int dstType, const Mat& rowKernel, const Mat& columnKernel, const Point& anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
:param anchor: Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.
:param anchor: Anchor position within the kernel; negative values mean that anchor is positioned at the aperture center.
:param rowBorderType, columnBorderType: Pixel extrapolation method in the horizontal and the vertical directions; see :func:`borderInterpolate` . About limitation see , .
:param rowBorderType, columnBorderType: Pixel extrapolation method in the horizontal and the vertical directions; see :c:func:`borderInterpolate`. About limitation see :cpp:func:`gpu::getLinearRowFilter_GPU`, cpp:func:`gpu::getLinearColumnFilter_GPU`.
See also: :cpp:func:`gpu::getLinearRowFilter_GPU`, :cpp:func:`gpu::getLinearColumnFilter_GPU`, :c:func:`createSeparableLinearFilter`.
See also:,,
:func:`createSeparableLinearFilter` .
.. index:: gpu::sepFilter2D
.. index:: gpu::sepFilter2D
gpu::sepFilter2D
gpu::sepFilter2D
--------------------
--------------------
.. c:function:: void gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. cpp:function:: void gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
:param anchor: Anchor position within the kernel; The default value :math:`(-1, 1)` means that the anchor is at the kernel center.
:param anchor: Anchor position within the kernel; The default value ``(-1, 1)`` means that the anchor is at the kernel center.
:param rowBorderType, columnBorderType: Pixel extrapolation method; see :c:func:`borderInterpolate`.
See also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`sepFilter2D`.
:param rowBorderType, columnBorderType: Pixel extrapolation method; see :func:`borderInterpolate` .
See also:,:func:`sepFilter2D` .
.. index:: gpu::createDerivFilter_GPU
.. index:: gpu::createDerivFilter_GPU
gpu::createDerivFilter_GPU
gpu::createDerivFilter_GPU
------------------------------
------------------------------
.. c:function:: Ptr<FilterEngine_GPU> createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. cpp:function:: Ptr<FilterEngine_GPU> gpu::createDerivFilter_GPU(int srcType, int dstType, int dx, int dy, int ksize, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
Creates filter engine for the generalized Sobel operator.
Creates filter engine for the generalized Sobel operator.
:param dstType: Destination image type; must have as many channels as ``srcType`` . Supports ``CV_8U`` , ``CV_16S`` , ``CV_32S`` and ``CV_32F`` depths.
:param dstType: Destination image type; must have as many channels as ``srcType``. Supports ``CV_8U``, ``CV_16S``, ``CV_32S`` and ``CV_32F`` depths.
:param dx: Derivative order in respect with x.
:param dx: Derivative order in respect with x.
:param dy: Derivative order in respect with y.
:param dy: Derivative order in respect with y.
:param ksize: Aperture size; see :func:`getDerivKernels` .
:param ksize: Aperture size; see :c:func:`getDerivKernels`.
:param rowBorderType, columnBorderType: Pixel extrapolation method; see :c:func:`borderInterpolate`.
See also: :cpp:func:`gpu::createSeparableLinearFilter_GPU`, :c:func:`createDerivFilter`.
:param rowBorderType, columnBorderType: Pixel extrapolation method; see :func:`borderInterpolate` .
See also:,:func:`createDerivFilter` .
.. index:: gpu::Sobel
.. index:: gpu::Sobel
gpu::Sobel
gpu::Sobel
--------------
--------------
.. c:function:: void gpu::Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
.. cpp:function:: void gpu::Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1, int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1)
:param dst: Destination image; will have the same size and the same type as ``src`` .
:param dst: Destination image; will have the same size and the same type as ``src``.
:param ksize: Gaussian kernel size; ``ksize.width`` and ``ksize.height`` can differ, but they both must be positive and odd. Or, they can be zero's, then they are computed from ``sigmaX`` amd ``sigmaY`` .
:param ksize: Gaussian kernel size; ``ksize.width`` and ``ksize.height`` can differ, but they both must be positive and odd. Or, they can be zero's, then they are computed from ``sigmaX`` amd ``sigmaY``.
:param sigmaX, sigmaY: Gaussian kernel standard deviations in X and Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX`` . If they are both zeros, they are computed from ``ksize.width`` and ``ksize.height`` , respectively, see :func:`getGaussianKernel` . To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of ``ksize`` , ``sigmaX`` and ``sigmaY`` .
:param sigmaX, sigmaY: Gaussian kernel standard deviations in X and Y direction. If ``sigmaY`` is zero, it is set to be equal to ``sigmaX``. If they are both zeros, they are computed from ``ksize.width`` and ``ksize.height``, respectively, see :c:func:`getGaussianKernel`. To fully control the result regardless of possible future modification of all this semantics, it is recommended to specify all of ``ksize``, ``sigmaX`` and ``sigmaY``.
:param rowBorderType, columnBorderType: Pixel extrapolation method; see :c:func:`borderInterpolate`.
See also: :cpp:func:`gpu::createGaussianFilter_GPU`, :c:func:`GaussianBlur`.
:param rowBorderType, columnBorderType: Pixel extrapolation method; see :func:`borderInterpolate` .
See also:,:func:`GaussianBlur` .
.. index:: gpu::getMaxFilter_GPU
.. index:: gpu::getMaxFilter_GPU
gpu::getMaxFilter_GPU
gpu::getMaxFilter_GPU
-------------------------
-------------------------
.. c:function:: Ptr<BaseFilter_GPU> getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1))
.. cpp:function:: Ptr<BaseFilter_GPU> gpu::getMaxFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1))
Creates maximum filter.
Creates maximum filter.
:param srcType: Input image type. Supports only ``CV_8UC1`` and ``CV_8UC4`` .
:param srcType: Input image type. Supports only ``CV_8UC1`` and ``CV_8UC4``.
:param dstType: Output image type. Supports only the same type as source.
:param dstType: Output image type. Supports only the same type as source.
...
@@ -661,18 +691,19 @@ gpu::getMaxFilter_GPU
...
@@ -661,18 +691,19 @@ gpu::getMaxFilter_GPU
:param anchor: Anchor point. The default value (-1) means that the anchor is at the kernel center.
:param anchor: Anchor point. The default value (-1) means that the anchor is at the kernel center.
**Please note:**
**Please note:** This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
.. index:: gpu::getMinFilter_GPU
.. index:: gpu::getMinFilter_GPU
gpu::getMinFilter_GPU
gpu::getMinFilter_GPU
-------------------------
-------------------------
.. c:function:: Ptr<BaseFilter_GPU> getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1))
.. cpp:function:: Ptr<BaseFilter_GPU> gpu::getMinFilter_GPU(int srcType, int dstType, const Size& ksize, Point anchor = Point(-1,-1))
Creates minimum filter.
Creates minimum filter.
:param srcType: Input image type. Supports only ``CV_8UC1`` and ``CV_8UC4`` .
:param srcType: Input image type. Supports only ``CV_8UC1`` and ``CV_8UC4``.
:param dstType: Output image type. Supports only the same type as source.
:param dstType: Output image type. Supports only the same type as source.
...
@@ -680,5 +711,4 @@ gpu::getMinFilter_GPU
...
@@ -680,5 +711,4 @@ gpu::getMinFilter_GPU
:param anchor: Anchor point. The default value (-1) means that the anchor is at the kernel center.
:param anchor: Anchor point. The default value (-1) means that the anchor is at the kernel center.
**Please note:**
**Please note:** This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
This filter doesn't check out of border accesses, so only proper submatrix of bigger matrix have to be passed to it.
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, and as the result we have 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 color of mapped points. Will have the same size and type as ``src``.
:param sp: Spatial window radius.
:param sp: Spatial window radius.
:param sr: Color window radius.
:param sr: Color window radius.
:param criteria: Termination criteria. See .
:param criteria: Termination criteria. See :c:type:`TermCriteria`.
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 floating point matrix. Can 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).
...
@@ -234,61 +235,55 @@ cv::gpu::dft
...
@@ -234,61 +235,55 @@ cv::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 (it's 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** Inverse DFT must be perfromed for complex-complex case (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** 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:
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 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.
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.
See also: :c:func:`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.
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. Must have the same size and type as ``image``.
:param result: Map containing comparison results ( ``CV_32FC1`` ). If ``image`` is :math:`W \times H` and ``templ`` is :math:`w \times h` then ``result`` must be :math:`(W-w+1) \times (H-h+1)` .
: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 method: Specifies the way which the template must be compared with the image.
:param method: Specifies the way which the template must be compared with the image.
...
@@ -343,20 +340,21 @@ Following methods are supported for the ``CV_32F`` images for now:
...
@@ -343,20 +340,21 @@ Following methods are supported for the ``CV_32F`` images for now:
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:
See also: :c:func:`remap`.
:func:`remap` .
.. index:: gpu::cvtColor
.. index:: gpu::cvtColor
cv::gpu::cvtColor
gpu::cvtColor
-----------------
-----------------
.. c:function:: void gpu::cvtColor(const GpuMat\& src, GpuMat\& dst, int code, int dcn = 0)
.. cpp:function:: void gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0)
.. c:function:: void gpu::cvtColor(const GpuMat\& src, GpuMat\& dst, int code, int dcn, const Stream\& stream)
.. cpp:function:: void gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream)
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; will have the same size and the same depth as ``src``.
:param code: Color space conversion code. For details see :func:`cvtColor` . Conversion to/from Luv and Bayer color spaces doesn't supported.
:param code: Color space conversion code. For details see :c:func:`cvtColor`. Conversion to/from Luv and Bayer color spaces doesn't 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 will be 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``, etc) can be stored to 4-channel image for better perfomance.
: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. 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. 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 dsize: Destination image size. If it is zero, then it is computed as:
:param dsize: Destination image size. If it is zero, then it is computed as:
:param flags: Combination of interpolation methods, see :func:`resize` , and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation ( :math:`\texttt{dst}\rightarrow\texttt{src}` ). Supports only ``INTER_NEAREST`` , ``INTER_LINEAR`` and ``INTER_CUBIC`` interpolation methods.
: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.
See also: :c:func:`warpAffine`.
See also:
:func:`warpAffine` .
.. index:: gpu::warpPerspective
.. index:: gpu::warpPerspective
cv::gpu::warpPerspective
gpu::warpPerspective
------------------------
------------------------
.. c:function:: void gpu::warpPerspective(const GpuMat\& src, GpuMat\& dst, const Mat\& M, Size dsize, int flags = INTER_LINEAR)
.. cpp:function:: void gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR)
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; will have size ``dsize`` and the same type as ``src``.
:param flags: Combination of interpolation methods, see :func:`resize` , and the optional flag ``WARP_INVERSE_MAP`` that means that ``M`` is the inverse transformation ( :math:`\texttt{dst}\rightarrow\texttt{src}` ). Supports only ``INTER_NEAREST`` , ``INTER_LINEAR`` and ``INTER_CUBIC`` interpolation methods.
: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 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: The destination image; will have the same type as ``src`` and the size ``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: 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 sqr: Squared source image. Supports only ``CV_32FC1`` type.
:param sqr: Squared source image. Supports only ``CV_32FC1`` type.
:param dst: Destination image; will have the same type and the same size as ``src`` .
:param dst: Destination image; will have the same type and the same size as ``src``.
:param rect: Rectangular window.
:param rect: Rectangular window.
.. index:: gpu::evenLevels
.. index:: gpu::evenLevels
cv::gpu::evenLevels
gpu::evenLevels
-------------------
-------------------
.. c:function:: void gpu::evenLevels(GpuMat\& levels, int nLevels, int lowerLevel, int upperLevel)
.. cpp:function:: void gpu::evenLevels(GpuMat& levels, int nLevels, int lowerLevel, int upperLevel)
Computes levels with even distribution.
Computes levels with even distribution.
...
@@ -581,17 +586,19 @@ cv::gpu::evenLevels
...
@@ -581,17 +586,19 @@ cv::gpu::evenLevels
:param upperLevel: Upper boundary value of the greatest level.
:param upperLevel: Upper boundary value of the greatest level.
.. index:: gpu::histEven
.. index:: gpu::histEven
cv::gpu::histEven
gpu::histEven
-----------------
-----------------
.. c:function:: void gpu::histEven(const GpuMat\& src, GpuMat\& hist, int histSize, int lowerLevel, int upperLevel)
.. cpp:function:: void gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel)
.. c: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 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. Supports ``CV_8U``, ``CV_16U`` or ``CV_16S`` depth and 1 or 4 channels. For 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. Will have one row, ``histSize`` cols and ``CV_32S`` type.
...
@@ -601,19 +608,20 @@ cv::gpu::histEven
...
@@ -601,19 +608,20 @@ cv::gpu::histEven
:param upperLevel: Upper boundary of highest level bin.
:param upperLevel: Upper boundary of highest level bin.
Calculates histogram with bins determined by levels array.
Calculates histogram with bins determined by 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. Supports ``CV_8U``, ``CV_16U`` or ``CV_16S`` depth and 1 or 4 channels. For 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. Will have one row, ``(levels.cols-1)`` cols and ``CV_32SC1`` type.
.. 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.
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.
.. index:: gpu::setDevice
.. index:: gpu::setDevice
cv::gpu::setDevice
gpu::setDevice
------------------
------------------
.. c:function:: void setDevice(int device)
.. cpp:function:: void gpu::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.
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.
:param device: index of GPU device in system starting with 0.
.. index:: gpu::getDevice
.. index:: gpu::getDevice
cv::gpu::getDevice
gpu::getDevice
------------------
------------------
.. c:function:: int getDevice()
.. cpp:function:: int gpu::getDevice()
Returns the current device index, which was set by {gpu::getDevice} or initialized by default.
Returns the current device index, which was set by :cpp:func:`gpu::setDevice` or initialized by default.
.. index:: gpu::GpuFeature
.. _gpu::GpuFeature:
.. index:: gpu::GpuFeature
gpu::GpuFeature
gpu::GpuFeature
---------------
---------------
...
@@ -48,17 +54,16 @@ GPU compute features. ::
...
@@ -48,17 +54,16 @@ GPU compute features. ::
};
};
.. index:: gpu::DeviceInfo
.. _gpu::DeviceInfo:
.. index:: gpu::DeviceInfo
gpu::DeviceInfo
gpu::DeviceInfo
---------------
---------------
.. c:type:: 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 CV_EXPORTS DeviceInfo
class DeviceInfo
{
{
public:
public:
DeviceInfo();
DeviceInfo();
...
@@ -79,87 +84,104 @@ This class provides functionality for querying the specified GPU properties. ::
...
@@ -79,87 +84,104 @@ This class provides functionality for querying the specified GPU properties. ::
Constructs DeviceInfo object for the specified device. If deviceidparameter is missed it constructs object for the current device.
Constructs :cpp:class:`gpu::DeviceInfo` object for the specified device. If ``device_id`` parameter is missed it constructs object for the current device.
:param device_id: Index of the GPU device in system starting with 0.
:param device_id: Index of the GPU device in system starting with 0.
.. index:: gpu::DeviceInfo::name
.. index:: gpu::DeviceInfo::name
cv::gpu::DeviceInfo::name
gpu::DeviceInfo::name
-------------------------
-------------------------
.. c:function:: string DeviceInfo::name()
.. cpp:function:: string gpu::DeviceInfo::name()
Returns the device name.
Returns the device name.
.. index:: gpu::DeviceInfo::majorVersion
.. index:: gpu::DeviceInfo::majorVersion
cv::gpu::DeviceInfo::majorVersion
gpu::DeviceInfo::majorVersion
---------------------------------
---------------------------------
.. c:function:: int DeviceInfo::majorVersion()
.. cpp:function:: int gpu::DeviceInfo::majorVersion()
Returns the major compute capability version.
Returns the major compute capability version.
.. index:: gpu::DeviceInfo::minorVersion
.. index:: gpu::DeviceInfo::minorVersion
cv::gpu::DeviceInfo::minorVersion
gpu::DeviceInfo::minorVersion
---------------------------------
---------------------------------
.. c:function:: int DeviceInfo::minorVersion()
.. cpp:function:: int gpu::DeviceInfo::minorVersion()
Returns the minor compute capability version.
Returns the minor compute capability version.
.. index:: gpu::DeviceInfo::multiProcessorCount
.. index:: gpu::DeviceInfo::multiProcessorCount
cv::gpu::DeviceInfo::multiProcessorCount
gpu::DeviceInfo::multiProcessorCount
----------------------------------------
----------------------------------------
.. c:function:: int DeviceInfo::multiProcessorCount()
.. cpp:function:: int gpu::DeviceInfo::multiProcessorCount()
:param feature: Feature to be checked. See :c:type:`gpu::GpuFeature`.
There are a set of methods for checking whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s):
There are a set of methods for checking whether the module contains intermediate (PTX) or binary GPU code for the given architecture(s):
.. c:function:: static bool has(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::has(int major, int minor)
.. c:function:: static bool hasPtx(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::hasPtx(int major, int minor)
.. c:function:: static bool hasBin(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::hasBin(int major, int minor)
.. c:function:: static bool hasEqualOrLessPtx(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::hasEqualOrLessPtx(int major, int minor)
.. c:function:: static bool hasEqualOrGreater(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::hasEqualOrGreater(int major, int minor)
.. c:function:: static bool hasEqualOrGreaterPtx(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::hasEqualOrGreaterPtx(int major, int minor)
.. c:function:: static bool hasEqualOrGreaterBin(int major, int minor)
.. cpp:function:: static bool gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
* **major** Major compute capability version.
:param major: Major compute capability version.
* **minor** Minor compute capability version.
:param 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
gpu::MultiGpuManager
--------------------
.. c:type:: gpu::MultiGpuManager
Provides functionality for working with many GPUs. ::
@@ -14,10 +14,7 @@ The GPU module depends on the Cuda Toolkit and NVidia Performance Primitives lib
...
@@ -14,10 +14,7 @@ The GPU module depends on the Cuda Toolkit and NVidia Performance Primitives lib
OpenCV GPU module is designed for ease of use and does not require any knowledge of Cuda. Though, such a knowledge will certainly be useful in non-trivial cases, or when you want to get the highest performance. It is helpful to have understanding of the costs of various operations, what the GPU does, what are the preferred data formats etc. The GPU module is an effective instrument for quick implementation of GPU-accelerated computer vision algorithms. However, if you algorithm involves many simple operations, then for the best possible performance you may still need to write your own kernels, to avoid extra write and read operations on the intermediate results.
OpenCV GPU module is designed for ease of use and does not require any knowledge of Cuda. Though, such a knowledge will certainly be useful in non-trivial cases, or when you want to get the highest performance. It is helpful to have understanding of the costs of various operations, what the GPU does, what are the preferred data formats etc. The GPU module is an effective instrument for quick implementation of GPU-accelerated computer vision algorithms. However, if you algorithm involves many simple operations, then for the best possible performance you may still need to write your own kernels, to avoid extra write and read operations on the intermediate results.
To enable CUDA support, configure OpenCV using CMake with ``WITH_CUDA=ON`` . When the flag is set and if CUDA is installed, the full-featured OpenCV GPU module will be built. Otherwise, the module will still be built, but at runtime all functions from the module will throw
To enable CUDA support, configure OpenCV using CMake with ``WITH_CUDA=ON`` . When the flag is set and if CUDA is installed, the full-featured OpenCV GPU module will be built. Otherwise, the module will still be built, but at runtime all functions from the module will throw :c:type:`Exception` with ``CV_GpuNotSupported`` error code, except for :cpp:func:`gpu::getCudaEnabledDeviceCount`. The latter function will return zero GPU count in this case. Building OpenCV without CUDA support does not perform device code compilation, so it does not require Cuda Toolkit installed. Therefore, using :cpp:func:`gpu::getCudaEnabledDeviceCount` function it is possible to implement a high-level algorithm that will detect GPU presence at runtime and choose the appropriate implementation (CPU or GPU) accordingly.
:func:`Exception` with ``CV_GpuNotSupported`` error code, except for
:func:`gpu::getCudaEnabledDeviceCount()` . The latter function will return zero GPU count in this case. Building OpenCV without CUDA support does not perform device code compilation, so it does not require Cuda Toolkit installed. Therefore, using
:func:`gpu::getCudaEnabledDeviceCount()` function it is possible to implement a high-level algorithm that will detect GPU presence at runtime and choose the appropriate implementation (CPU or GPU) accordingly.
Compilation for different NVidia platforms.
Compilation for different NVidia platforms.
-------------------------------------------
-------------------------------------------
...
@@ -28,19 +25,16 @@ On first call, the PTX code is compiled to binary code for the particular GPU us
...
@@ -28,19 +25,16 @@ On first call, the PTX code is compiled to binary code for the particular GPU us
By default, the OpenCV GPU module includes:
By default, the OpenCV GPU module includes:
*
* Binaries for compute capabilities 1.1, 1.2, 1.3 and 2.0 (controlled by ``CUDA_ARCH_BIN`` in CMake)
Binaries for compute capabilities 1.3 and 2.0 (controlled by ``CUDA_ARCH_BIN`` in CMake)
*
* PTX code for compute capabilities 1.1 and 1.3 (controlled by ``CUDA_ARCH_PTX`` in CMake)
PTX code for compute capabilities 1.1 and 1.3 (controlled by ``CUDA_ARCH_PTX`` in CMake)
That means for devices with CC 1.3 and 2.0 binary images are ready to run. For all newer platforms the PTX code for 1.3 is JIT'ed to a binary image. For devices with 1.1 and 1.2 the PTX for 1.1 is JIT'ed. For devices with CC 1.0 no code is available and the functions will throw
That means for devices with CC 1.1, 1.2, 1.3 and 2.0 binary images are ready to run. For all newer platforms the PTX code for 1.3 is JIT'ed to a binary image. For devices with CC 1.0 no code is available and the functions will throw
:func:`Exception` . For platforms where JIT compilation is performed first run will be slow.
:c:type:`Exception`. For platforms where JIT compilation is performed first run will be slow.
If you happen to have GPU with CC 1.0, the GPU module can still be compiled on it and most of the functions will run just fine on such card. Simply add "1.0" to the list of binaries, for example, ``CUDA_ARCH_BIN="1.0 1.3 2.0"``. The functions that can not be run on CC 1.0 GPUs will throw an exception.
If you happen to have GPU with CC 1.0, the GPU module can still be compiled on it and most of the functions will run just fine on such card. Simply add "1.0" to the list of binaries, for example, ``CUDA_ARCH_BIN="1.0 1.3 2.0"``. The functions that can not be run on CC 1.0 GPUs will throw an exception.
You can always determine at runtime whether OpenCV GPU built binaries (or PTX code) are compatible with your GPU. The function
You can always determine at runtime whether OpenCV GPU built binaries (or PTX code) are compatible with your GPU. The function :cpp:func:`gpu::DeviceInfo::isCompatible` return the compatibility status (true/false).
:func:`gpu::DeviceInfo::isCompatible` return the compatibility status (true/false).
Threading and multi-threading.
Threading and multi-threading.
------------------------------
------------------------------
...
@@ -56,25 +50,14 @@ Multi-GPU
...
@@ -56,25 +50,14 @@ Multi-GPU
In the current version each of the OpenCV GPU algorithms can use only a single GPU. So, to utilize multiple GPUs, user has to manually distribute the work between the GPUs. Here are the two ways of utilizing multiple GPUs:
In the current version each of the OpenCV GPU algorithms can use only a single GPU. So, to utilize multiple GPUs, user has to manually distribute the work between the GPUs. Here are the two ways of utilizing multiple GPUs:
*
* If you only use synchronous functions, first, create several CPU threads (one per each GPU) and from within each thread create CUDA context for the corresponding GPU using :cpp:func:`gpu::setDevice` or Driver API. That's it. Now each of the threads will use the associated GPU.
If you only use synchronous functions, first, create several CPU threads (one per each GPU) and from within each thread create CUDA context for the corresponding GPU using
:func:`gpu::setDevice()` or Driver API. That's it. Now each of the threads will use the associated GPU.
*
* In case of asynchronous functions, it is possible to create several Cuda contexts associated with different GPUs but attached to one CPU thread. This can be done only by Driver API. Within the thread you can switch from one GPU to another by making the corresponding context "current". With non-blocking GPU calls managing algorithm is clear.
In case of asynchronous functions, it is possible to create several Cuda contexts associated with different GPUs but attached to one CPU thread. This can be done only by Driver API. Within the thread you can switch from one GPU to another by making the corresponding context "current". With non-blocking GPU calls managing algorithm is clear.
While developing algorithms for multiple GPUs a data passing overhead have to be taken into consideration. For primitive functions and for small images it can be significant and eliminate all the advantages of having multiple GPUs. But for high level algorithms Multi-GPU acceleration may be suitable. For example, Stereo Block Matching algorithm has been successfully parallelized using the following algorithm:
While developing algorithms for multiple GPUs a data passing overhead have to be taken into consideration. For primitive functions and for small images it can be significant and eliminate all the advantages of having multiple GPUs. But for high level algorithms Multi-GPU acceleration may be suitable. For example, Stereo Block Matching algorithm has been successfully parallelized using the following algorithm:
*
* Each image of the stereo pair is split into two horizontal overlapping stripes.
Each image of the stereo pair is split into two horizontal overlapping stripes.
* Each pair of stripes (from the left and the right images) has been processed on a separate Fermi GPU
* The results are merged into the single disparity map.
*
With this scheme dual GPU gave 180 % performance increase comparing to the single Fermi GPU. The source code of the example is available at https://code.ros.org/svn/opencv/trunk/opencv/examples/gpu/.
Each pair of stripes (from the left and the right images) has been processed on a separate Fermi GPU
*
The results are merged into the single disparity map.
With this scheme dual GPU gave 180
%
performance increase comparing to the single Fermi GPU. The source code of the example is available at
Histogram of Oriented Gradients [Navneet Dalal and Bill Triggs. Histogram of oriented gradients for human detection. 2005.] descriptor and detector. ::
dalal_hog
descriptor and detector. ::
struct CV_EXPORTS HOGDescriptor
struct HOGDescriptor
{
{
enum { DEFAULT_WIN_SIGMA = -1 };
enum { DEFAULT_WIN_SIGMA = -1 };
enum { DEFAULT_NLEVELS = 64 };
enum { DEFAULT_NLEVELS = 64 };
...
@@ -66,16 +64,13 @@ descriptor and detector. ::
...
@@ -66,16 +64,13 @@ descriptor and detector. ::
Interfaces of all methods are kept similar to CPU HOG descriptor and detector analogues as much as possible.
Interfaces of all methods are kept similar to CPU HOG descriptor and detector analogues as much as possible.
:param img: Source image. See :func:`gpu::HOGDescriptor::detect` for type limitations.
:param img: Source image. See :cpp:func:`gpu::HOGDescriptor::detect` for type limitations.
:param found_locations: Will contain detected objects boundaries.
:param found_locations: Will contain detected objects boundaries.
:param hit_threshold: The threshold for the distance between features and SVM classifying plane. See :func:`gpu::HOGDescriptor::detect` for details.
:param hit_threshold: The threshold for the distance between features and SVM classifying plane. See :cpp:func:`gpu::HOGDescriptor::detect` for details.
:param win_stride: Window stride. Must be a multiple of block stride.
:param win_stride: Window stride. Must be a multiple of block stride.
:param scale0: Coefficient of the detection window increase.
:param scale0: Coefficient of the detection window increase.
:param group_threshold: After detection some objects could be covered by many rectangles. This coefficient regulates similarity threshold. 0 means don't perform grouping.
:param group_threshold: After detection some objects could be covered by many rectangles. This coefficient regulates similarity threshold. 0 means don't perform grouping. See :c:func:`groupRectangles`.
:param filename: Name of file from which classifier will be load. Only old haar classifier (trained by haartraining application) and NVidia's nvbin are supported.
:param filename: Name of file from which classifier will be load. Only old haar classifier (trained by haartraining application) and NVidia's nvbin are supported.
Loads the classifier from file. The previous content is destroyed.
Loads the classifier from file. The previous content is destroyed.
:param filename: Name of file from which classifier will be load. Only old haar classifier (trained by haartraining application) and NVidia's nvbin are supported.
:param filename: Name of file from which classifier will be load. Only old haar classifier (trained by haartraining application) and NVidia's nvbin are supported.
.. c:function:: int CascadeClassifier_GPU::detectMultiScale(const GpuMat\& image, GpuMat\& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size())
.. cpp:function:: int gpu::CascadeClassifier_GPU::detectMultiScale(const GpuMat& image, GpuMat& objectsBuf, double scaleFactor=1.2, int minNeighbors=4, Size minSize=Size())
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.
:param image: Matrix of type ``CV_8U`` containing the image in which to detect objects.
:param image: Matrix of type ``CV_8U`` containing the image in which to detect objects.
:param objects: Buffer to store detected objects (rectangles). If it is empty, it will be allocated with default size. If not empty, function will search not more than N objects, where N = sizeof(objectsBufer's data)/sizeof(cv::Rect).
:param objects: Buffer to store detected objects (rectangles). If it is empty, it will be allocated with default size. If not empty, function will search not more than N objects, where ``N = sizeof(objectsBufer's data)/sizeof(cv::Rect)``.
:param scaleFactor: Specifies how much the image size is reduced at each image scale.
:param scaleFactor: Specifies how much the image size is reduced at each image scale.
...
@@ -333,7 +336,5 @@ The function returns number of detected objects, so you can retrieve them as in
...
@@ -333,7 +336,5 @@ The function returns number of detected objects, so you can retrieve them as in
imshow("Faces", image_cpu);
imshow("Faces", image_cpu);
See also: :c:func:`CascadeClassifier::detectMultiScale`.
Transforms the source matrix into the destination matrix using given look-up table:
Transforms the source matrix into the destination matrix using given look-up table:
.. math::
dst(I) = lut(src(I))
:param src: Source matrix. ``CV_8UC1`` and ``CV_8UC3`` matrixes are supported for now.
:param src: Source matrix. ``CV_8UC1`` and ``CV_8UC3`` matrixes are supported for now.
:param lut: Look-up table. Must be continuous, ``CV_8U`` depth matrix. Its area must satisfy to ``lut.rows`` :math:`\times` ``lut.cols`` = 256 condition.
:param lut: Look-up table. Must be continuous, ``CV_8U`` depth matrix. Its area must satisfy to ``lut.rows`` :math:`\times` ``lut.cols`` = 256 condition.
:param dst: Destination matrix. Will have the same depth as ``lut`` and the same number of channels as ``src`` .
:param dst: Destination matrix. Will have the same depth as ``lut`` and the same number of channels as ``src``.
See also: :c:func:`LUT`.
See also:
:func:`LUT` .
.. index:: gpu::merge
.. index:: gpu::merge
gpu::merge
gpu::merge
--------------
--------------
.. c:function:: void gpu::merge(const GpuMat* src, size_t n, GpuMat\& dst)
.. cpp:function:: void gpu::merge(const GpuMat* src, size_t n, GpuMat& dst)
.. c:function:: void gpu::merge(const GpuMat* src, size_t n, GpuMat\& dst,