Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can i get angle and line length in Python OpenCV

I have a chunk of code to get start, end, far variable from Convexity Defects :

    hull = cv2.convexHull(cnt,returnPoints = False)
    defects = cv2.convexityDefects(cnt,hull)

    for i in range(defects.shape[0]):
        s,e,f,d = defects[i,0]
        start = tuple(cnt[s][0])
        end = tuple(cnt[e][0])
        far = tuple(cnt[f][0])

        cv2.line(res,far,end,[0,255,0],2)
        cv2.line(res,start,far,[0,255,0],2)

I need to dismissed convexity defect from finger if:

line_length<0.4lbb and angle>80o

So How can i get angle and line length value from those start, end, far variable? and dismissed convexity defect from given rule?

click to hide/show revision 2
retagged

updated 2014-04-01 03:54:51 -0500

berak gravatar image

How can i get angle and line length in Python OpenCV

I have a chunk of code to get start, end, far variable from Convexity Defects :

    hull = cv2.convexHull(cnt,returnPoints = False)
    defects = cv2.convexityDefects(cnt,hull)

    for i in range(defects.shape[0]):
        s,e,f,d = defects[i,0]
        start = tuple(cnt[s][0])
        end = tuple(cnt[e][0])
        far = tuple(cnt[f][0])

        cv2.line(res,far,end,[0,255,0],2)
        cv2.line(res,start,far,[0,255,0],2)

I need to dismissed convexity defect from finger if:

line_length<0.4lbb and angle>80o

So How can i get angle and line length value from those start, end, far variable? and dismissed convexity defect from given rule?