Developer Reference

  • 2020
  • 07/15/2020
  • Public Content
Contents

HOG

Computes the HOG descriptor.

Syntax

IppStatus ippiHOG_<mod>(const Ipp<srcDatatype>*
pSrc
, int
srcStep
, IppiSize
roiSize
, const IppiPoint*
pLocation
, int
nLocations
, Ipp32f*
pDst
, const IppiHOGSpec*
pHOGSpec
, IppiBorderType
borderID
, Ipp<srcDatatype>
borderValue
, Ipp8u*
pBuffer
);
Supported values for
mod
:
8u32f_C1R
16u32f_C1R
16s32f_C1R
32f_C1R
IppStatus ippiHOG_<mod>(const Ipp<srcDatatype>*
pSrc
, int
srcStep
, IppiSize
roiSize
, const IppiPoint*
pLocation
, int
nLocations
, Ipp32f*
pDst
, const IppiHOGSpec*
pHOGCtx
, IppiBorderType
borderID
, Ipp<srcDatatype>
borderValue
[3], Ipp8u*
pBuffer
);
Supported values for
mod
:
8u32f_C3R
16u32f_C3R
16s32f_C3R
32f_C3R
Include Files
ippi.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
,
ipps.h
Libraries:
ippcore.lib
,
ippvm.lib
,
ipps.lib
Parameters
pSrc
Pointer to the source image ROI.
srcStep
Distance, in bytes, between the starting points of consecutive lines in the source image.
roiSize
Size of the source image ROI, in pixels.
pLocation
Pointer to the array with detection window locations.
nLocations
Number of locations.
pDst
Pointer to the HOG descriptor.
pHOGCtx
,
pHOGSpec
Pointer to the HOG context/specification structure.
borderID
Type of border. Possible values are:
ippBorderConst
Values of all border pixels are set to a 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 between
ippBorderRepl
and
ippBorderInMemTop
,
ippBorderInMemBottom
,
ippBorderInMemLeft
,
ippBorderInMemRight
.
borderValue
Constant value to assign to pixels of the constant border. This parameter is applicable only to the
ippBorderConst
border type.
pBuffer
Pointer to the work buffer.
Description
This function computes the HOG descriptor over defined locations of the detection window. Flavors with the
C1
suffix operate on one-channel (gray) images, and
C3
flavors operate on color images.
Before using this function, compute the size of the context structure, work buffer, and descriptor using the HOGGetSize, HOGGetBufferSize, and HOGGetDescriptorSize functions, respectively. To initialize the HOG context structure, use the HOGInit function.
Return Values
ippStsNoErr
Indicates no error. Any other value indicates an error or a warning.
ippStsNullPtrErr
Indicates an error when one of the specified pointers is
NULL
.
ippStsContextmatchErr
Indicates an error when the context parameter does not match the operation.
ippStsStepErr
Indicates an error when
srcStep
is less than, or equal to zero.
ippStsNotEvenStepErr
Indicates an error when
srcStep
is not divisible by input data type size.
ippStsBorderErr
Indicates an error when
borderID
has an illegal value.
ippStsSizeErr
Indicates an error when
roiSize
is less than, or equal to zero.

Example

/******************************************************************************* * Copyright 2015-2020 Intel Corporation. * * This software and the related documents are Intel copyrighted materials, and * your use of them is governed by the express license under which they were * provided to you (License). Unless the License provides otherwise, you may not * use, modify, copy, publish, distribute, disclose or transmit this software or * the related documents without Intel's prior written permission. * * This software and the related documents are provided as is, with no express * or implied warranties, other than those that are expressly stated in the * License. *******************************************************************************/ // A simple example of computing HOG descriptor using Intel(R) Integrated Primitives (Intel(R) IPP) functions: // ippiHOGGetSize // ippiHOGInit // ippiHOGGetBufferSize // ippiHOGGetDescriptorSize // ippiHOG_8u32f_C1R #include <stdio.h> #include "ipp.h" #define WIND_WIDTH 64 /* detection window width */ #define WIND_HEIGHT 128 /* detection window image height */ /* Next two defines are created to simplify code reading and understanding */ #define EXIT_MAIN exitLine: /* Label for Exit */ #define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */ /* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */ static IppiHOGConfig config = { /* HOG configure structure */ 1, /* Use OpenCV compatible output format */ 8, /* Cell size (pixels) */ 16, /* Block size (pixels) */ 8, /* Block stride size (pixels) */ 9, /* Number of bins (orientations) in the histogram */ 1.0f, /* Sigma value (in the applied Gaussian) */ 0.2f, /* Threshold value (applied for normalization) */ {WIND_WIDTH, WIND_HEIGHT}, /* Size (width and height in pixels) of detection window */ }; int main(void) { IppStatus status = ippStsNoErr; Ipp8u* pSrc = NULL; /* Pointers to source/destination/feature images */ int srcStep = 0; /* Steps, in bytes, through the source/destination/feature images */ IppiSize roiSize = { WIND_WIDTH, WIND_HEIGHT }; /* Size of source ROI in pixels */ const Ipp8u borderValue = 0; IppiHOGSpec* pHOGctx = NULL; /* Pointer to the HOG context */ int hogCtxSize = 0, hogBuffSize = 0, winBuffSize = 0; /* Sizes of buffers */ Ipp8u* pBuffer = NULL; /* Pointer to the work buffer */ IppiPoint loc[] = { { 0, 0 }, { 2, 1 }, { 4, 2 }, { 6, 3 } }; /* Locations of detection window */ int numLocs = sizeof(loc) / sizeof(IppiPoint); Ipp32f* pDescriptor = NULL; /* HOG descriptor */ check_sts( status = ippiHOGGetSize(&config, &hogCtxSize) ) /* Get size of HOG context */ pHOGctx = (IppiHOGSpec*)ippsMalloc_8u(hogCtxSize); check_sts( status = ippiHOGInit(&config, pHOGctx) ) /* Initialize HOG context */ pSrc = ippiMalloc_8u_C1(roiSize.width, roiSize.height, &srcStep); /* Compute the temporary work buffer size */ check_sts( status = ippiHOGGetBufferSize(pHOGctx, roiSize, &hogBuffSize) ) pBuffer = ippsMalloc_8u(hogBuffSize); /* Compute size of HOG descriptor */ check_sts( status = ippiHOGGetDescriptorSize(pHOGctx, &winBuffSize) ) pDescriptor = (Ipp32f*)ippsMalloc_8u(numLocs*winBuffSize); check_sts( status = ippiHOG_8u32f_C1R(pSrc, srcStep, roiSize, /* Compute HOG descriptor */ loc, numLocs, pDescriptor, pHOGctx, ippBorderConst, borderValue, pBuffer) ) EXIT_MAIN ippiFree(pSrc); ippsFree(pHOGctx); ippsFree(pBuffer); ippsFree(pDescriptor); printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status)); return (int)status; }

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804