How to extract a feature from OpenCV instead of skimage?

asked 2020-04-08 21:54:42 -0600

redhwan gravatar image

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!

edit retag flag offensive close merge delete

Comments

1

unfortunately, opencv has no real equivalent (save something GPU optimized) for this.

berak gravatar imageberak ( 2020-04-09 05:25:28 -0600 )edit