I'm working on a people counter system and i'm getting the coordinate of each blob detected through the following code: if area>100: contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE) try: hierarchy = hierarchy[0] except: hierarchy = [] for contour, hier in zip(contours, hierarchy): (x,y,w,h) = cv2.boundingRect(contour) if w>40 and h>40:
if x>400 and x<450:
if (abs(prev_x-x))>30:
cv2.circle(frame,(int(x),int(y)),10,(0,255,0),-1)
cv2.rectangle(frame, (x,y),(x+10,y+10), (255, 0, 0), 0)
j=j+1
prev_x=x
Now the coordinates from the rectangle i'm getting isn't smooth. Moreover the centre of circle i'm getting is'nt stable. Can anyone please suggest a better solution at getting the coordinates of each blob/contour smmothly which is not prone to noise and is stable? If there's a different algorithm available then please do suggest. Thanks.