0

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

Comp.Zhe
  • 5
  • 2
  • 1
    Possible duplicate of [How to efficiently find the bounding box of a collection of points?](https://stackoverflow.com/questions/46335488/how-to-efficiently-find-the-bounding-box-of-a-collection-of-points) – Ari Cooper-Davis Jun 10 '19 at 12:05
  • Hi, Thanks for your reply, but that's a different problem. For my task, the final result would be four of those zebra stripes vertices. – Comp.Zhe Jun 10 '19 at 12:12

2 Answers2

0

As you told, you know the coordinates of each individual stripe of the zebra crossing. So now you can determine the first and last stripes by looking at max and min coordinates of all vertices(By considering a reference axis from which you can measure distance). then you know coordinates of terminal stripes and hence you can make the outline by considering the coordinates and hence making a larger rectangle from those four coordinates determining the whole zebra crossing.

Avinash Karhana
  • 659
  • 4
  • 16
  • Hi, thanks for your reply. This is really insightful, Thanks. But I am doing it in 3D, shall I calculate max and min for each direction like in 2D? I think the case is a little bit more complicated, because I will get 6 max/min values, but I only need 4 vertices.. – Comp.Zhe Jun 10 '19 at 12:21
  • How would you get 6 values? By doing it in 3D you still have a 2D image I assume, it's maybe just a distorted image of the stripes. You would still have 2-2 minima/maxima for the coordinates. – Gábor Fekete Jun 10 '19 at 12:46
  • Yes, theoretically they are still on a plane, but how can I know which 4 out of 6 max/min to use? there are x, y ,z, 3 directions, and max/min doubles that number, which leads to a 6 in total – Comp.Zhe Jun 11 '19 at 02:05
0

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.