Fastest Image Pattern Matching
Using C++/MFC/OpenCV to build a NCC-Based Image Alignment algorithm
The matching algorithm is based on Normalized Cross Correlation, and the formular is as followed:
steps to build this project
- Download Visual Studio 2017 or newer versions
- Check on the option of “x86 and x64 version of C++ MFC”
- Install
- Open ELCVMatchTool.sln
- Upgrade if it is required
- Open this project’s property page
- Modified “General-Output Directory” to the .exe directory you want
- Choose the SDK version you have in “General-Windows SDK Version”
- Choose the right toolset you have in “General-Platform Toolset” (for me, it is Visual Studio 2017 (v141))
- Go to “VC++ Directories”, and type in “Include Directories” for your own OpenCV
- Type in “Library Directories” for your own OpenCV’s library path
- Go to “Linker-Input”, and type in library name (for me, it is opencv_world310d_vs2017.lib)
- Make sure that your opencvXX.dll and MatchTool.Lang are in the same directory as .exe of this project
usage of this project
- Select the Language you want
- Drag Source Image to the Left Area
- Drag Dst Image to the Right Top Area
- Push “Execute Button”
tests
test0 – with user interface
test1
test2
test3
test4
test5
Parameters Setting
- Target Number: possible max objects you want to find in the inspection image
- Max OverLap Ratio: (the overlap area between two findings) / area of golden sample
- Score (Similarity): accepted similarity of findings (0~1), lower score causes more execution time
- Tolerance Angle: possible rotation of targets in the inspection image (180 means search range is from -180~180), higher angle causes more execution time or you can push “↓” button to select 2 angle range
- Min Reduced Area: the min area of toppest level in image pyrimid (trainning stage)
about outputs
- results are sorted by score (decreasing order)
- Angles: inspected rotation of findings
- PosX, PosY: pixel position of findings
Demonstration Video Link
https://www.youtube.com/watch?v=2h_lN79SpMM&ab_channel=%E5%8A%89%E6%9F%8F%E5%AF%AC
This project can also be used as OCR detection
https://www.youtube.com/watch?v=lM0NK6xVNfg&ab_channel=%E5%8A%89%E6%9F%8F%E5%AF%AC