/CSVA

Primary LanguageC++OtherNOASSERTION

Core structural verification algorithm of keypoint matches

C++ implementation of the robust keypoint elimination algorithm described in the paper

Malashin R.O. Core algorithm for structural verification of keypoint matches. Intelligent Systems Reference Library. Computer Vision in Control Systems-3. 2018. P. 251-286

Update 2023

I did minor changes to the code to make it compatible with new opencv4.x.

Ubuntu 22.04 install

  1. Install Boost
apt-get install libboost-all-dev
  1. Download, compile and install opencv with opencv_contrib. Follow opencv documentation.

    Make sure to enable DOPENCV_ENABLE_NONFREE flag when configure. The flag is needed for SURF detector, which is used by default (you can substitute it later). I used the following commands:

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DOPENCV_ENABLE_NONFREE:BOOL=ON -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.x/modules ../opencv-4.x
make -j8
make install
  1. Compile CSVA project.
git clone https://github.com/malashinroman/CSVA
cd CSVA
mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
make -j8
  1. You should get following files in CSVA/bin directory

    libcommon_lib.a, libcsva_lib.so, match3D, match_aero.

If you see them, then everything is OK, and you can proceed to tests.

See Dockerfile to see all commands for clean installation in Ubuntu

Description

CSVA (“core” structural verification algorithm) is a robust and fast algorithm for outlier elimination of keypoint matches (e.g. SURF, SIFT or BRISK features) that heavily exploits gemetrical constraints. It can be used by developers and researches in different practical tasks with minor adaptation. CSVA an improved version of SIFT clustering proposed by David Lowe in SIFT.

Demo video

video1 and video2

for more demonstration results visit project page

Prerequisites

opencv

CSVA uses openCV structures like cv::DMatch and cv::KeyPoint internally, opencv3.1 and opencv4.0 were tested



opencv-contrib

You will need xfeatures2d from opencv-contrib to compile and test with SURF and SIFT

Boost 

CSVA uses boost library in it's core

Operating system

Windows 7 and Ubuntu 14.04 were tested

Compile

Cmake is a recommended tool for creating CSVA project

Running test examples

CSVA has two regimes for 3D scene matching and aerospace matching.

3D scene matching

After compilation you can run

match3D image1.jpg image2.jpg

The result showing keypoint matches selected by CSVA will be drawn in result.jpg

aerospace matching

After compilation you can run

match_aero im1.jpg im2.jpg 0.5 0.5 1

where im1.jpg is first aero or space image, im2.jpg is second aero or space image, 0.5 is a resize factor, 1 - is fast mode (use 2 to get robust results).

Folder <im1.jpg> will be created by the program, where images demonstrating the matching result (keypoint mathces, color alighnment, etc) will be saved.

Use csva_lib in your project

To use CSVA in your C++ project

  1. compile csva_lib
  2. link csva_lib to the project
  3. Include header in the file you need
#include "csva_lib/csva.h"
  1. CSVA is opencv compatible. You can verify matches generated by opencv and stored in vectorcv::DMatch by the following command:
csva::filter_matches(points1, points2, matches, image1, image2, csva::geometry_mode::THREEDIM_SCENE, LocalMatchtype, goodmatches, confidence, 0.001);

where points1 and points2 are vectorcv::KeyPoint, image1 and image2 are two images in cv::Mat, LocalMatchtype is a flag specifying which feature detector, feature extractor and matcher was used to genereate matches (for example, 352 is HammingMatcher + BRISK descriptor + SURF detector), goodmatches is output vectorcv::DMatch for inliers, confidence is output double[6] confidence with first element specifying the confidence of the solution taking into accout goodness of the selected matches, 0.001 is confidence of random cluster forming (you can use another value here, it affects computation of output confidence)

Current repository suggests using OpenCVfeatures wrapper to compute features defined in features2d and xfeatures2d modules: std::vector matches = feat.getLocalPatchMatches2(image1, image2, points1, points2, LocalMatchtype, 0);

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Citing

1. Malashin R.O. Core algorithm for structural verification of keypoint matches. Intelligent Systems Reference Library. Computer Vision in Control Systems-3. 2018. P. 251-286
2. Malashin R. Matching of Aerospace Photographs with the use of Local Features // Journal of Physics: Conference Series - 2014, Vol. 536, No. 1, pp. 012018.