# Coordinates in contour not Accurate/smooth

I'm working on a people counter system and i'm getting the coordinate of each blob detected through the following code:

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):
center = (int(x),int(y))
cv2.circle(frame,center,1,(0,255,0),-1)
if x>400 and x<450:
if (abs(prev_x-x))>25:
cv2.circle(frame,center,1,(0,255,0),-1)
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? Mine is moving too waywardly and the moving of centres arent linear. If there's a different algorithm available then please do suggest. Thanks.

edit retag close merge delete