mwgit00 / BGHMatcher

Experiments with the Generalized Hough transform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BGHMatcher

Experiments with the Generalized Hough Transform.

This repository has an implementation of the the classic Generalized Hough (GH) algorithm. Sobel filters calculate the X and Y derivatives. A Cartesian-to-Polar operation converts the X and Y derivatives to magnitude and angle. Gradients with magnitudes below an arbitrary threshold are discarded. The angles are converted to 8-bit integer codes for quick lookup in a voting table.

Some implementations of the GH algorithm use a Canny Edge Detector as a pre-processing step and sub-divide an image into voting bins. It can be difficult to tune the Canny detector and bin size. In this implementation, the gradient calculations are blurry and the edges are "fuzzy". This creates a lot of redundant votes. In practice, this creates well-defined maxima. The maxima are located at single pixels rather than at voting bins, which may be associated with multiple pixels. Blurry gradients might also provide more tolerance to variations in scale and rotation when finding matches in the target image.

Installation

The project compiles in the Community edition of Visual Studio 2019 (toolset v142). It uses the Windows pre-built OpenCV 4.5.3 libraries extracted to c:\opencv-4.5.3. I just copied the appropriate OpenCV DLLs to wherever I had my executables. It creates a command-line Windows executable. I have tested it on a Windows 10 Home (22H2) 64-bit machine.

Camera

I tested with a Logitech c270. It was the cheapest one I could find that I could purchase locally. It was plug-and-play.

Video

Click the image for YouTube demo video:

BGHMatcher Demo Video

About

Experiments with the Generalized Hough transform.

License:MIT License


Languages

Language:C++ 100.0%