Reputation: 11
I need to find the moving direction of a vehicle by its extracted point cloud, and I have converted the point cloud to the following image.
As the target vehicle could be moving straight or turning and the image is sometimes clear and sometimes fuzzy, I find it's difficult to match the "L" shape using template matching.
I also try to use RANSAC to fit the linear, but it has two sides and RANSAC does not work well. What I need to do is using an oriented bounding box to represent the vehicle.
If I could have the yaw angle of the "L" shape, it's very easy to recover it to an oriented bounding box. So could anyone give me some suggestions?
PS: The function cv::minAreaRect
could offer a basic result, but it sometimes fit the "L" shape in a wrong direction.
Upvotes: 0
Views: 863
Reputation: 71
One possibility is to see what side is closer to the center of the mass, because the this center is always closer to the 'L' shape.
See the link below:
docs.opencv.org/2.4/doc/tutorials/imgproc/shapedescriptors/moments/moments.html
Upvotes: 0
Reputation:
Build the convex hull and qualify the sides as "pretty vertical" and "pretty horizontal". This will help you identify the corners.
A yet simpler method is to identify the four pixels that maximimze ±X±Y. This gives you an interesting bounding quadrilateral (often reduced to a triangle).
Upvotes: 1