Path Detection with OpenCV (28 Days of Hacking: Day 14)

So earlier I discussed a simple algorithm for crosswalk detection, but we need some way to compute valid paths on the sidewalk. This includes avoiding people and other obstacles. So let's start with this sidewalk.



So once we have that, we want to convert it to grayscale.



Once we have that, we can convert it to binary as before, which gives us:



Which once again we want to dilate.



Finally we can perform Canny edge detection which gives us:

<

Now up to this point we have been processing a 2D image, but we can make a fairly clever approximation about depth to get around this. If we start with an initial offset up to ignore any noise at the bottom of the frame, like feet, we can then propagate outwards and up then find the first object on each side. This object can be tagged as the most critical obstacle to avoid. Once we have this we can construct the bounds of the path leading up to it. In this case the manhole cover tightened the bounds a bit.