HarrisCorner
Implements Harris corner detection algorithm.
Syntax
IppStatus ippiHarrisCorner_8u32f_C1R(const Ipp8u*
pSrc
, int
srcStep
, Ipp32f*
pDst
, int
dstStep
, IppiSize
roiSize
, IppiDifferentialKernel
filterType
, IppiMaskSize
filterMask
, Ipp32u
avgWndSize
, float
k
, float
scale
, IppiBorderType
borderType
, Ipp8u
borderValue
, Ipp8u*
pBuffer
);
IppStatus ippiHarrisCorner_32f_C1R(const Ipp32f*
pSrc
, int
srcStep
, Ipp32f*
pDst
, int
dstStep
, IppiSize
roiSize
, IppiDifferentialKernel
filterType
, IppiMaskSize
filterMask
, Ipp32u
avgWndSize
, float
k
, float
scale
, IppiBorderType
borderType
, Ipp32f
borderValue
, Ipp8u*
pBuffer
);
Include Files
ippcv.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
,
ipps.h
,
ippi.h
Libraries:
ippcore.lib
,
ippvm.lib
,
ipps.lib
,
ippi.lib
Parameters
- pSrc
- Pointer to the source image.
- srcStep
- Distance, in bytes, between the starting points of consecutive lines in the source image.
- pDst
- Pointer to the destination image.
- dstStep
- Distance, in bytes, between the starting points of consecutive lines in the destination image.
- roiSize
- Size of the source and destination image ROI in pixels.
- filterType
- Type of the derivative operator. Possible values are:
- ippKernelSobel
- Sobel filter
- ippKernelScharr
- Scharr filter
- ippKernelCentralDiff
- Central differences operator
- filterMask
- Size of the derivative filter aperture. The list of possible values depends on thefilterTypevalue:Filter TypeFilter MaskippKernelSobelippMskSize3x3,ippMskSize5x5ippKernelScharrippMskSize3x3ippKernelCentralDiffippMskSize3x3
- avgWndSize
- Linear size of a neighborhood block for averaging.
- k
- Harris detector free coefficient.
- scale
- Destination image scale factor.
- borderType
- Type of border. Possible values are:
- ippBorderConst
- Values of all border pixels are set to constant.
- ippBorderRepl
- Border is replicated from the edge pixels.
- ippBorderInMem
- Border is obtained from the source image pixels in memory.
- ippBorderMirror
- Border pixels are mirrored from the source image boundary pixels.
Mixed borders are also supported. They can be obtained by the bitwise operation OR betweenippBorderReplorippBorderConstand the following flags:- ippBorderInMemTop
- ippBorderInMemBottom
- ippBorderInMemLeft
- ippBorderInMemRight
- borderValue
- Constant value(s) to assign to pixels of the constant border. This parameter is applicable only to theippBorderConstborder type. TheippiHarrisCornerfunction uses the specified constant value only at the first stage of the algorithm. At the third stage, the function uses zero constant border.
- pBuffer
- Pointer to the pre-allocated temporary buffer. To calculate the size of the temporary buffer, use the HarrisCornerGetBufferSize function.
Description
This function goes through the following stages to implement the Harris corner detection algorithm:
- ComputesI(x,y)andxI(x,y)gradients for each (yx,y) pixel of the image. The function computes gradients using the derivative operator specified by thefilterTypeandfilterMaskparameters.
- Computes products of the gradients at each (x,y) pixel of the image:
- Performs averaging of the products of gradients over a rectangular neighborhood block at each pixel of the image. The block size is specified by theavgWndSizevalue.
- Defines 2x2 gradient covariance matrixH(over a rectangular neighborhood block for each (x,y)x,y) pixel of the image.
- Computes the corner response at each pixel of the image:wherekis the Harris detector free parameter
The first and third stages of the function algorithm are filtering operations; they use border processing approach that is specified by the
borderType
parameter.The
scale
parameter is applied to the output image.Before using this function, compute the size of the temporary work buffer using the HarrisCornerGetBufferSize function.
Return Values
- ippStsNoErr
- Indicates no error. Any other value indicates an error or a warning.
- ippStsNullPtrErr
- Indicates an error whenpSrc,pDst, orpBufferSizeisNULL.
- ippStsSizeErr
- Indicates an error in the following cases:
- whenroiSizeis less than, or equal to zero
- whenavgWndSizeis equal to zero
- ippStsNotEvenStepErr
- Indicates an error when one of the step values is not divisible by 4 for floating point images.
- ippStsFilterTypeErr
- Indicates an error whenfilterTypehas an illegal value.
- ippStsMaskSizeErr
- Indicates an error whenfilterMaskhas an illegal value.
- ippStsBorderErr
- Indicates an error whenborderTypehas an illegal value.
- ippStsStepErr
- Indicates an error whensrcStepordstStephas a negative value.
- ippStsInplaceModeNotSupportedErr
- Indicates an error whenpSrcandpDstpoint to the same image.
Example
The code example below demonstrates how to use the
ippiHarrisCorner_8u32f_C1R
and ippiHarrisCornerGetBufferSize
functions.... int bufSize = 0; Ipp8u* pBuffer = 0; Ipp32u numChannels = 1; IppStatus status = ippStsNoErr; IppiBorderType borderType = ippBorderRepl; IppiDifferentialKernel filterType = ippFilterSobel; IppiMaskSize filterMask = ippMskSize5x5; Ipp32u avgWndSize = 3; Ipp32f scale = 1.0f; /* Computes the temporary work buffer size */ status = ippiHarrisCornerGetBufferSize(roiSize, filterMask, avgWndSize, ipp8u, numChannels, &bufSize); /* Memory allocation */ if (status != ippStsNoErr) pBuffer = ippsMalloc_8u(bufSize); if (pBuffer != NULL) { /* Harris Corner processing */ status = ippiHarrisCorner_8u32f_C1R(pSrc, srcStep, pDst, dstStep, roiSize, filterType, filterMask, avgWndSize, 0.04f, scale, borderType, 0, pBuffer); ippsFree(pBuffer); } ...