This is a helper jupyter notebook, which contains [interactive widgets](https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Basics.html) for qualitative evaluation of the image matching pipeline and better understanding of the robust model fitting with RANSAC. You can plug-in the functions, which you have implemented, or use the pre-defined wrappers around OpenCV or kornia functions.
It also can be useful as a template for writing your own visualizations or interactive apps.
%% Cell type:markdown id: tags:
Let's first do in in OpenCV to get the high-level understanding of the steps. We have two image as an input and would like to get corresponces and perspective transform between them.
%% Cell type:markdown id: tags:
## Recommended way of using this notebook
This notebook is a helper tool for you to check if the modules you have developed are working in practice. For doing this, you select the appropriate function in the interactive section below. It would not be shown, until you run all the cells, as the interactive widgets are not persistent.
You can also find and modify if you want, the commented implementation of the interactive part.
Let's create the choices for the drop-down list. They should match whatever we have inside `CustomLocalFeatureMatcher` above.
%% Cell type:code id: tags:
``` python
possible_detectors = ["kornia Harris",
"kornia Hessian",
"assignment Harris",
"assignment Hessian"]
possible_ori = ["none",
"kornia orientation",
"assignment orientation"]
possible_affine = ["none",
"kornia affine",
"assignment affine"]
possible_descriptor = ["kornia SIFT",
"assignment SIFT"]
possible_matching = ["kornia snn",
"assignment snn"]
possible_ransac = ["kornia RANSAC",
"assignment RANSAC"]
```
%% Cell type:markdown id: tags:
## PARAMETRIZATION
Throughout the whole notebook, we use data classes to parametrize algorithms. They are easy to use. They are extensible and clean. We encourage you to add new parameters and adjust our code to your needs. You can change the detection, description, and matching pipeline completely or use our and tweak the parameters.
## Dataclasses
We defined multiple data classes RansacPlanarFunctions, RansacPlanarParams, and PlotParams. We use them for storing values and parametrization. Their advantage over simple dictionaries is that they have defined values, are comparable, and [many others](https://docs.python.org/3/library/dataclasses.html). We also use them to store RANSAC output.
Below, you can see how do we define them within the hidden codebase. You can change all of the values below in the initialization section. (or during runtime)
%% Cell type:code id: tags:
``` python
# Here are default parameters for out app.
@dataclass(eq=False)
class WxBSParams:
detector: str = 'kornia Harris'
orientation: str = 'kornia orientation'
affine: str = 'none'
descriptor: str = 'kornia SIFT'
match: str = 'kornia snn'
ransac: str = 'kornia RANSAC'
```
%% Cell type:code id: tags:
``` python
matching_params = WxBSParams()
plt_params = PlotParams()
```
%% Cell type:markdown id: tags:
## Global variables and support plotting functions
%% Cell type:code id: tags:
``` python
# Modes in which inliers/outliers are displayed.
# Modes works as follows: there are three modes: 0, 1, 2.
# Mode 0: do not plot anything
# Mode 1: show only keypoints (in both images)
# Mode 2: show regions (in both images)
# Mode 3: show keypoints and connect them with lines
# Mode 4: show regions and connect them with lines
/opt/homebrew/Caskroom/miniforge/base/envs/python39/lib/python3.9/site-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.)