pip install pixelstitch
Let's test our annotator on a sample project. It needs a list of triplets: (path_to_img1
, path_to_img2
, path_to_corrs_to_save
).
import os
rootdir = 'sample_project'
pairs = os.listdir(rootdir)
img_pairs_list = []
for p in pairs:
if p == '.DS_Store':
continue
cur_dir = os.path.join(rootdir, p)
img_pairs_list.append((os.path.join(cur_dir, '01.png'),
os.path.join(cur_dir, '02.png'),
os.path.join(cur_dir, 'corrs.txt')))
print (img_pairs_list)
Now we are ready to initialize CorrespondenceAnnotator
. Don't forget to declare magic command %matplotlib notebook
.
WITHOUT MAGIC IT WOULD NOT WORK
You also should explicitly specify, if you want to save (and possibly over-write previous better annotation) current correspondences automatically when clicking on prev and next buttons for going to the next pair.
%matplotlib notebook
from pixelstitch.core import *
CA = CorrespondenceAnnotator(img_pairs_list, save_on_next=True)
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:95% !important; }</style>"))
CA.start(figsize=(12,7))
Controls
Selectors
Model
. One can select between "F
" -- fundamental matrix and "H
" -- homography. The selection influences the reprojection error type, and the visualization of the models and reprojection errors, shown when clicked onNextCorrsValPoint
,NextCorrsValAll
andShowModel
buttons.
Buttons
NextCorrsValPoint
. Shows the correspondence in the bottom axis. The image title shows correspondence index and the reprojection error. IfModel
isF
, it will show induced epipolar line, ifH
-- the position of the reprojected point from other image. The model is estimated with all other correspondences except current one.NextCorrsValAll
. Shows the correspondences in the bottom axis. Similar toNextCorrsValPoint
button, but shows all points. The model is estimated with all correspondences except current one, which index is shown in the title.
ShowModel
. Has different behavoir depending on theModel
selected. ForF
-- shows correspondences with their induced epipolar lines. UnlikeNextCorrsValPoint
andNextCorrsValPoint
all correspondences are used for model estimation.For
H
, the button shows overlay of image 1 reprojected into image2 with image2. The reprojected area is defined by the convex hull of the labelled correspondences. Next click flips the order, i.e. shows the image 2 reprojected into image 1.Save points
-- saves (overwrites) the correspondences into the text file.Prev
-- Loads and shows previous image pair to label. If theCorrespondenceAnnotator
was initialized withsave_on_next=True
, the current pair correspondences are saved before the switch. Change is not cyclical, so the button does nothing on 1st image pairNext
-- Loads and shows next image pair to label. If theCorrespondenceAnnotator
was initialized withsave_on_next=True
, the current pair correspondences are saved before the switch.Change is not cyclical, so the button does nothing on last image pair.CLAHE
-- Images are shown with enhanced contrast with CLAHE algorithm.
Pick 4 points for homography
-- Special mode. User picks 4 points in one image, which define new fronto-parallel view. This mode helps for labeling obscure views, see example below. The order of the points: top-left -> top-right -> bottom right -> bottom left. After the 4 point picked, the mode is switched off, so user needs to click the button again if she wants to rectify another image.ResetView
-- Resets any recifications or zoom done to images.
All points are selected and image1 is rectified to the rectangle, defined by the selected points