I'm trying to detect hand with OpenCV on Python.
I am working on this thresholded image:
And that's contour drawed state:
I am trying to detect hand, but contour is too big, it captures my whole body.
I need it like this:
My code:
import cv2
orImage = cv2.imread("f.png")
image = cv2.cvtColor(orImage,cv2.COLOR_BGR2GRAY)
image = cv2.blur(image,(15,15))
(_,img_th) = cv2.threshold(image,96,255,1)
(contours,_) = cv2.findContours(img_th, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
for c in contours:
if cv2.contourArea(c) > 15:
x,y,w,h = cv2.boundingRect(c)
cv2.rectangle(image,(x-20,y-20),(x+w+20,y+h+20),(0,255,0),2)
cv2.drawContours(image,contours,-1,(255,0,0),2)
cv2.imwrite("hi.jpg",image)
Thanks!