Displace X-Y on centroid

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

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 close merge delete

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 -0500 )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 -0500 )edit

you would need to know the orientation then.

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