Finding the right parameters for your Computer Vision algorithm

Maunesh Ahir
3 min readDec 21, 2016

--

Finding the right parameters for your Computer Vision algorithms can sometimes be a tricky and a time consuming task. Computer Vision algorithms work quite well in research papers; but from my little experience, when we implement those low-level to mid-level algorithms ourselves, we typically need to make some efforts for them to work well on our own set of input images or videos. Most of these efforts go into finding the right parameters for our algorithms, and even then the algorithm may not work well in practice sometimes.

“In theory there is no difference between theory and practice; in practice there is.” — Yogi Berra (actually a mis-attributed quote)

If you find yourself struggling to determine the right parameters for a Computer Vision algorithm, probably the best solution is to implement the algorithm yourself and learn how each parameter affects the outcome. This is tedious and not practical — unless you’re a taking a Computer Vision course, and your professor requires you to implement the algorithm; in that case, you have no choice! If you simply want to use a library function from OpenCV, and still want to understand how each parameter affects the final result, without spending a lot of time on intricacies of math, an efficient way is to use a visual tool to help you understand what happens to the outcome, when you fiddle with one or more parameters.

In the following demo of such a visual helper tool, I am trying to find the right parameters for Canny edge detection algorithm, that will be used in Hough Transform algorithm, for an application of finding the lane-lines. For Canny edge detection algorithm to work well, we need to tune 3 main parameters — kernel size of the Gaussian Filter, the upper bound and the lower bound for Hysteresis Thresholding. More info on this can be found here. Using a GUI tool, I am trying to determine the best values of these parameters that I should use for my input.

As you can see, using a visual helper tool makes things much easier. Also, if you simply play around with the tool, you may develop more intuition for the algorithm and be able to guesstimate the right parameters the next time around when you use the same algorithm.

You can download the code for this tool from GitHub and modify it for your own needs, and use it for any algorithm to help you understand it better.

Below is link to a library that I plan to work on and build a GUI tool for all popular Computer Vision algorithms.

I used this tool to find the right parameters for Canny edge detection and used the edge output in Hough Line Transform. Below are some results that I got from Hough Line Transform for finding lane lines.

I learned this technique of using GUI tool, while taking a Computer Vision course by Dr. Aaron Bobick, Georgia Tech.

“Finding the Lane Lines” is one of the projects in Udacity’s Self Driving Car Engineer Nanodegree program. If you are interested in learning more about Self Driving Cars, Computer Vision or Deep Learning, you should check it out.

--

--