I am doing a zebra crossing detection problem, and now I've already known the vertices of each zebra stripe, as a list of points. How can I efficiently calculate the coordinates of the vertices of the outline rectangle containing those zebra stripes?
I am doing it in 3D
I've been thinking this question for days, and cannot figure out a solution rather than brutal force...
That's a different problem from finding the bounding box of a given list of points. For this task, the return would be four of those zebra stripes' vertices. I just need to find them out. Any help or pointers would be valuable!
UPDATE: I finally sorted those zebra-crossings by orientation and found the terminal zebra strips easily. The rest of the work is trivial
From what you say, it seems that you have the 3D coordinates of the outline of a rectangle. I will assume Cartesian coordinates and undistorted geometry.
The points belong to a plane, which you can determine by 3D plane fitting. Then by an orthogonal change of variables, you can project the points onto that plane.
For resonably good accuracy, you can
find the centroid of the points;
find the point the most distant from the centroid;
split the point set by means of the line from the centroid to that point;
on both halves, find the most distant points from the centroid;
the line that joints them allows you to further split in four quadrants;
in every quadrant, apply line fitting to find the edges.
If what you are after is the bounding box of several stripes, you can proceed as above to find the directions of the sides. Then apply a change of coordinates to bring those sides axis-aligned. Finding the bounding box is now straightforward.
Undo the transforms to obtain the3D coordinates of the rectangle in 3D.