merged all the latest changes from 2.4 to trunk
This commit is contained in:
@@ -55,7 +55,7 @@ Calculates eigenvalues and eigenvectors of image blocks for corner detection.
|
||||
:param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` .
|
||||
|
||||
For every pixel
|
||||
:math:`p` , the function ``cornerEigenValsAndVecs`` considers a ``blockSize`` :math:`\times` ``blockSize`` neigborhood
|
||||
:math:`p` , the function ``cornerEigenValsAndVecs`` considers a ``blockSize`` :math:`\times` ``blockSize`` neighborhood
|
||||
:math:`S(p)` . It calculates the covariation matrix of derivatives over the neighborhood as:
|
||||
|
||||
.. math::
|
||||
@@ -279,9 +279,6 @@ The function can be used to initialize a point-based tracker of an object.
|
||||
:ocv:func:`cornerHarris`,
|
||||
:ocv:func:`calcOpticalFlowPyrLK`,
|
||||
:ocv:func:`estimateRigidTransform`,
|
||||
:ocv:class:`PlanarObjectDetector`,
|
||||
:ocv:class:`OneWayDescriptor`
|
||||
|
||||
|
||||
|
||||
HoughCircles
|
||||
@@ -544,4 +541,4 @@ The corners can be found as local maximums of the functions, as shown below: ::
|
||||
|
||||
.. [Shi94] J. Shi and C. Tomasi. *Good Features to Track*. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 593-600, June 1994.
|
||||
|
||||
.. [Yuen90] Yuen, H. K. and Princen, J. and Illingworth, J. and Kittler, J., *Comparative study of Hough transform methods for circle finding*. Image Vision Comput. 8 1, pp 71–77 (1990)
|
||||
.. [Yuen90] Yuen, H. K. and Princen, J. and Illingworth, J. and Kittler, J., *Comparative study of Hough transform methods for circle finding*. Image Vision Comput. 8 1, pp 71–77 (1990)
|
||||
|
@@ -418,7 +418,7 @@ Smoothes an image using the normalized box filter.
|
||||
|
||||
.. ocv:pyfunction:: cv2.blur(src, ksize[, dst[, anchor[, borderType]]]) -> dst
|
||||
|
||||
:param src: Source image.
|
||||
:param src: Source image. The image can have any number of channels, which are processed independently. The depth should be ``CV_8U``, ``CV_16U``, ``CV_16S``, ``CV_32F`` or ``CV_64F``.
|
||||
|
||||
:param dst: Destination image of the same size and type as ``src`` .
|
||||
|
||||
@@ -507,9 +507,7 @@ where
|
||||
|
||||
\alpha = \fork{\frac{1}{\texttt{ksize.width*ksize.height}}}{when \texttt{normalize=true}}{1}{otherwise}
|
||||
|
||||
Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms,
|
||||
and so on). If you need to compute pixel sums over variable-size windows, use
|
||||
:ocv:func:`integral` .
|
||||
Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use :ocv:func:`integral` .
|
||||
|
||||
.. seealso::
|
||||
|
||||
@@ -585,6 +583,10 @@ The function supports the mode when ``src`` is already in the middle of ``dst``
|
||||
...
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
When the source image is a part (ROI) of a bigger image, the function will try to use the pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as if ``src`` was not a ROI, use ``borderType | BORDER_ISOLATED``.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ocv:func:`borderInterpolate`
|
||||
@@ -713,13 +715,13 @@ Creates a non-separable linear filter engine.
|
||||
|
||||
:param delta: Value added to the filtered results before storing them.
|
||||
|
||||
:param bits: Number of the fractional bits. the parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
|
||||
:param bits: Number of the fractional bits. The parameter is used when the kernel is an integer matrix representing fixed-point filter coefficients.
|
||||
|
||||
:param rowBorderType: Pixel extrapolation method in the vertical direction. For details, see :ocv:func:`borderInterpolate`.
|
||||
|
||||
:param columnBorderType: Pixel extrapolation method in the horizontal direction.
|
||||
|
||||
:param borderValue: Border vaule used in case of a constant border.
|
||||
:param borderValue: Border value used in case of a constant border.
|
||||
|
||||
The function returns a pointer to a 2D linear filter for the specified kernel, the source array type, and the destination array type. The function is a higher-level function that calls ``getLinearFilter`` and passes the retrieved 2D filter to the
|
||||
:ocv:class:`FilterEngine` constructor.
|
||||
@@ -737,17 +739,17 @@ Creates an engine for non-separable morphological operations.
|
||||
|
||||
.. ocv:function:: Ptr<FilterEngine> createMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1), int rowBorderType=BORDER_CONSTANT, int columnBorderType=-1, const Scalar& borderValue=morphologyDefaultBorderValue())
|
||||
|
||||
.. ocv:function:: Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1))
|
||||
.. ocv:function:: Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray element, Point anchor=Point(-1,-1))
|
||||
|
||||
.. ocv:function:: Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int esize, int anchor=-1)
|
||||
.. ocv:function:: Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int esize, int anchor=-1)
|
||||
|
||||
.. ocv:function:: Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int esize, int anchor=-1)
|
||||
.. ocv:function:: Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int esize, int anchor=-1)
|
||||
|
||||
.. ocv:function:: Scalar morphologyDefaultBorderValue()
|
||||
|
||||
:param op: Morphology operation ID, ``MORPH_ERODE`` or ``MORPH_DILATE`` .
|
||||
|
||||
:param type: Input/output image type.
|
||||
|
||||
:param type: Input/output image type. The number of channels can be arbitrary. The depth should be one of ``CV_8U``, ``CV_16U``, ``CV_16S``, ``CV_32F` or ``CV_64F``.
|
||||
|
||||
:param element: 2D 8-bit structuring element for a morphological operation. Non-zero elements indicate the pixels that belong to the element.
|
||||
|
||||
@@ -836,7 +838,7 @@ Dilates an image by using a specific structuring element.
|
||||
.. ocv:cfunction:: void cvDilate( const CvArr* src, CvArr* dst, IplConvKernel* element=NULL, int iterations=1 )
|
||||
.. ocv:pyoldfunction:: cv.Dilate(src, dst, element=None, iterations=1)-> None
|
||||
|
||||
:param src: Source image.
|
||||
:param src: Source image. The number of channels can be arbitrary. The depth should be one of ``CV_8U``, ``CV_16U``, ``CV_16S``, ``CV_32F` or ``CV_64F``.
|
||||
|
||||
:param dst: Destination image of the same size and type as ``src`` .
|
||||
|
||||
@@ -876,9 +878,9 @@ Erodes an image by using a specific structuring element.
|
||||
.. ocv:cfunction:: void cvErode( const CvArr* src, CvArr* dst, IplConvKernel* element=NULL, int iterations=1)
|
||||
.. ocv:pyoldfunction:: cv.Erode(src, dst, element=None, iterations=1)-> None
|
||||
|
||||
:param src: Source image.
|
||||
:param src: Source image. The number of channels can be arbitrary. The depth should be one of ``CV_8U``, ``CV_16U``, ``CV_16S``, ``CV_32F` or ``CV_64F``.
|
||||
|
||||
:param dst: Destination image of the same size and type as ``src`` .
|
||||
:param dst: Destination image of the same size and type as ``src``.
|
||||
|
||||
:param element: Structuring element used for erosion. If ``element=Mat()`` , a ``3 x 3`` rectangular structuring element is used.
|
||||
|
||||
@@ -921,7 +923,13 @@ Convolves an image with the kernel.
|
||||
|
||||
:param dst: Destination image of the same size and the same number of channels as ``src`` .
|
||||
|
||||
:param ddepth: Desired depth of the destination image. If it is negative, it will be the same as ``src.depth()`` .
|
||||
:param ddepth: Desired depth of the destination image. If it is negative, it will be the same as ``src.depth()`` . The following combination of ``src.depth()`` and ``ddepth`` are supported:
|
||||
* ``src.depth()`` = ``CV_8U``, ``ddepth`` = -1/``CV_16S``/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_16U``/``CV_16S``, ``ddepth`` = -1/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_32F``, ``ddepth`` = -1/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_64F``, ``ddepth`` = -1/``CV_64F``
|
||||
|
||||
when ``ddepth=-1``, the destination image will have the same depth as the source.
|
||||
|
||||
:param kernel: Convolution kernel (or rather a correlation kernel), a single-channel floating point matrix. If you want to apply different kernels to different channels, split the image into separate color planes using :ocv:func:`split` and process them individually.
|
||||
|
||||
@@ -961,7 +969,7 @@ Smoothes an image using a Gaussian filter.
|
||||
|
||||
.. ocv:pyfunction:: cv2.GaussianBlur(src, ksize, sigma1[, dst[, sigma2[, borderType]]]) -> dst
|
||||
|
||||
:param src: Source image.
|
||||
:param src: Source image. The image can have any number of channels, which are processed independently. The depth should be ``CV_8U``, ``CV_16U``, ``CV_16S``, ``CV_32F`` or ``CV_64F``.
|
||||
|
||||
:param dst: Destination image of the same size and type as ``src`` .
|
||||
|
||||
@@ -1169,7 +1177,7 @@ Performs advanced morphological transformations.
|
||||
.. ocv:cfunction:: void cvMorphologyEx( const CvArr* src, CvArr* dst, CvArr* temp, IplConvKernel* element, int operation, int iterations=1 )
|
||||
.. ocv:pyoldfunction:: cv.MorphologyEx(src, dst, temp, element, operation, iterations=1)-> None
|
||||
|
||||
:param src: Source image.
|
||||
:param src: Source image. The number of channels can be arbitrary. The depth should be one of ``CV_8U``, ``CV_16U``, ``CV_16S``, ``CV_32F` or ``CV_64F``.
|
||||
|
||||
:param dst: Destination image of the same size and type as ``src`` .
|
||||
|
||||
@@ -1225,7 +1233,7 @@ Morphological gradient:
|
||||
|
||||
\texttt{dst} = \mathrm{blackhat} ( \texttt{src} , \texttt{element} )= \mathrm{close} ( \texttt{src} , \texttt{element} )- \texttt{src}
|
||||
|
||||
Any of the operations can be done in-place.
|
||||
Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.
|
||||
|
||||
.. seealso::
|
||||
|
||||
@@ -1402,7 +1410,13 @@ Applies a separable linear filter to an image.
|
||||
|
||||
:param dst: Destination image of the same size and the same number of channels as ``src`` .
|
||||
|
||||
:param ddepth: Destination image depth.
|
||||
:param ddepth: Destination image depth. The following combination of ``src.depth()`` and ``ddepth`` are supported:
|
||||
* ``src.depth()`` = ``CV_8U``, ``ddepth`` = -1/``CV_16S``/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_16U``/``CV_16S``, ``ddepth`` = -1/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_32F``, ``ddepth`` = -1/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_64F``, ``ddepth`` = -1/``CV_64F``
|
||||
|
||||
when ``ddepth=-1``, the destination image will have the same depth as the source.
|
||||
|
||||
:param rowKernel: Coefficients for filtering each row.
|
||||
|
||||
@@ -1493,7 +1507,13 @@ Calculates the first, second, third, or mixed image derivatives using an extende
|
||||
|
||||
:param dst: Destination image of the same size and the same number of channels as ``src`` .
|
||||
|
||||
:param ddepth: Destination image depth.
|
||||
:param ddepth: Destination image depth. The following combination of ``src.depth()`` and ``ddepth`` are supported:
|
||||
* ``src.depth()`` = ``CV_8U``, ``ddepth`` = -1/``CV_16S``/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_16U``/``CV_16S``, ``ddepth`` = -1/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_32F``, ``ddepth`` = -1/``CV_32F``/``CV_64F``
|
||||
* ``src.depth()`` = ``CV_64F``, ``ddepth`` = -1/``CV_64F``
|
||||
|
||||
when ``ddepth=-1``, the destination image will have the same depth as the source. In the case of 8-bit input images it will result in truncated derivatives.
|
||||
|
||||
:param xorder: Order of the derivative x.
|
||||
|
||||
@@ -1568,9 +1588,9 @@ Calculates the first x- or y- image derivative using Scharr operator.
|
||||
|
||||
:param src: Source image.
|
||||
|
||||
:param dst: Destination image of the same size and the same number of channels as ``src`` .
|
||||
:param dst: Destination image of the same size and the same number of channels as ``src``.
|
||||
|
||||
:param ddepth: Destination image depth.
|
||||
:param ddepth: Destination image depth. See :ocv:func:`Sobel` for the list of supported combination of ``src.depth()`` and ``ddepth``.
|
||||
|
||||
:param xorder: Order of the derivative x.
|
||||
|
||||
@@ -1578,7 +1598,7 @@ Calculates the first x- or y- image derivative using Scharr operator.
|
||||
|
||||
:param scale: Optional scale factor for the computed derivative values. By default, no scaling is applied. See :ocv:func:`getDerivKernels` for details.
|
||||
|
||||
:param delta: Optional delta value that is added to the results prior to storing them in ``dst`` .
|
||||
:param delta: Optional delta value that is added to the results prior to storing them in ``dst``.
|
||||
|
||||
:param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` for details.
|
||||
|
||||
|
@@ -34,7 +34,7 @@ Calculates a histogram of a set of arrays.
|
||||
|
||||
:param ranges: Array of the ``dims`` arrays of the histogram bin boundaries in each dimension. When the histogram is uniform ( ``uniform`` =true), then for each dimension ``i`` it is enough to specify the lower (inclusive) boundary :math:`L_0` of the 0-th histogram bin and the upper (exclusive) boundary :math:`U_{\texttt{histSize}[i]-1}` for the last histogram bin ``histSize[i]-1`` . That is, in case of a uniform histogram each of ``ranges[i]`` is an array of 2 elements. When the histogram is not uniform ( ``uniform=false`` ), then each of ``ranges[i]`` contains ``histSize[i]+1`` elements: :math:`L_0, U_0=L_1, U_1=L_2, ..., U_{\texttt{histSize[i]}-2}=L_{\texttt{histSize[i]}-1}, U_{\texttt{histSize[i]}-1}` . The array elements, that are not between :math:`L_0` and :math:`U_{\texttt{histSize[i]}-1}` , are not counted in the histogram.
|
||||
|
||||
:param uniform: Flag indicatinfg whether the histogram is uniform or not (see above).
|
||||
:param uniform: Flag indicating whether the histogram is uniform or not (see above).
|
||||
|
||||
:param accumulate: Accumulation flag. If it is set, the histogram is not cleared in the beginning when it is allocated. This feature enables you to compute a single histogram from several sets of arrays, or to update the histogram in time.
|
||||
|
||||
@@ -123,7 +123,7 @@ Calculates the back projection of a histogram.
|
||||
|
||||
:param hist: Input histogram that can be dense or sparse.
|
||||
|
||||
:param backProject: Destination back projection aray that is a single-channel array of the same size and depth as ``arrays[0]`` .
|
||||
:param backProject: Destination back projection array that is a single-channel array of the same size and depth as ``arrays[0]`` .
|
||||
|
||||
:param ranges: Array of arrays of the histogram bin boundaries in each dimension. See :ocv:func:`calcHist` .
|
||||
|
||||
@@ -405,8 +405,8 @@ Creates a histogram.
|
||||
The function creates a histogram of the specified size and returns a pointer to the created histogram. If the array ``ranges`` is 0, the histogram bin ranges must be specified later via the function :ocv:cfunc:`SetHistBinRanges`. Though :ocv:cfunc:`CalcHist` and :ocv:cfunc:`CalcBackProject` may process 8-bit images without setting bin ranges, they assume they are equally spaced in 0 to 255 bins.
|
||||
|
||||
|
||||
GetHistValue_?D
|
||||
---------------
|
||||
GetHistValue\_?D
|
||||
----------------
|
||||
Returns a pointer to the histogram bin.
|
||||
|
||||
.. ocv:cfunction:: float cvGetHistValue_1D(CvHistogram hist, int idx0)
|
||||
|
@@ -436,7 +436,7 @@ The functions ``distanceTransform`` calculate the approximate or precise
|
||||
distance from every binary image pixel to the nearest zero pixel.
|
||||
For zero image pixels, the distance will obviously be zero.
|
||||
|
||||
When ``maskSize == CV_DIST_MASK_PRECISE`` and ``distanceType == CV_DIST_L2`` , the function runs the algorithm described in [Felzenszwalb04]_.
|
||||
When ``maskSize == CV_DIST_MASK_PRECISE`` and ``distanceType == CV_DIST_L2`` , the function runs the algorithm described in [Felzenszwalb04]_. This algorithm is parallelized with the TBB library.
|
||||
|
||||
In other cases, the algorithm
|
||||
[Borgefors86]_
|
||||
@@ -449,7 +449,7 @@ basic distances. Since the distance function should be symmetric,
|
||||
all of the horizontal and vertical shifts must have the same cost (denoted as ``a`` ), all the diagonal shifts must have the
|
||||
same cost (denoted as ``b`` ), and all knight's moves must have
|
||||
the same cost (denoted as ``c`` ). For the ``CV_DIST_C`` and ``CV_DIST_L1`` types, the distance is calculated precisely,
|
||||
whereas for ``CV_DIST_L2`` (Euclidian distance) the distance
|
||||
whereas for ``CV_DIST_L2`` (Euclidean distance) the distance
|
||||
can be calculated only with a relative error (a
|
||||
:math:`5\times 5` mask
|
||||
gives more accurate results). For ``a``,``b`` , and ``c`` , OpenCV uses the values suggested in the original paper:
|
||||
@@ -706,7 +706,8 @@ Also, the special value ``THRESH_OTSU`` may be combined with
|
||||
one of the above values. In this case, the function determines the optimal threshold
|
||||
value using the Otsu's algorithm and uses it instead of the specified ``thresh`` .
|
||||
The function returns the computed threshold value.
|
||||
Currently, the Otsu's method is implemented only for 8-bit images.
|
||||
Currently, the Otsu's method is implemented only for 8-bit images.
|
||||
|
||||
|
||||
.. image:: pics/threshold.png
|
||||
|
||||
@@ -721,7 +722,7 @@ Currently, the Otsu's method is implemented only for 8-bit images.
|
||||
|
||||
watershed
|
||||
-------------
|
||||
Performs a marker-based image segmentation using the watershed algrorithm.
|
||||
Performs a marker-based image segmentation using the watershed algorithm.
|
||||
|
||||
.. ocv:function:: void watershed( InputArray image, InputOutputArray markers )
|
||||
|
||||
|
@@ -144,7 +144,7 @@ The function supports multi-channel images. Each channel is processed independen
|
||||
|
||||
phaseCorrelate
|
||||
--------------
|
||||
The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion esitimation. For more information please see http://en.wikipedia.org/wiki/Phase\_correlation .
|
||||
The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see http://en.wikipedia.org/wiki/Phase\_correlation .
|
||||
|
||||
Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with :ocv:func:`getOptimalDFTSize`.
|
||||
|
||||
|
@@ -109,7 +109,7 @@ Point of an original or dual subdivision.
|
||||
..
|
||||
|
||||
* id
|
||||
This integer can be used to index auxillary data associated with each vertex of the planar subdivision.
|
||||
This integer can be used to index auxiliary data associated with each vertex of the planar subdivision.
|
||||
|
||||
CalcSubdivVoronoi2D
|
||||
-------------------
|
||||
@@ -254,7 +254,7 @@ Returns the location of a point within a Delaunay triangulation.
|
||||
|
||||
:param edge: Output edge that the point belongs to or is located to the right of it.
|
||||
|
||||
:param vertex: Optional output vertex double pointer the input point coinsides with.
|
||||
:param vertex: Optional output vertex double pointer the input point coincides with.
|
||||
|
||||
The function locates the input point within the subdivision. There are five cases:
|
||||
|
||||
@@ -280,7 +280,7 @@ The function locates the input point within the subdivision. There are five case
|
||||
will contain a pointer to the vertex.
|
||||
|
||||
*
|
||||
The point is outside the subdivsion reference rectangle. The function returns
|
||||
The point is outside the subdivision reference rectangle. The function returns
|
||||
``CV_PTLOC_OUTSIDE_RECT``
|
||||
and no pointers are filled.
|
||||
|
||||
|
@@ -30,6 +30,14 @@ The function computes moments, up to the 3rd order, of a vector shape or a raste
|
||||
double m02, double m30, double m21, double m12, double m03 );
|
||||
Moments( const CvMoments& moments );
|
||||
operator CvMoments() const;
|
||||
|
||||
// spatial moments
|
||||
double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03;
|
||||
// central moments
|
||||
double mu20, mu11, mu02, mu30, mu21, mu12, mu03;
|
||||
// central normalized moments
|
||||
double nu20, nu11, nu02, nu30, nu21, nu12, nu03;
|
||||
}
|
||||
|
||||
In case of a raster image, the spatial moments :math:`\texttt{Moments::m}_{ji}` are computed as:
|
||||
|
||||
@@ -66,6 +74,10 @@ The normalized central moments
|
||||
|
||||
The moments of a contour are defined in the same way but computed using the Green's formula (see http://en.wikipedia.org/wiki/Green_theorem). So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.
|
||||
|
||||
.. note::
|
||||
|
||||
Since the contour moments are computed using Green formula, you may get seemingly odd results for contours with self-intersections, e.g. a zero area (``m00``) for butterfly-shaped contours.
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ocv:func:`contourArea`,
|
||||
@@ -112,6 +124,8 @@ Finds contours in a binary image.
|
||||
|
||||
.. ocv:function:: void findContours( InputOutputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point())
|
||||
|
||||
.. ocv:pyfunction:: cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
|
||||
|
||||
.. ocv:cfunction:: int cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** firstContour, int headerSize=sizeof(CvContour), int mode=CV_RETR_LIST, int method=CV_CHAIN_APPROX_SIMPLE, CvPoint offset=cvPoint(0, 0) )
|
||||
|
||||
.. ocv:pyoldfunction:: cv.FindContours(image, storage, mode=CV_RETR_LIST, method=CV_CHAIN_APPROX_SIMPLE, offset=(0, 0)) -> cvseq
|
||||
@@ -122,7 +136,7 @@ Finds contours in a binary image.
|
||||
|
||||
:param hierarchy: Optional output vector containing information about the image topology. It has as many elements as the number of contours. For each contour ``contours[i]`` , the elements ``hierarchy[i][0]`` , ``hiearchy[i][1]`` , ``hiearchy[i][2]`` , and ``hiearchy[i][3]`` are set to 0-based indices in ``contours`` of the next and previous contours at the same hierarchical level: the first child contour and the parent contour, respectively. If for a contour ``i`` there are no next, previous, parent, or nested contours, the corresponding elements of ``hierarchy[i]`` will be negative.
|
||||
|
||||
:param mode: Contour retrieval mode.
|
||||
:param mode: Contour retrieval mode (if you use Python see also a note below).
|
||||
|
||||
* **CV_RETR_EXTERNAL** retrieves only the extreme outer contours. It sets ``hierarchy[i][2]=hierarchy[i][3]=-1`` for all the contours.
|
||||
|
||||
@@ -132,7 +146,7 @@ Finds contours in a binary image.
|
||||
|
||||
* **CV_RETR_TREE** retrieves all of the contours and reconstructs a full hierarchy of nested contours. This full hierarchy is built and shown in the OpenCV ``contours.c`` demo.
|
||||
|
||||
:param method: Contour approximation method.
|
||||
:param method: Contour approximation method (if you use Python see also a note below).
|
||||
|
||||
* **CV_CHAIN_APPROX_NONE** stores absolutely all the contour points. That is, any 2 subsequent points ``(x1,y1)`` and ``(x2,y2)`` of the contour will be either horizontal, vertical or diagonal neighbors, that is, ``max(abs(x1-x2),abs(y2-y1))==1``.
|
||||
|
||||
@@ -147,6 +161,7 @@ The function retrieves contours from the binary image using the algorithm
|
||||
|
||||
.. note:: Source ``image`` is modified by this function.
|
||||
|
||||
.. note:: If you use the new Python interface then the ``CV_`` prefix has to be omitted in contour retrieval mode and contour approximation method parameters (for example, use ``cv2.RETR_LIST`` and ``cv2.CHAIN_APPROX_NONE`` parameters). If you use the old Python interface then these parameters have the ``CV_`` prefix (for example, use ``cv.CV_RETR_LIST`` and ``cv.CV_CHAIN_APPROX_NONE``).
|
||||
|
||||
drawContours
|
||||
----------------
|
||||
@@ -179,6 +194,12 @@ Draws contours outlines or filled contours.
|
||||
|
||||
:param offset: Optional contour shift parameter. Shift all the drawn contours by the specified :math:`\texttt{offset}=(dx,dy)` .
|
||||
|
||||
:param contour: Pointer to the first contour.
|
||||
|
||||
:param externalColor: Color of external contours.
|
||||
|
||||
:param holeColor: Color of internal contours (holes).
|
||||
|
||||
The function draws contour outlines in the image if
|
||||
:math:`\texttt{thickness} \ge 0` or fills the area bounded by the contours if
|
||||
:math:`\texttt{thickness}<0` . The example below shows how to retrieve connected components from the binary image and label them: ::
|
||||
@@ -342,6 +363,7 @@ The function computes a contour area. Similarly to
|
||||
:ocv:func:`moments` , the area is computed using the Green formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using
|
||||
:ocv:func:`drawContours` or
|
||||
:ocv:func:`fillPoly` , can be different.
|
||||
Also, the function will most certainly give a wrong results for contours with self-intersections.
|
||||
|
||||
Example: ::
|
||||
|
||||
@@ -376,7 +398,7 @@ Finds the convex hull of a point set.
|
||||
|
||||
:param points: Input 2D point set, stored in ``std::vector`` or ``Mat``.
|
||||
|
||||
:param hull: Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the ``hull`` elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, ``hull`` elements aree the convex hull points themselves.
|
||||
:param hull: Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the ``hull`` elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, ``hull`` elements are the convex hull points themselves.
|
||||
|
||||
:param storage: Output memory storage in the old API (``cvConvexHull2`` returns a sequence containing the convex hull points or their indices).
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
@@ -62,7 +63,11 @@ PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3,
|
||||
|
||||
TEST_CYCLE() GaussianBlur(src, dst, Size(3,3), 0, 0, btype);
|
||||
|
||||
#if CV_SSE2
|
||||
SANITY_CHECK(dst, 1);
|
||||
#else
|
||||
SANITY_CHECK(dst);
|
||||
#endif
|
||||
}
|
||||
|
||||
PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3,
|
||||
|
@@ -35,5 +35,5 @@ PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
|
||||
|
||||
TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
SANITY_CHECK(dst, 2e-6);
|
||||
}
|
@@ -1767,26 +1767,26 @@ public:
|
||||
__m128i r1 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step));
|
||||
__m128i r2 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step*2));
|
||||
|
||||
__m128i b1 = _mm_add_epi16(_mm_srli_epi16(_mm_slli_epi16(r0, 8), 8),
|
||||
_mm_srli_epi16(_mm_slli_epi16(r2, 8), 8));
|
||||
__m128i b1 = _mm_add_epi16(_mm_srli_epi16(_mm_slli_epi16(r0, 8), 7),
|
||||
_mm_srli_epi16(_mm_slli_epi16(r2, 8), 7));
|
||||
__m128i b0 = _mm_add_epi16(b1, _mm_srli_si128(b1, 2));
|
||||
b1 = _mm_slli_epi16(_mm_srli_si128(b1, 2), 1);
|
||||
|
||||
__m128i g0 = _mm_add_epi16(_mm_srli_epi16(r0, 8), _mm_srli_epi16(r2, 8));
|
||||
__m128i g1 = _mm_srli_epi16(_mm_slli_epi16(r1, 8), 8);
|
||||
__m128i g0 = _mm_add_epi16(_mm_srli_epi16(r0, 7), _mm_srli_epi16(r2, 7));
|
||||
__m128i g1 = _mm_srli_epi16(_mm_slli_epi16(r1, 8), 7);
|
||||
g0 = _mm_add_epi16(g0, _mm_add_epi16(g1, _mm_srli_si128(g1, 2)));
|
||||
g1 = _mm_slli_epi16(_mm_srli_si128(g1, 2), 2);
|
||||
|
||||
r0 = _mm_srli_epi16(r1, 8);
|
||||
r1 = _mm_slli_epi16(_mm_add_epi16(r0, _mm_srli_si128(r0, 2)), 1);
|
||||
r0 = _mm_slli_epi16(r0, 2);
|
||||
|
||||
r1 = _mm_slli_epi16(_mm_add_epi16(r0, _mm_srli_si128(r0, 2)), 2);
|
||||
r0 = _mm_slli_epi16(r0, 3);
|
||||
|
||||
g0 = _mm_add_epi16(_mm_mulhi_epi16(b0, _b2y), _mm_mulhi_epi16(g0, _g2y));
|
||||
g1 = _mm_add_epi16(_mm_mulhi_epi16(b1, _b2y), _mm_mulhi_epi16(g1, _g2y));
|
||||
g0 = _mm_add_epi16(g0, _mm_mulhi_epi16(r0, _r2y));
|
||||
g1 = _mm_add_epi16(g1, _mm_mulhi_epi16(r1, _r2y));
|
||||
g0 = _mm_srli_epi16(g0, 1);
|
||||
g1 = _mm_srli_epi16(g1, 1);
|
||||
g0 = _mm_srli_epi16(g0, 2);
|
||||
g1 = _mm_srli_epi16(g1, 2);
|
||||
g0 = _mm_packus_epi16(g0, g0);
|
||||
g1 = _mm_packus_epi16(g1, g1);
|
||||
g0 = _mm_unpacklo_epi8(g0, g1);
|
||||
@@ -2667,6 +2667,13 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
|
||||
|
||||
///////////////////////////////////// YUV420 -> RGB /////////////////////////////////////
|
||||
|
||||
const int ITUR_BT_601_CY = 1220542;
|
||||
const int ITUR_BT_601_CUB = 2116026;
|
||||
const int ITUR_BT_601_CUG = -409993;
|
||||
const int ITUR_BT_601_CVG = -852492;
|
||||
const int ITUR_BT_601_CVR = 1673527;
|
||||
const int ITUR_BT_601_SHIFT = 20;
|
||||
|
||||
template<int bIdx, int uIdx>
|
||||
struct YUV420sp2RGB888Invoker
|
||||
{
|
||||
@@ -2690,13 +2697,6 @@ struct YUV420sp2RGB888Invoker
|
||||
//G = (1220542(Y - 16) - 852492(V - 128) - 409993(U - 128) + (1 << 19)) >> 20
|
||||
//B = (1220542(Y - 16) + 2116026(U - 128) + (1 << 19)) >> 20
|
||||
|
||||
const int cY = 1220542;
|
||||
const int cUB = 2116026;
|
||||
const int cUG = -409993;
|
||||
const int cVG = -852492;
|
||||
const int cVR = 1673527;
|
||||
const int YUV420_SHIFT = 20;
|
||||
|
||||
const uchar* y1 = my1 + rangeBegin * stride, *uv = muv + rangeBegin * stride / 2;
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
@@ -2715,29 +2715,29 @@ struct YUV420sp2RGB888Invoker
|
||||
int u = int(uv[i + 0 + uIdx]) - 128;
|
||||
int v = int(uv[i + 1 - uIdx]) - 128;
|
||||
|
||||
int ruv = (1 << (YUV420_SHIFT - 1)) + cVR * v;
|
||||
int guv = (1 << (YUV420_SHIFT - 1)) + cVG * v + cUG * u;
|
||||
int buv = (1 << (YUV420_SHIFT - 1)) + cUB * u;
|
||||
int ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * v;
|
||||
int guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * v + ITUR_BT_601_CUG * u;
|
||||
int buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * u;
|
||||
|
||||
int y00 = std::max(0, int(y1[i]) - 16) * cY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> YUV420_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> YUV420_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> YUV420_SHIFT);
|
||||
int y00 = std::max(0, int(y1[i]) - 16) * ITUR_BT_601_CY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y01 = std::max(0, int(y1[i + 1]) - 16) * cY;
|
||||
row1[5-bIdx] = saturate_cast<uchar>((y01 + ruv) >> YUV420_SHIFT);
|
||||
row1[4] = saturate_cast<uchar>((y01 + guv) >> YUV420_SHIFT);
|
||||
row1[3+bIdx] = saturate_cast<uchar>((y01 + buv) >> YUV420_SHIFT);
|
||||
int y01 = std::max(0, int(y1[i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row1[5-bIdx] = saturate_cast<uchar>((y01 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[4] = saturate_cast<uchar>((y01 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[3+bIdx] = saturate_cast<uchar>((y01 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y10 = std::max(0, int(y2[i]) - 16) * cY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> YUV420_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> YUV420_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> YUV420_SHIFT);
|
||||
int y10 = std::max(0, int(y2[i]) - 16) * ITUR_BT_601_CY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y11 = std::max(0, int(y2[i + 1]) - 16) * cY;
|
||||
row2[5-bIdx] = saturate_cast<uchar>((y11 + ruv) >> YUV420_SHIFT);
|
||||
row2[4] = saturate_cast<uchar>((y11 + guv) >> YUV420_SHIFT);
|
||||
row2[3+bIdx] = saturate_cast<uchar>((y11 + buv) >> YUV420_SHIFT);
|
||||
int y11 = std::max(0, int(y2[i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row2[5-bIdx] = saturate_cast<uchar>((y11 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[4] = saturate_cast<uchar>((y11 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[3+bIdx] = saturate_cast<uchar>((y11 + buv) >> ITUR_BT_601_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2766,13 +2766,6 @@ struct YUV420sp2RGBA8888Invoker
|
||||
//G = (1220542(Y - 16) - 852492(V - 128) - 409993(U - 128) + (1 << 19)) >> 20
|
||||
//B = (1220542(Y - 16) + 2116026(U - 128) + (1 << 19)) >> 20
|
||||
|
||||
const int cY = 1220542;
|
||||
const int cUB = 2116026;
|
||||
const int cUG = -409993;
|
||||
const int cVG = -852492;
|
||||
const int cVR = 1673527;
|
||||
const int YUV420_SHIFT = 20;
|
||||
|
||||
const uchar* y1 = my1 + rangeBegin * stride, *uv = muv + rangeBegin * stride / 2;
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
@@ -2791,32 +2784,32 @@ struct YUV420sp2RGBA8888Invoker
|
||||
int u = int(uv[i + 0 + uIdx]) - 128;
|
||||
int v = int(uv[i + 1 - uIdx]) - 128;
|
||||
|
||||
int ruv = (1 << (YUV420_SHIFT - 1)) + cVR * v;
|
||||
int guv = (1 << (YUV420_SHIFT - 1)) + cVG * v + cUG * u;
|
||||
int buv = (1 << (YUV420_SHIFT - 1)) + cUB * u;
|
||||
int ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * v;
|
||||
int guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * v + ITUR_BT_601_CUG * u;
|
||||
int buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * u;
|
||||
|
||||
int y00 = std::max(0, int(y1[i]) - 16) * cY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> YUV420_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> YUV420_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> YUV420_SHIFT);
|
||||
int y00 = std::max(0, int(y1[i]) - 16) * ITUR_BT_601_CY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row1[3] = uchar(0xff);
|
||||
|
||||
int y01 = std::max(0, int(y1[i + 1]) - 16) * cY;
|
||||
row1[6-bIdx] = saturate_cast<uchar>((y01 + ruv) >> YUV420_SHIFT);
|
||||
row1[5] = saturate_cast<uchar>((y01 + guv) >> YUV420_SHIFT);
|
||||
row1[4+bIdx] = saturate_cast<uchar>((y01 + buv) >> YUV420_SHIFT);
|
||||
int y01 = std::max(0, int(y1[i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row1[6-bIdx] = saturate_cast<uchar>((y01 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[5] = saturate_cast<uchar>((y01 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[4+bIdx] = saturate_cast<uchar>((y01 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row1[7] = uchar(0xff);
|
||||
|
||||
int y10 = std::max(0, int(y2[i]) - 16) * cY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> YUV420_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> YUV420_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> YUV420_SHIFT);
|
||||
int y10 = std::max(0, int(y2[i]) - 16) * ITUR_BT_601_CY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row2[3] = uchar(0xff);
|
||||
|
||||
int y11 = std::max(0, int(y2[i + 1]) - 16) * cY;
|
||||
row2[6-bIdx] = saturate_cast<uchar>((y11 + ruv) >> YUV420_SHIFT);
|
||||
row2[5] = saturate_cast<uchar>((y11 + guv) >> YUV420_SHIFT);
|
||||
row2[4+bIdx] = saturate_cast<uchar>((y11 + buv) >> YUV420_SHIFT);
|
||||
int y11 = std::max(0, int(y2[i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row2[6-bIdx] = saturate_cast<uchar>((y11 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[5] = saturate_cast<uchar>((y11 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[4+bIdx] = saturate_cast<uchar>((y11 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row2[7] = uchar(0xff);
|
||||
}
|
||||
}
|
||||
@@ -2842,13 +2835,6 @@ struct YUV420p2RGB888Invoker
|
||||
size_t uvsteps[2] = {width/2, stride - width/2};
|
||||
int usIdx = ustepIdx, vsIdx = vstepIdx;
|
||||
|
||||
const int cY = 1220542;
|
||||
const int cUB = 2116026;
|
||||
const int cUG = -409993;
|
||||
const int cVG = -852492;
|
||||
const int cVR = 1673527;
|
||||
const int YUV420_SHIFT = 20;
|
||||
|
||||
const uchar* y1 = my1 + rangeBegin * stride;
|
||||
const uchar* u1 = mu + (range.begin() / 2) * stride;
|
||||
const uchar* v1 = mv + (range.begin() / 2) * stride;
|
||||
@@ -2870,29 +2856,29 @@ struct YUV420p2RGB888Invoker
|
||||
int u = int(u1[i]) - 128;
|
||||
int v = int(v1[i]) - 128;
|
||||
|
||||
int ruv = (1 << (YUV420_SHIFT - 1)) + cVR * v;
|
||||
int guv = (1 << (YUV420_SHIFT - 1)) + cVG * v + cUG * u;
|
||||
int buv = (1 << (YUV420_SHIFT - 1)) + cUB * u;
|
||||
int ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * v;
|
||||
int guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * v + ITUR_BT_601_CUG * u;
|
||||
int buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * u;
|
||||
|
||||
int y00 = std::max(0, int(y1[2 * i]) - 16) * cY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> YUV420_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> YUV420_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> YUV420_SHIFT);
|
||||
int y00 = std::max(0, int(y1[2 * i]) - 16) * ITUR_BT_601_CY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y01 = std::max(0, int(y1[2 * i + 1]) - 16) * cY;
|
||||
row1[5-bIdx] = saturate_cast<uchar>((y01 + ruv) >> YUV420_SHIFT);
|
||||
row1[4] = saturate_cast<uchar>((y01 + guv) >> YUV420_SHIFT);
|
||||
row1[3+bIdx] = saturate_cast<uchar>((y01 + buv) >> YUV420_SHIFT);
|
||||
int y01 = std::max(0, int(y1[2 * i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row1[5-bIdx] = saturate_cast<uchar>((y01 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[4] = saturate_cast<uchar>((y01 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[3+bIdx] = saturate_cast<uchar>((y01 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y10 = std::max(0, int(y2[2 * i]) - 16) * cY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> YUV420_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> YUV420_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> YUV420_SHIFT);
|
||||
int y10 = std::max(0, int(y2[2 * i]) - 16) * ITUR_BT_601_CY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y11 = std::max(0, int(y2[2 * i + 1]) - 16) * cY;
|
||||
row2[5-bIdx] = saturate_cast<uchar>((y11 + ruv) >> YUV420_SHIFT);
|
||||
row2[4] = saturate_cast<uchar>((y11 + guv) >> YUV420_SHIFT);
|
||||
row2[3+bIdx] = saturate_cast<uchar>((y11 + buv) >> YUV420_SHIFT);
|
||||
int y11 = std::max(0, int(y2[2 * i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row2[5-bIdx] = saturate_cast<uchar>((y11 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[4] = saturate_cast<uchar>((y11 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[3+bIdx] = saturate_cast<uchar>((y11 + buv) >> ITUR_BT_601_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2914,13 +2900,6 @@ struct YUV420p2RGBA8888Invoker
|
||||
int rangeBegin = range.begin() * 2;
|
||||
int rangeEnd = range.end() * 2;
|
||||
|
||||
const int cY = 1220542;
|
||||
const int cUB = 2116026;
|
||||
const int cUG = -409993;
|
||||
const int cVG = -852492;
|
||||
const int cVR = 1673527;
|
||||
const int YUV420_SHIFT = 20;
|
||||
|
||||
size_t uvsteps[2] = {width/2, stride - width/2};
|
||||
int usIdx = ustepIdx, vsIdx = vstepIdx;
|
||||
|
||||
@@ -2945,32 +2924,32 @@ struct YUV420p2RGBA8888Invoker
|
||||
int u = int(u1[i]) - 128;
|
||||
int v = int(v1[i]) - 128;
|
||||
|
||||
int ruv = (1 << (YUV420_SHIFT - 1)) + cVR * v;
|
||||
int guv = (1 << (YUV420_SHIFT - 1)) + cVG * v + cUG * u;
|
||||
int buv = (1 << (YUV420_SHIFT - 1)) + cUB * u;
|
||||
int ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * v;
|
||||
int guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * v + ITUR_BT_601_CUG * u;
|
||||
int buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * u;
|
||||
|
||||
int y00 = std::max(0, int(y1[2 * i]) - 16) * cY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> YUV420_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> YUV420_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> YUV420_SHIFT);
|
||||
int y00 = std::max(0, int(y1[2 * i]) - 16) * ITUR_BT_601_CY;
|
||||
row1[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[1] = saturate_cast<uchar>((y00 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[bIdx] = saturate_cast<uchar>((y00 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row1[3] = uchar(0xff);
|
||||
|
||||
int y01 = std::max(0, int(y1[2 * i + 1]) - 16) * cY;
|
||||
row1[6-bIdx] = saturate_cast<uchar>((y01 + ruv) >> YUV420_SHIFT);
|
||||
row1[5] = saturate_cast<uchar>((y01 + guv) >> YUV420_SHIFT);
|
||||
row1[4+bIdx] = saturate_cast<uchar>((y01 + buv) >> YUV420_SHIFT);
|
||||
int y01 = std::max(0, int(y1[2 * i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row1[6-bIdx] = saturate_cast<uchar>((y01 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row1[5] = saturate_cast<uchar>((y01 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row1[4+bIdx] = saturate_cast<uchar>((y01 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row1[7] = uchar(0xff);
|
||||
|
||||
int y10 = std::max(0, int(y2[2 * i]) - 16) * cY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> YUV420_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> YUV420_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> YUV420_SHIFT);
|
||||
int y10 = std::max(0, int(y2[2 * i]) - 16) * ITUR_BT_601_CY;
|
||||
row2[2-bIdx] = saturate_cast<uchar>((y10 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[1] = saturate_cast<uchar>((y10 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[bIdx] = saturate_cast<uchar>((y10 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row2[3] = uchar(0xff);
|
||||
|
||||
int y11 = std::max(0, int(y2[2 * i + 1]) - 16) * cY;
|
||||
row2[6-bIdx] = saturate_cast<uchar>((y11 + ruv) >> YUV420_SHIFT);
|
||||
row2[5] = saturate_cast<uchar>((y11 + guv) >> YUV420_SHIFT);
|
||||
row2[4+bIdx] = saturate_cast<uchar>((y11 + buv) >> YUV420_SHIFT);
|
||||
int y11 = std::max(0, int(y2[2 * i + 1]) - 16) * ITUR_BT_601_CY;
|
||||
row2[6-bIdx] = saturate_cast<uchar>((y11 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row2[5] = saturate_cast<uchar>((y11 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row2[4+bIdx] = saturate_cast<uchar>((y11 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row2[7] = uchar(0xff);
|
||||
}
|
||||
}
|
||||
@@ -3027,6 +3006,128 @@ inline void cvtYUV420p2RGBA(Mat& _dst, int _stride, const uchar* _y1, const ucha
|
||||
converter(BlockedRange(0, _dst.rows/2));
|
||||
}
|
||||
|
||||
///////////////////////////////////// YUV422 -> RGB /////////////////////////////////////
|
||||
|
||||
template<int bIdx, int uIdx, int yIdx>
|
||||
struct YUV422toRGB888Invoker
|
||||
{
|
||||
Mat* dst;
|
||||
const uchar* src;
|
||||
int width, stride;
|
||||
|
||||
YUV422toRGB888Invoker(Mat* _dst, int _stride, const uchar* _yuv)
|
||||
: dst(_dst), src(_yuv), width(_dst->cols), stride(_stride) {}
|
||||
|
||||
void operator()(const BlockedRange& range) const
|
||||
{
|
||||
int rangeBegin = range.begin();
|
||||
int rangeEnd = range.end();
|
||||
|
||||
const int uidx = 1 - yIdx + uIdx * 2;
|
||||
const int vidx = (2 + uidx) % 4;
|
||||
const uchar* yuv_src = src + rangeBegin * stride;
|
||||
|
||||
for (int j = rangeBegin; j < rangeEnd; j++, yuv_src += stride)
|
||||
{
|
||||
uchar* row = dst->ptr<uchar>(j);
|
||||
|
||||
for (int i = 0; i < 2 * width; i += 4, row += 6)
|
||||
{
|
||||
int u = int(yuv_src[i + uidx]) - 128;
|
||||
int v = int(yuv_src[i + vidx]) - 128;
|
||||
|
||||
int ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * v;
|
||||
int guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * v + ITUR_BT_601_CUG * u;
|
||||
int buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * u;
|
||||
|
||||
int y00 = std::max(0, int(yuv_src[i + yIdx]) - 16) * ITUR_BT_601_CY;
|
||||
row[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row[1] = saturate_cast<uchar>((y00 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row[bIdx] = saturate_cast<uchar>((y00 + buv) >> ITUR_BT_601_SHIFT);
|
||||
|
||||
int y01 = std::max(0, int(yuv_src[i + yIdx + 2]) - 16) * ITUR_BT_601_CY;
|
||||
row[5-bIdx] = saturate_cast<uchar>((y01 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row[4] = saturate_cast<uchar>((y01 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row[3+bIdx] = saturate_cast<uchar>((y01 + buv) >> ITUR_BT_601_SHIFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<int bIdx, int uIdx, int yIdx>
|
||||
struct YUV422toRGBA8888Invoker
|
||||
{
|
||||
Mat* dst;
|
||||
const uchar* src;
|
||||
int width, stride;
|
||||
|
||||
YUV422toRGBA8888Invoker(Mat* _dst, int _stride, const uchar* _yuv)
|
||||
: dst(_dst), src(_yuv), width(_dst->cols), stride(_stride) {}
|
||||
|
||||
void operator()(const BlockedRange& range) const
|
||||
{
|
||||
int rangeBegin = range.begin();
|
||||
int rangeEnd = range.end();
|
||||
|
||||
const int uidx = 1 - yIdx + uIdx * 2;
|
||||
const int vidx = (2 + uidx) % 4;
|
||||
const uchar* yuv_src = src + rangeBegin * stride;
|
||||
|
||||
for (int j = rangeBegin; j < rangeEnd; j++, yuv_src += stride)
|
||||
{
|
||||
uchar* row = dst->ptr<uchar>(j);
|
||||
|
||||
for (int i = 0; i < 2 * width; i += 4, row += 8)
|
||||
{
|
||||
int u = int(yuv_src[i + uidx]) - 128;
|
||||
int v = int(yuv_src[i + vidx]) - 128;
|
||||
|
||||
int ruv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVR * v;
|
||||
int guv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CVG * v + ITUR_BT_601_CUG * u;
|
||||
int buv = (1 << (ITUR_BT_601_SHIFT - 1)) + ITUR_BT_601_CUB * u;
|
||||
|
||||
int y00 = std::max(0, int(yuv_src[i + yIdx]) - 16) * ITUR_BT_601_CY;
|
||||
row[2-bIdx] = saturate_cast<uchar>((y00 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row[1] = saturate_cast<uchar>((y00 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row[bIdx] = saturate_cast<uchar>((y00 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row[3] = uchar(0xff);
|
||||
|
||||
int y01 = std::max(0, int(yuv_src[i + yIdx + 2]) - 16) * ITUR_BT_601_CY;
|
||||
row[6-bIdx] = saturate_cast<uchar>((y01 + ruv) >> ITUR_BT_601_SHIFT);
|
||||
row[5] = saturate_cast<uchar>((y01 + guv) >> ITUR_BT_601_SHIFT);
|
||||
row[4+bIdx] = saturate_cast<uchar>((y01 + buv) >> ITUR_BT_601_SHIFT);
|
||||
row[7] = uchar(0xff);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#define MIN_SIZE_FOR_PARALLEL_YUV422_CONVERSION (320*240)
|
||||
|
||||
template<int bIdx, int uIdx, int yIdx>
|
||||
inline void cvtYUV422toRGB(Mat& _dst, int _stride, const uchar* _yuv)
|
||||
{
|
||||
YUV422toRGB888Invoker<bIdx, uIdx, yIdx> converter(&_dst, _stride, _yuv);
|
||||
#ifdef HAVE_TBB
|
||||
if (_dst.total() >= MIN_SIZE_FOR_PARALLEL_YUV422_CONVERSION)
|
||||
parallel_for(BlockedRange(0, _dst.rows), converter);
|
||||
else
|
||||
#endif
|
||||
converter(BlockedRange(0, _dst.rows));
|
||||
}
|
||||
|
||||
template<int bIdx, int uIdx, int yIdx>
|
||||
inline void cvtYUV422toRGBA(Mat& _dst, int _stride, const uchar* _yuv)
|
||||
{
|
||||
YUV422toRGBA8888Invoker<bIdx, uIdx, yIdx> converter(&_dst, _stride, _yuv);
|
||||
#ifdef HAVE_TBB
|
||||
if (_dst.total() >= MIN_SIZE_FOR_PARALLEL_YUV422_CONVERSION)
|
||||
parallel_for(BlockedRange(0, _dst.rows), converter);
|
||||
else
|
||||
#endif
|
||||
converter(BlockedRange(0, _dst.rows));
|
||||
}
|
||||
|
||||
}//namespace cv
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -3484,11 +3585,56 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
|
||||
src(Range(0, dstSz.height), Range::all()).copyTo(dst);
|
||||
}
|
||||
break;
|
||||
case COLOR_YUV2RGB_UYVY: case COLOR_YUV2BGR_UYVY: case COLOR_YUV2RGBA_UYVY: case COLOR_YUV2BGRA_UYVY:
|
||||
case COLOR_YUV2RGB_YUY2: case COLOR_YUV2BGR_YUY2: case COLOR_YUV2RGB_YVYU: case COLOR_YUV2BGR_YVYU:
|
||||
case COLOR_YUV2RGBA_YUY2: case COLOR_YUV2BGRA_YUY2: case COLOR_YUV2RGBA_YVYU: case COLOR_YUV2BGRA_YVYU:
|
||||
case COLOR_YUV2GRAY_UYVY: case COLOR_YUV2GRAY_YUY2:
|
||||
CV_Error(CV_StsUnsupportedFormat, "This format is not supported yet");
|
||||
case CV_YUV2RGB_UYVY: case CV_YUV2BGR_UYVY: case CV_YUV2RGBA_UYVY: case CV_YUV2BGRA_UYVY:
|
||||
case CV_YUV2RGB_YUY2: case CV_YUV2BGR_YUY2: case CV_YUV2RGB_YVYU: case CV_YUV2BGR_YVYU:
|
||||
case CV_YUV2RGBA_YUY2: case CV_YUV2BGRA_YUY2: case CV_YUV2RGBA_YVYU: case CV_YUV2BGRA_YVYU:
|
||||
{
|
||||
//http://www.fourcc.org/yuv.php#UYVY
|
||||
//http://www.fourcc.org/yuv.php#YUY2
|
||||
//http://www.fourcc.org/yuv.php#YVYU
|
||||
|
||||
if (dcn <= 0) dcn = (code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY || code==CV_YUV2RGBA_YUY2 || code==CV_YUV2BGRA_YUY2 || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 4 : 3;
|
||||
const int bidx = (code==CV_YUV2BGR_UYVY || code==CV_YUV2BGRA_UYVY || code==CV_YUV2BGR_YUY2 || code==CV_YUV2BGRA_YUY2 || code==CV_YUV2BGR_YVYU || code==CV_YUV2BGRA_YVYU) ? 0 : 2;
|
||||
const int ycn = (code==CV_YUV2RGB_UYVY || code==CV_YUV2BGR_UYVY || code==CV_YUV2RGBA_UYVY || code==CV_YUV2BGRA_UYVY) ? 1 : 0;
|
||||
const int uidx = (code==CV_YUV2RGB_YVYU || code==CV_YUV2BGR_YVYU || code==CV_YUV2RGBA_YVYU || code==CV_YUV2BGRA_YVYU) ? 1 : 0;
|
||||
|
||||
CV_Assert( dcn == 3 || dcn == 4 );
|
||||
CV_Assert( scn == 2 && depth == CV_8U );
|
||||
|
||||
_dst.create(sz, CV_8UC(dcn));
|
||||
dst = _dst.getMat();
|
||||
|
||||
switch(dcn*1000 + bidx*100 + uidx*10 + ycn)
|
||||
{
|
||||
case 3000: cvtYUV422toRGB<0,0,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3001: cvtYUV422toRGB<0,0,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3010: cvtYUV422toRGB<0,1,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3011: cvtYUV422toRGB<0,1,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3200: cvtYUV422toRGB<2,0,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3201: cvtYUV422toRGB<2,0,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3210: cvtYUV422toRGB<2,1,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 3211: cvtYUV422toRGB<2,1,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4000: cvtYUV422toRGBA<0,0,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4001: cvtYUV422toRGBA<0,0,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4010: cvtYUV422toRGBA<0,1,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4011: cvtYUV422toRGBA<0,1,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4200: cvtYUV422toRGBA<2,0,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4201: cvtYUV422toRGBA<2,0,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4210: cvtYUV422toRGBA<2,1,0>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
case 4211: cvtYUV422toRGBA<2,1,1>(dst, (int)src.step, src.ptr<uchar>()); break;
|
||||
default: CV_Error( CV_StsBadFlag, "Unknown/unsupported color conversion code" ); break;
|
||||
};
|
||||
}
|
||||
break;
|
||||
case CV_YUV2GRAY_UYVY: case CV_YUV2GRAY_YUY2:
|
||||
{
|
||||
if (dcn <= 0) dcn = 1;
|
||||
|
||||
CV_Assert( dcn == 1 );
|
||||
CV_Assert( scn == 2 && depth == CV_8U );
|
||||
|
||||
extractChannel(_src, _dst, code == CV_YUV2GRAY_UYVY ? 1 : 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CV_Error( CV_StsBadFlag, "Unknown/unsupported color conversion code" );
|
||||
|
@@ -185,7 +185,8 @@ void FilterEngine::init( const Ptr<BaseFilter>& _filter2D,
|
||||
if( rowBorderType == BORDER_CONSTANT || columnBorderType == BORDER_CONSTANT )
|
||||
{
|
||||
constBorderValue.resize(srcElemSize*borderLength);
|
||||
scalarToRawData(_borderValue, &constBorderValue[0], srcType,
|
||||
int srcType1 = CV_MAKETYPE(CV_MAT_DEPTH(srcType), MIN(CV_MAT_CN(srcType), 4));
|
||||
scalarToRawData(_borderValue, &constBorderValue[0], srcType1,
|
||||
borderLength*CV_MAT_CN(srcType));
|
||||
}
|
||||
|
||||
@@ -2804,6 +2805,8 @@ cv::Ptr<cv::BaseRowFilter> cv::getLinearRowFilter( int srcType, int bufType,
|
||||
if( sdepth == CV_32F && ddepth == CV_32F )
|
||||
return Ptr<BaseRowFilter>(new RowFilter<float, float, RowVec_32f>
|
||||
(kernel, anchor, RowVec_32f(kernel)));
|
||||
if( sdepth == CV_32F && ddepth == CV_64F )
|
||||
return Ptr<BaseRowFilter>(new RowFilter<float, double, RowNoVec>(kernel, anchor));
|
||||
if( sdepth == CV_64F && ddepth == CV_64F )
|
||||
return Ptr<BaseRowFilter>(new RowFilter<double, double, RowNoVec>(kernel, anchor));
|
||||
|
||||
|
@@ -2454,7 +2454,8 @@ void cv::remap( InputArray _src, OutputArray _dst,
|
||||
|
||||
_dst.create( map1.size(), src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
CV_Assert(dst.data != src.data);
|
||||
if( dst.data == src.data )
|
||||
src = src.clone();
|
||||
|
||||
int depth = src.depth(), map_depth = map1.depth();
|
||||
RemapNNFunc nnfunc = 0;
|
||||
@@ -2823,7 +2824,9 @@ void cv::warpAffine( InputArray _src, OutputArray _dst,
|
||||
Mat src = _src.getMat(), M0 = _M0.getMat();
|
||||
_dst.create( dsize.area() == 0 ? src.size() : dsize, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
CV_Assert( dst.data != src.data && src.cols > 0 && src.rows > 0 );
|
||||
CV_Assert( src.cols > 0 && src.rows > 0 );
|
||||
if( dst.data == src.data )
|
||||
src = src.clone();
|
||||
|
||||
const int BLOCK_SZ = 64;
|
||||
short XY[BLOCK_SZ*BLOCK_SZ*2], A[BLOCK_SZ*BLOCK_SZ];
|
||||
@@ -2966,7 +2969,9 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0,
|
||||
_dst.create( dsize.area() == 0 ? src.size() : dsize, src.type() );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
CV_Assert( dst.data != src.data && src.cols > 0 && src.rows > 0 );
|
||||
CV_Assert( src.cols > 0 && src.rows > 0 );
|
||||
if( dst.data == src.data )
|
||||
src = src.clone();
|
||||
|
||||
const int BLOCK_SZ = 32;
|
||||
short XY[BLOCK_SZ*BLOCK_SZ*2], A[BLOCK_SZ*BLOCK_SZ];
|
||||
|
@@ -75,6 +75,23 @@ template<typename T> struct MaxOp
|
||||
template<> inline uchar MinOp<uchar>::operator ()(uchar a, uchar b) const { return CV_MIN_8U(a, b); }
|
||||
template<> inline uchar MaxOp<uchar>::operator ()(uchar a, uchar b) const { return CV_MAX_8U(a, b); }
|
||||
|
||||
struct MorphRowNoVec
|
||||
{
|
||||
MorphRowNoVec(int, int) {}
|
||||
int operator()(const uchar*, uchar*, int, int) const { return 0; }
|
||||
};
|
||||
|
||||
struct MorphColumnNoVec
|
||||
{
|
||||
MorphColumnNoVec(int, int) {}
|
||||
int operator()(const uchar**, uchar*, int, int, int) const { return 0; }
|
||||
};
|
||||
|
||||
struct MorphNoVec
|
||||
{
|
||||
int operator()(uchar**, int, uchar*, int) const { return 0; }
|
||||
};
|
||||
|
||||
#if CV_SSE2
|
||||
|
||||
template<class VecUpdate> struct MorphRowIVec
|
||||
@@ -567,23 +584,6 @@ typedef MorphFVec<VMax32f> DilateVec32f;
|
||||
|
||||
#else
|
||||
|
||||
struct MorphRowNoVec
|
||||
{
|
||||
MorphRowNoVec(int, int) {}
|
||||
int operator()(const uchar*, uchar*, int, int) const { return 0; }
|
||||
};
|
||||
|
||||
struct MorphColumnNoVec
|
||||
{
|
||||
MorphColumnNoVec(int, int) {}
|
||||
int operator()(const uchar**, uchar*, int, int, int) const { return 0; }
|
||||
};
|
||||
|
||||
struct MorphNoVec
|
||||
{
|
||||
int operator()(uchar**, int, uchar*, int) const { return 0; }
|
||||
};
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
using tegra::ErodeRowVec8u;
|
||||
using tegra::DilateRowVec8u;
|
||||
@@ -623,6 +623,13 @@ typedef MorphNoVec DilateVec32f;
|
||||
|
||||
#endif
|
||||
|
||||
typedef MorphRowNoVec ErodeRowVec64f;
|
||||
typedef MorphRowNoVec DilateRowVec64f;
|
||||
typedef MorphColumnNoVec ErodeColumnVec64f;
|
||||
typedef MorphColumnNoVec DilateColumnVec64f;
|
||||
typedef MorphNoVec ErodeVec64f;
|
||||
typedef MorphNoVec DilateVec64f;
|
||||
|
||||
|
||||
template<class Op, class VecOp> struct MorphRowFilter : public BaseRowFilter
|
||||
{
|
||||
@@ -861,6 +868,9 @@ cv::Ptr<cv::BaseRowFilter> cv::getMorphologyRowFilter(int op, int type, int ksiz
|
||||
if( depth == CV_32F )
|
||||
return Ptr<BaseRowFilter>(new MorphRowFilter<MinOp<float>,
|
||||
ErodeRowVec32f>(ksize, anchor));
|
||||
if( depth == CV_64F )
|
||||
return Ptr<BaseRowFilter>(new MorphRowFilter<MinOp<double>,
|
||||
ErodeRowVec64f>(ksize, anchor));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -876,6 +886,9 @@ cv::Ptr<cv::BaseRowFilter> cv::getMorphologyRowFilter(int op, int type, int ksiz
|
||||
if( depth == CV_32F )
|
||||
return Ptr<BaseRowFilter>(new MorphRowFilter<MaxOp<float>,
|
||||
DilateRowVec32f>(ksize, anchor));
|
||||
if( depth == CV_64F )
|
||||
return Ptr<BaseRowFilter>(new MorphRowFilter<MaxOp<double>,
|
||||
DilateRowVec64f>(ksize, anchor));
|
||||
}
|
||||
|
||||
CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type));
|
||||
@@ -902,6 +915,9 @@ cv::Ptr<cv::BaseColumnFilter> cv::getMorphologyColumnFilter(int op, int type, in
|
||||
if( depth == CV_32F )
|
||||
return Ptr<BaseColumnFilter>(new MorphColumnFilter<MinOp<float>,
|
||||
ErodeColumnVec32f>(ksize, anchor));
|
||||
if( depth == CV_64F )
|
||||
return Ptr<BaseColumnFilter>(new MorphColumnFilter<MinOp<double>,
|
||||
ErodeColumnVec64f>(ksize, anchor));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -917,6 +933,9 @@ cv::Ptr<cv::BaseColumnFilter> cv::getMorphologyColumnFilter(int op, int type, in
|
||||
if( depth == CV_32F )
|
||||
return Ptr<BaseColumnFilter>(new MorphColumnFilter<MaxOp<float>,
|
||||
DilateColumnVec32f>(ksize, anchor));
|
||||
if( depth == CV_64F )
|
||||
return Ptr<BaseColumnFilter>(new MorphColumnFilter<MaxOp<double>,
|
||||
DilateColumnVec64f>(ksize, anchor));
|
||||
}
|
||||
|
||||
CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type));
|
||||
@@ -940,6 +959,8 @@ cv::Ptr<cv::BaseFilter> cv::getMorphologyFilter(int op, int type, InputArray _ke
|
||||
return Ptr<BaseFilter>(new MorphFilter<MinOp<short>, ErodeVec16s>(kernel, anchor));
|
||||
if( depth == CV_32F )
|
||||
return Ptr<BaseFilter>(new MorphFilter<MinOp<float>, ErodeVec32f>(kernel, anchor));
|
||||
if( depth == CV_64F )
|
||||
return Ptr<BaseFilter>(new MorphFilter<MinOp<double>, ErodeVec64f>(kernel, anchor));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -951,6 +972,8 @@ cv::Ptr<cv::BaseFilter> cv::getMorphologyFilter(int op, int type, InputArray _ke
|
||||
return Ptr<BaseFilter>(new MorphFilter<MaxOp<short>, DilateVec16s>(kernel, anchor));
|
||||
if( depth == CV_32F )
|
||||
return Ptr<BaseFilter>(new MorphFilter<MaxOp<float>, DilateVec32f>(kernel, anchor));
|
||||
if( depth == CV_64F )
|
||||
return Ptr<BaseFilter>(new MorphFilter<MaxOp<double>, DilateVec64f>(kernel, anchor));
|
||||
}
|
||||
|
||||
CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type));
|
||||
@@ -983,14 +1006,18 @@ cv::Ptr<cv::FilterEngine> cv::createMorphologyFilter( int op, int type, InputArr
|
||||
borderValue == morphologyDefaultBorderValue() )
|
||||
{
|
||||
int depth = CV_MAT_DEPTH(type);
|
||||
CV_Assert( depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F );
|
||||
CV_Assert( depth == CV_8U || depth == CV_16U || depth == CV_16S ||
|
||||
depth == CV_32F || depth == CV_64F );
|
||||
if( op == MORPH_ERODE )
|
||||
borderValue = Scalar::all( depth == CV_8U ? (double)UCHAR_MAX :
|
||||
depth == CV_16U ? (double)USHRT_MAX :
|
||||
depth == CV_16S ? (double)SHRT_MAX : (double)FLT_MAX );
|
||||
depth == CV_16U ? (double)USHRT_MAX :
|
||||
depth == CV_16S ? (double)SHRT_MAX :
|
||||
depth == CV_32F ? (double)FLT_MAX : DBL_MAX);
|
||||
else
|
||||
borderValue = Scalar::all( depth == CV_8U || depth == CV_16U ? 0. :
|
||||
depth == CV_16S ? (double)SHRT_MIN : (double)-FLT_MAX );
|
||||
borderValue = Scalar::all( depth == CV_8U || depth == CV_16U ?
|
||||
0. :
|
||||
depth == CV_16S ? (double)SHRT_MIN :
|
||||
depth == CV_32F ? (double)-FLT_MAX : -DBL_MAX);
|
||||
}
|
||||
|
||||
return Ptr<FilterEngine>(new FilterEngine(filter2D, rowFilter, columnFilter,
|
||||
|
@@ -308,7 +308,7 @@ pyrDown_( const Mat& _src, Mat& _dst, int borderType )
|
||||
|
||||
|
||||
template<class CastOp, class VecOp> void
|
||||
pyrUp_( const Mat& _src, Mat& _dst, int borderType )
|
||||
pyrUp_( const Mat& _src, Mat& _dst, int)
|
||||
{
|
||||
const int PU_SZ = 3;
|
||||
typedef typename CastOp::type1 WT;
|
||||
|
@@ -58,7 +58,6 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
|
||||
int cdepth = CV_MAT_DEPTH(ctype), ccn = CV_MAT_CN(ctype);
|
||||
|
||||
CV_Assert( img.dims <= 2 && templ.dims <= 2 && corr.dims <= 2 );
|
||||
CV_Assert( depth == CV_8U || depth == CV_16U || depth == CV_32F || depth == CV_64F );
|
||||
|
||||
if( depth != tdepth && tdepth != std::max(CV_32F, depth) )
|
||||
{
|
||||
@@ -74,7 +73,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
|
||||
|
||||
corr.create(corrsize, ctype);
|
||||
|
||||
int maxDepth = depth > CV_8U ? CV_64F : std::max(std::max(CV_32F, tdepth), cdepth);
|
||||
int maxDepth = depth > CV_8S ? CV_64F : std::max(std::max(CV_32F, tdepth), cdepth);
|
||||
Size blocksize, dftsize;
|
||||
|
||||
blocksize.width = cvRound(templ.cols*blockScale);
|
||||
@@ -228,14 +227,6 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
|
||||
}
|
||||
}
|
||||
|
||||
/*void
|
||||
cv::crossCorr( const Mat& img, const Mat& templ, Mat& corr,
|
||||
Point anchor, double delta, int borderType )
|
||||
{
|
||||
CvMat _img = img, _templ = templ, _corr = corr;
|
||||
icvCrossCorr( &_img, &_templ, &_corr, anchor, delta, borderType );
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
@@ -1672,11 +1672,31 @@ TEST(Imgproc_ColorRGB, accuracy) { CV_ColorRGBTest test; test.safe_run(); }
|
||||
TEST(Imgproc_ColorBayer, accuracy) { CV_ColorBayerTest test; test.safe_run(); }
|
||||
|
||||
|
||||
TEST(Imgproc_ColorBayerVNG, accuracy)
|
||||
TEST(Imgproc_ColorBayer, regression)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
|
||||
Mat given = imread(string(ts.get_data_path()) + "/cvtcolor/bayerVNG_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat given = imread(string(ts.get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat gold = imread(string(ts.get_data_path()) + "/cvtcolor/bayer_gold.png", CV_LOAD_IMAGE_UNCHANGED);
|
||||
Mat result;
|
||||
|
||||
cvtColor(given, result, CV_BayerBG2GRAY);
|
||||
|
||||
EXPECT_EQ(gold.type(), result.type());
|
||||
EXPECT_EQ(gold.cols, result.cols);
|
||||
EXPECT_EQ(gold.rows, result.rows);
|
||||
|
||||
Mat diff;
|
||||
absdiff(gold, result, diff);
|
||||
|
||||
EXPECT_EQ(0, countNonZero(diff.reshape(1) > 1));
|
||||
}
|
||||
|
||||
TEST(Imgproc_ColorBayerVNG, regression)
|
||||
{
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
|
||||
Mat given = imread(string(ts.get_data_path()) + "/cvtcolor/bayer_input.png", CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat gold = imread(string(ts.get_data_path()) + "/cvtcolor/bayerVNG_gold.png", CV_LOAD_IMAGE_UNCHANGED);
|
||||
Mat result;
|
||||
|
||||
|
@@ -477,10 +477,7 @@ INSTANTIATE_TEST_CASE_P(cvt420, Imgproc_ColorYUV,
|
||||
(int)CV_YUV2RGBA_YV12, (int)CV_YUV2BGRA_YV12, (int)CV_YUV2RGBA_IYUV, (int)CV_YUV2BGRA_IYUV,
|
||||
(int)CV_YUV2GRAY_420));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(DISABLED_cvt888, Imgproc_ColorYUV,
|
||||
::testing::Values((int)CV_YUV2BGR, (int)CV_YUV2RGB));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(DISABLED_cvt422, Imgproc_ColorYUV,
|
||||
INSTANTIATE_TEST_CASE_P(cvt422, Imgproc_ColorYUV,
|
||||
::testing::Values((int)CV_YUV2RGB_UYVY, (int)CV_YUV2BGR_UYVY, (int)CV_YUV2RGBA_UYVY, (int)CV_YUV2BGRA_UYVY,
|
||||
(int)CV_YUV2RGB_YUY2, (int)CV_YUV2BGR_YUY2, (int)CV_YUV2RGB_YVYU, (int)CV_YUV2BGR_YVYU,
|
||||
(int)CV_YUV2RGBA_YUY2, (int)CV_YUV2BGRA_YUY2, (int)CV_YUV2RGBA_YVYU, (int)CV_YUV2BGRA_YVYU,
|
||||
|
@@ -1775,3 +1775,107 @@ TEST(Imgproc_MinEigenVal, accuracy) { CV_MinEigenValTest test; test.safe_run();
|
||||
TEST(Imgproc_EigenValsVecs, accuracy) { CV_EigenValVecTest test; test.safe_run(); }
|
||||
TEST(Imgproc_PreCornerDetect, accuracy) { CV_PreCornerDetectTest test; test.safe_run(); }
|
||||
TEST(Imgproc_Integral, accuracy) { CV_IntegralTest test; test.safe_run(); }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CV_FilterSupportedFormatsTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
CV_FilterSupportedFormatsTest() {}
|
||||
~CV_FilterSupportedFormatsTest() {}
|
||||
protected:
|
||||
void run(int)
|
||||
{
|
||||
const int depths[][2] =
|
||||
{
|
||||
{CV_8U, CV_8U},
|
||||
{CV_8U, CV_16U},
|
||||
{CV_8U, CV_16S},
|
||||
{CV_8U, CV_32F},
|
||||
{CV_8U, CV_64F},
|
||||
{CV_16U, CV_16U},
|
||||
{CV_16U, CV_32F},
|
||||
{CV_16U, CV_64F},
|
||||
{CV_16S, CV_16S},
|
||||
{CV_16S, CV_32F},
|
||||
{CV_16S, CV_64F},
|
||||
{CV_32F, CV_32F},
|
||||
{CV_64F, CV_64F},
|
||||
{-1, -1}
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
volatile int fidx = -1;
|
||||
try
|
||||
{
|
||||
// use some "odd" size to do yet another smoke
|
||||
// testing of the non-SIMD loop tails
|
||||
Size sz(163, 117);
|
||||
Mat small_kernel(5, 5, CV_32F), big_kernel(21, 21, CV_32F);
|
||||
Mat kernelX(11, 1, CV_32F), kernelY(7, 1, CV_32F);
|
||||
Mat symkernelX(11, 1, CV_32F), symkernelY(7, 1, CV_32F);
|
||||
randu(small_kernel, -10, 10);
|
||||
randu(big_kernel, -1, 1);
|
||||
randu(kernelX, -1, 1);
|
||||
randu(kernelY, -1, 1);
|
||||
flip(kernelX, symkernelX, 0);
|
||||
symkernelX += kernelX;
|
||||
flip(kernelY, symkernelY, 0);
|
||||
symkernelY += kernelY;
|
||||
|
||||
Mat elem_ellipse = getStructuringElement(MORPH_ELLIPSE, Size(7, 7));
|
||||
Mat elem_rect = getStructuringElement(MORPH_RECT, Size(7, 7));
|
||||
|
||||
for( i = 0; depths[i][0] >= 0; i++ )
|
||||
{
|
||||
int sdepth = depths[i][0];
|
||||
int ddepth = depths[i][1];
|
||||
Mat src(sz, CV_MAKETYPE(sdepth, 5)), dst;
|
||||
randu(src, 0, 100);
|
||||
// non-separable filtering with a small kernel
|
||||
fidx = 0;
|
||||
filter2D(src, dst, ddepth, small_kernel);
|
||||
fidx++;
|
||||
filter2D(src, dst, ddepth, big_kernel);
|
||||
fidx++;
|
||||
sepFilter2D(src, dst, ddepth, kernelX, kernelY);
|
||||
fidx++;
|
||||
sepFilter2D(src, dst, ddepth, symkernelX, symkernelY);
|
||||
fidx++;
|
||||
Sobel(src, dst, ddepth, 2, 0, 5);
|
||||
fidx++;
|
||||
Scharr(src, dst, ddepth, 0, 1);
|
||||
if( sdepth != ddepth )
|
||||
continue;
|
||||
fidx++;
|
||||
GaussianBlur(src, dst, Size(5, 5), 1.2, 1.2);
|
||||
fidx++;
|
||||
blur(src, dst, Size(11, 11));
|
||||
fidx++;
|
||||
morphologyEx(src, dst, MORPH_GRADIENT, elem_ellipse);
|
||||
fidx++;
|
||||
morphologyEx(src, dst, MORPH_GRADIENT, elem_rect);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "Combination of depths %d => %d in %s is not supported (yet it should be)",
|
||||
depths[i][0], depths[i][1],
|
||||
fidx == 0 ? "filter2D (small kernel)" :
|
||||
fidx == 1 ? "filter2D (large kernel)" :
|
||||
fidx == 2 ? "sepFilter2D" :
|
||||
fidx == 3 ? "sepFilter2D (symmetrical/asymmetrical kernel)" :
|
||||
fidx == 4 ? "Sobel" :
|
||||
fidx == 5 ? "Scharr" :
|
||||
fidx == 6 ? "GaussianBlur" :
|
||||
fidx == 7 ? "blur" :
|
||||
fidx == 8 || fidx == 9 ? "morphologyEx" :
|
||||
"unknown???");
|
||||
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Imgproc_Filtering, supportedFormats) { CV_FilterSupportedFormatsTest test; test.safe_run(); }
|
||||
|
||||
|
@@ -391,3 +391,33 @@ void CV_HuMomentsTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
|
||||
TEST(Imgproc_Moments, accuracy) { CV_MomentsTest test; test.safe_run(); }
|
||||
TEST(Imgproc_HuMoments, accuracy) { CV_HuMomentsTest test; test.safe_run(); }
|
||||
|
||||
class CV_SmallContourMomentTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
CV_SmallContourMomentTest() {}
|
||||
~CV_SmallContourMomentTest() {}
|
||||
protected:
|
||||
void run(int)
|
||||
{
|
||||
try
|
||||
{
|
||||
vector<Point> points;
|
||||
points.push_back(Point(50, 56));
|
||||
points.push_back(Point(53, 53));
|
||||
points.push_back(Point(46, 54));
|
||||
points.push_back(Point(49, 51));
|
||||
|
||||
Moments m = moments(points, false);
|
||||
double area = contourArea(points);
|
||||
|
||||
CV_Assert( m.m00 == 0 && m.m01 == 0 && m.m10 == 0 && area == 0 );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Imgproc_ContourMoment, small) { CV_SmallContourMomentTest test; test.safe_run(); }
|
||||
|
Reference in New Issue
Block a user