Skip to content
/ hogpp Public

Fast computation of rectangular histogram of oriented gradients (R-HOG) features using integral histogram

License

Notifications You must be signed in to change notification settings

sergiud/hogpp

Repository files navigation

HOGpp

Linux macOS Windows codecov Documentation Status PyPI - Version

This repository contains an implementation of the rectangular histogram of oriented gradients feature descriptor (R-HOG) using integral histograms. The integral histogram representation allows to quickly compute HOG features in subregions of an image in constant time. This is particularly useful if the features in an image must be computed repeatedly, e.g., in a sliding window manner.

Features

  • C++ templated implementation
  • Python support for 32, 64, and 80 bit floating point precision
  • Unrestricted input size (e.g., OpenCV as of version 4.5.5 requires the input to be a multiple of the block size)
  • Support for arbitrary integer (8 bit to 64 bit, both signed and unsigned) and floating point input (e.g., OpenCV requires 8-bit unsigned integer input)
  • Masking support (i.e., spatial exclusion of gradient magnitudes from contributing to features)

For a complete summary of differences between HOGpp and existing implementations, refer to the feature matrix.

Getting Started

In Python:

from hogpp import IntegralHOGDescriptor

desc = IntegralHOGDescriptor()
# Load image
image = # ...
# Precompute the gradient histograms. This needs to be done only once for each image.
desc.compute(image)
# Extract the feature descriptor of a region of interest. The method can be
# called multiple times for different subregions of the above image. Note the
# use of matrix indexing along each axis opposed to Cartesian coordinates.
roi = (0, 0, 128, 64) # top left (row, column) size (height, width)
X = desc(roi)

License

HOGpp is provided under the Apache License 2.0.