Skip to content

Instantly share code, notes, and snippets.

@amarlearning
Created July 28, 2018 16:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amarlearning/9c554ebb244c11653b44c9c4e5c1f2dc to your computer and use it in GitHub Desktop.
Save amarlearning/9c554ebb244c11653b44c9c4e5c1f2dc to your computer and use it in GitHub Desktop.
def manage_image_opr(frame, hand_hist):
hist_mask_image = hist_masking(frame, hand_hist)
contour_list = contours(hist_mask_image)
max_cont = max_contour(contour_list)
cnt_centroid = centroid(max_cont)
cv2.circle(frame, cnt_centroid, 5, [255, 0, 255], -1)
if max_cont is not None:
hull = cv2.convexHull(max_cont, returnPoints=False)
defects = cv2.convexityDefects(max_cont, hull)
far_point = farthest_point(defects, max_cont, cnt_centroid)
print("Centroid : " + str(cnt_centroid) + ", farthest Point : " + str(far_point))
cv2.circle(frame, far_point, 5, [0, 0, 255], -1)
if len(traverse_point) < 20:
traverse_point.append(far_point)
else:
traverse_point.pop(0)
traverse_point.append(far_point)
draw_circles(frame, traverse_point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment