12

I have already seen that OpenCV provides a classifier based on LBP histograms:

But I want to have access to the LBP histogram itself. For instance:

histogram = calculate_LBP_Histogram( image )

Is there any function that performs this in OpenCV?

Tonechas
  • 13,398
  • 16
  • 46
  • 80
EijiAdachi
  • 441
  • 1
  • 3
  • 15

1 Answers1

21

You can get the C++ code for computing LBP using OpenCV's Mat data structure here:

http://www.bytefish.de/blog/local_binary_patterns

You should be able to find the Python version as well on the same site.

The code is written by Philipp Wagner, who I believe contributed the face recognition code you mentioned to OpenCV, so it should be the same thing.

The LBP code is found in the file: OpenCV-2.4.2/modules/contrib/src/facerec.cpp as a static function. Unfortunately, it does not appear to be exposed for public use (at least for OpenCV 2.4.2).

lightalchemist
  • 10,031
  • 4
  • 47
  • 55
  • Thanks, Do you know what additional changes need to be done (besides removing the `static` from the LBP functions, and building the project) to expose this in the Python version of OpenCV? – eran Aug 25 '13 at 07:37
  • 1
    Hi @eran. If you wish to have LBP available using Python, consider the scikit-image library: http://scikit-image.org/docs/dev/auto_examples/plot_local_binary_pattern.html But otherwise to make the LBP available for Python you need to do additional work to write the Python bindings for that function. – lightalchemist Aug 26 '13 at 02:04
  • 2
    Thanks! I managed to do it, see http://stackoverflow.com/questions/18426765/exposing-the-lbp-descriptors-from-opencv-in-python/18431418#18431418 – eran Aug 26 '13 at 05:28