Well today wasn't a good day either. I planned out exactly what I wanted to do yesterday, wrote the code and let it run overnight. I had some network connectivity problems around 6:00 am, so I had to restart my experiment. I just got back from lab and found I exceeded the rate limit on Twitter. So much for that idea. Then a server decided to crash, followed by my laptop's graphics driver when I plugged it into my monitor. I guess I just need to pivot. A little disclaimer, this material isn't new, I am borrowing it from my hack at PennApps (WanderWise). So I thought I would go into a bit about an algorithm that seemed to kind of work for picking up crosswalks. Time for disclaimer 2: I have no image processing background. Everything from here on out is me playing around with images to pick up crosswalks. I tried reading some journal papers on this, but we were too tight on time to implement an actual algorithm. I just tried different things and eventually got it working. It is buggy, for example try it with a white car nearby. So let us consider the classic zebra crosswalk:
It's black and white so let's convert it to binary (after grayscaling it):
Well that is really noisy. So we can dilate the image to try to get rid of some of the noise:
Now let's start looking for edges on the image:
There is still a lot of noise, so I decided to design a filter. It's not efficient but it works decently well.
Great, now we can extrapolate the position of the crosswalk.
And there you have it! A crosswalk!
And another example:
And just to show how it is far from perfect:
Still got the center line so that has to count for something!
Honestly I was surprised with how well this actually worked considering it was my first day really getting my hands dirty with OpenCV.