Week 4 - Improving Corner Detection Results

Welcome again to my blog! This week, I focused on improving the results of corner detections, so that we can use the results to measure the dimensions of the detected object.

Try the demo!

As always, I prepared a demo so that you can intuitively understand what was I doing this week. Here’s the link: https://senior-project.jessexu.me/?file_selection=Week+4

Tweaking Hough Line Transform parameters

To start with, I read through some articles and essays online about Hough Line Transform and got a more thorough understanding of the parameters of Hough Line Transform. I think what causes Hough Line Transform to perform poorly is that the lines aren’t exactly straight, and they are kind of “wiggly” (see image below).

lines being wiggly

The line in the image is not exactly straight

I tried reducing the angle step size (theta of HLT), increasing the minimum length of line detected, and then decreasing the threshold of HLT. This gave me a small improvement, but the lines detected are still fragmented and far from usable.

Hough line transform tweaking

Hough Line Transform result comparison

Tweaking Corner Detection Algorithms

Based on the results, it looks like Hough Line Transform, although being widely used, does not fit my demand very well. It could also be that my tweaking is not right. Anyways, I decided to try tweaking the corner detection algorithms as introduced in last week’s blog post.

I tried using the two commonly used corner detection algorithms, Harris and Shi-Tomasi, last week. However, they did not produce impressive results either. The points detected tend to cluster on the top left corners of the shapes, and many corners get detected multiple times.

I had no clue how to fix this problem at first, since I don’t see anything that I did wrong compared to tutorials and essays I found online. Then I realized one significant difference between my use case and that of the tutorials - the tutorials mostly use only one shape when detecting corners, while I tried to detect the corners of multiple shapes.

So, I decided to add a function to the program that allows users to crop the images to a single shape, and also added an option to limit the points to be detected by the Shi-Tomasi corner detection function. They turn out to work great together, and the final product is finally usable now! (Hooray!)

Image cropping function

Image cropping function

Shi-Tomasi detection result

Shi-Tomasi Corner Detection Result


This week, I made improvements to the corner detection function to make produce better results. Next week, I will start investigating on a new topic: Camera calibration, which will allow us to convert the number of pixels on image to real world lengths.