Code Monkey home page Code Monkey logo

fingers-detection-using-opencv-and-python's Issues

Cannot open the window of camera

Hi, when i was test the code you put, the light of the camera becomes green. However, the window is not open. i am new in this area. How could i fix this problem?

More than 3 has been identified as 2

After running the program, the effect is not good. The background is solid, but it seems that there is a lot of white noise in the subtracted background binary image, only 1 and 2 are recognized, and 3 or more has been identified as 2

Deprecated code

This line

 bgModel = cv2.BackgroundSubtractorMOG2(0, bgSubThreshold)

should be

cv2.createBackgroundSubtractorMOG2(0, bgSubThreshold)

and

contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

should be

x, contours, y = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

Background is not substracting

Hello, I tried to use your code (only the part of substracting the background) , but seems like nothing is happening. The image i give input, the code simply shows me the same image.

Small change to calculateFingers

How about moving the plotting of the circle outside the defand then using the new cavity_pts output to plot the points?

PS. What kind of license you have for your software? Can I use a modified version of this function in a non-commercial research purpose? How do you want yourself to be mentioned if you allow the usage?

def calculateFingers(max_c):
    """
    https://github.com/lzane/Fingers-Detection-using-OpenCV-and-Python/blob/master/new.py#L39-L60
    """
    hull = cv2.convexHull(max_c, returnPoints=False)
    if len(hull) > 3:
        try:
            defects = cv2.convexityDefects(max_c, hull)
        except Exception:
            defects = None
        
        counter = 0
        if defects is not None:
            cavity_pts = []
            for i in range(defects.shape[0]):  # calculate the angle
                s, e, f, d = defects[i][0]
                start = tuple(max_c[s][0])
                end = tuple(max_c[e][0])
                far = tuple(max_c[f][0])
                a = math.sqrt((end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2)
                b = math.sqrt((far[0] - start[0]) ** 2 + (far[1] - start[1]) ** 2)
                c = math.sqrt((end[0] - far[0]) ** 2 + (end[1] - far[1]) ** 2)
                angle = math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c))  # cosine theorem
                if angle <= math.pi / 2:  # angle less than 90 degree, treat as fingers
                    counter += 1
                    cavity_pts.append(far)
            return counter, cavity_pts
    return 0, []

An error occurred after pressing'b'.

line 96, in
_,contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

cannot running as demo

when i press b to get background and n to start,it can running a little time but gradually my hand integrate into backgroud(black).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.