Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to extract a feature from OpenCV instead of skimage?

I'd like to use import cv2 instead of from skimage import feature with local_binary_pattern because GPU doesn't support skimage library and I need to use it in real-time which requires high frame per second.

Full my code:

# import the necessary packages
from skimage import feature
import numpy as np
# import cupy as np

class LocalBinaryPatterns:
    def __init__(self, numPoints, radius):
        # store the number of points and radius
        self.numPoints = numPoints
        self.radius = radius

    def describe(self, image, eps=1e-7):
        # compute the Local Binary Pattern representation
        # of the image, and then use the LBP representation
        # to build the histogram of patterns
        lbp = feature.local_binary_pattern(image, self.numPoints,
            self.radius, method="uniform")


        (hist, _) = np.histogram(lbp.ravel(),
            bins=np.arange(0, self.numPoints + 3),
            range=(0, self.numPoints + 2))

        # normalize the histogram
        hist = hist.astype("float")
        hist /= (hist.sum() + eps)

        # return the histogram of Local Binary Patterns
        return hist

For copyright, you can get it here

Please help me or any suggestions?

Thank you in advance!