Displace X-Y on centroid [closed]

asked 2018-11-27 15:56:01 -0600

Hatmpatn gravatar image

Hello! I'm doing a project where I want a robot to pick up a part on the middle of the biggest area of my part. I was hoping I could be lucky the the centroid returned from cv2.moments would return the center of mass on exactly this spot but I'm afraid that is not the case.

All my parts in the image are rotated different from one another. Can I somehow modify the Moments returned values in that way that I displace the centroid a set of pixles?

Red dot is the centroid image description

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-06 11:43:34.608382

Comments

unfortunately, the center of mass seems to be entirely correctly calculated in your image.

maybe the problem is, that you did not want that ? (think of an U. the center of mass is not part of the letter)

berak gravatar imageberak ( 2018-11-28 03:37:55 -0600 )edit

Yes, I agree, it is correctly calculated. But is there a way to move the centroid, as like 20px in X and 30px in Y?

Hatmpatn gravatar imageHatmpatn ( 2018-11-28 04:13:02 -0600 )edit

you would need to know the orientation then.

berak gravatar imageberak ( 2018-11-28 04:15:59 -0600 )edit