I have used a bounding box to get the pair of 4-points around an object after RANSAC and conditional outlier removal during the segmentation and filtration process. After computing the 8 corner points of the bounding box, I have used 2 of them (front below) to localize the robot. for e.g following is a visual of the extracted object with the corner-points I intend to use
The problem is if the object is straight like above the robot moves correctly almost in the middle but if the object is tilted the robot moves more on the right or left depending on which side it is tilted for example
After analysis it seems that bounding box points are not exactly but with a offset on the object. What can be helpful in this situation ?
-adding a manual offset on the corner points
-adjusting segmentation thresholds
-Possible to use surface normal or angle information from these points
anyother possibility
I assume that when you tilt the object, the point of the object corner that closer to you gives more precise information than the other point. And if you can take angle information, find the surface normal and then calculate the angle between the vector or line you draw between two points that you got initially and the normal vector. And try change the point according to the result you got, in the area of your offset that the normal and our vector will be 90 to each other.
For example you know the normal vector and you have two points (x1,y1), (x2,y2). draw a vector between these two points, calculate the angle between this vector and normal. If the angle comes like 85 degrees. Manipulate (x2,y2) to get 90 degrees. It is like you hold a vector from it's start point and playing with it's direction. Because we assume that our starting point is precise.