vtool-ibeis 2.2.0__py3-none-any.whl → 2.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vtool_ibeis/__init__.py +1 -4
- vtool_ibeis/_rhomb_dist.py +0 -2
- vtool_ibeis/blend.py +1 -5
- vtool_ibeis/chip.py +2 -5
- vtool_ibeis/clustering2.py +5 -8
- vtool_ibeis/confusion.py +6 -8
- vtool_ibeis/coverage_grid.py +2 -5
- vtool_ibeis/coverage_kpts.py +18 -19
- vtool_ibeis/demodata.py +5 -7
- vtool_ibeis/distance.py +9 -14
- vtool_ibeis/ellipse.py +2 -5
- vtool_ibeis/exif.py +5 -10
- vtool_ibeis/features.py +3 -6
- vtool_ibeis/fontdemo.py +0 -3
- vtool_ibeis/geometry.py +8 -18
- vtool_ibeis/histogram.py +7 -10
- vtool_ibeis/image.py +57 -54
- vtool_ibeis/image_filters.py +14 -13
- vtool_ibeis/image_shared.py +1 -4
- vtool_ibeis/inspect_matches.py +2 -4
- vtool_ibeis/keypoint.py +12 -23
- vtool_ibeis/linalg.py +0 -1
- vtool_ibeis/matching.py +19 -17
- vtool_ibeis/nearest_neighbors.py +13 -5
- vtool_ibeis/numpy_utils.py +6 -10
- vtool_ibeis/other.py +9 -12
- vtool_ibeis/patch.py +13 -37
- vtool_ibeis/quality_classifier.py +2 -3
- vtool_ibeis/score_normalization.py +3 -6
- vtool_ibeis/segmentation.py +7 -9
- vtool_ibeis/spatial_verification.py +12 -11
- vtool_ibeis/symbolic.py +0 -2
- vtool_ibeis/trig.py +0 -1
- vtool_ibeis/util_math.py +3 -6
- {vtool_ibeis-2.2.0.dist-info → vtool_ibeis-2.3.0.dist-info}/LICENSE +4 -4
- vtool_ibeis-2.3.0.dist-info/METADATA +561 -0
- vtool_ibeis-2.3.0.dist-info/RECORD +42 -0
- {vtool_ibeis-2.2.0.dist-info → vtool_ibeis-2.3.0.dist-info}/WHEEL +1 -1
- vtool_ibeis/_old_matching.py +0 -262
- vtool_ibeis-2.2.0.dist-info/METADATA +0 -281
- vtool_ibeis-2.2.0.dist-info/RECORD +0 -43
- {vtool_ibeis-2.2.0.dist-info → vtool_ibeis-2.3.0.dist-info}/top_level.txt +0 -0
vtool_ibeis/image.py
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# LICENCE
|
|
3
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
4
1
|
import six
|
|
5
2
|
import os
|
|
6
3
|
from os.path import exists, join # NOQA
|
|
7
4
|
from os.path import splitext
|
|
8
|
-
from six.moves import zip, map, range # NOQA
|
|
9
5
|
import numpy as np
|
|
10
6
|
from PIL import Image
|
|
11
7
|
import cv2
|
|
@@ -14,6 +10,11 @@ from vtool_ibeis import exif
|
|
|
14
10
|
import utool as ut
|
|
15
11
|
import ubelt as ub
|
|
16
12
|
|
|
13
|
+
try:
|
|
14
|
+
from packaging.version import parse as LooseVersion
|
|
15
|
+
except ImportError:
|
|
16
|
+
from distutils.version import LooseVersion
|
|
17
|
+
|
|
17
18
|
|
|
18
19
|
if cv2 is not None:
|
|
19
20
|
|
|
@@ -43,7 +44,6 @@ if cv2 is not None:
|
|
|
43
44
|
try:
|
|
44
45
|
IMREAD_COLOR = cv2.IMREAD_COLOR
|
|
45
46
|
except AttributeError:
|
|
46
|
-
from distutils.version import LooseVersion
|
|
47
47
|
cv2_version = LooseVersion(cv2.__version__)
|
|
48
48
|
print('UNKNOWN cv2_version = {!r}'.format(cv2_version))
|
|
49
49
|
assert cv2_version.version[0] <= 2
|
|
@@ -177,11 +177,11 @@ def montage(img_list, dsize, rng=np.random, method='random', return_debug=False)
|
|
|
177
177
|
|
|
178
178
|
if use_placement_prob:
|
|
179
179
|
# TODO: place images in places that other images have not been placed yet
|
|
180
|
-
place_img = np.ones(shape[0:2], dtype=
|
|
180
|
+
place_img = np.ones(shape[0:2], dtype=float)
|
|
181
181
|
#place_img[
|
|
182
182
|
#place_img = vt.gaussian_patch(shape[0:2], np.array(shape[0:2]) * .1)
|
|
183
183
|
#place_img = vt.gaussian_patch(shape[0:2], np.array(shape[0:2]) * .3)
|
|
184
|
-
temp_img = np.ones(shape[0:2], dtype=
|
|
184
|
+
temp_img = np.ones(shape[0:2], dtype=float)
|
|
185
185
|
# Enumerate valid 2d locations
|
|
186
186
|
xy_locs_ = np.meshgrid(np.arange(place_img.shape[1]),
|
|
187
187
|
np.arange(place_img.shape[0]))
|
|
@@ -289,12 +289,12 @@ def imread(img_fpath, grayscale=False, orient=False, flags=None,
|
|
|
289
289
|
Example:
|
|
290
290
|
>>> # ENABLE_DOCTEST
|
|
291
291
|
>>> from vtool_ibeis.image import * # NOQA
|
|
292
|
-
>>> img_fpath = ut.grab_test_imgpath('
|
|
292
|
+
>>> img_fpath = ut.grab_test_imgpath('astro')
|
|
293
293
|
>>> imgBGR1 = imread(img_fpath, grayscale=False)
|
|
294
294
|
>>> imgBGR2 = imread(img_fpath, grayscale=True)
|
|
295
295
|
>>> imgBGR3 = imread(img_fpath, orient=True)
|
|
296
|
-
>>> assert imgBGR1.shape == (
|
|
297
|
-
>>> assert imgBGR2.shape == (
|
|
296
|
+
>>> assert imgBGR1.shape == (512, 512, 3)
|
|
297
|
+
>>> assert imgBGR2.shape == (512, 512)
|
|
298
298
|
>>> assert np.all(imgBGR1 == imgBGR3)
|
|
299
299
|
>>> # xdoctest: +REQUIRES(--show)
|
|
300
300
|
>>> import plottool_ibeis as pt
|
|
@@ -304,7 +304,7 @@ def imread(img_fpath, grayscale=False, orient=False, flags=None,
|
|
|
304
304
|
>>> ut.show_if_requested()
|
|
305
305
|
|
|
306
306
|
Example:
|
|
307
|
-
>>> #
|
|
307
|
+
>>> # DISABLE_DOCTEST
|
|
308
308
|
>>> from vtool_ibeis.image import * # NOQA
|
|
309
309
|
>>> img_url = 'http://images.summitpost.org/original/769474.JPG'
|
|
310
310
|
>>> img_fpath = ut.grab_file_url(img_url)
|
|
@@ -315,21 +315,24 @@ def imread(img_fpath, grayscale=False, orient=False, flags=None,
|
|
|
315
315
|
>>> print('imgBGR2.shape = %r' % (imgBGR2.shape,))
|
|
316
316
|
>>> result = str(imgBGR1.shape)
|
|
317
317
|
>>> diff_pxls = imgBGR1 != imgBGR2
|
|
318
|
+
>>> # Very strange that this fails
|
|
318
319
|
>>> num_diff_pxls = diff_pxls.sum()
|
|
319
320
|
>>> print(result)
|
|
320
321
|
>>> print('num_diff_pxls=%r/%r' % (num_diff_pxls, diff_pxls.size))
|
|
321
322
|
>>> assert num_diff_pxls == 0
|
|
322
323
|
>>> # xdoctest: +REQUIRES(--show)
|
|
324
|
+
>>> import kwplot
|
|
325
|
+
>>> kwplot.autompl()
|
|
323
326
|
>>> import plottool_ibeis as pt
|
|
324
327
|
>>> diffMag = np.linalg.norm(imgBGR2 / 255. - imgBGR1 / 255., axis=2)
|
|
325
|
-
>>>
|
|
326
|
-
>>>
|
|
327
|
-
>>>
|
|
328
|
-
>>>
|
|
328
|
+
>>> kwplot.imshow(imgBGR1, pnum=(1, 3, 1))
|
|
329
|
+
>>> kwplot.imshow(diffMag / diffMag.max(), pnum=(1, 3, 2))
|
|
330
|
+
>>> kwplot.imshow(imgBGR2, pnum=(1, 3, 3))
|
|
331
|
+
>>> kwplot.show_if_requested()
|
|
329
332
|
(2736, 3648, 3)
|
|
330
333
|
|
|
331
334
|
Example:
|
|
332
|
-
>>> #
|
|
335
|
+
>>> # xdoctest +SKIP("networking")
|
|
333
336
|
>>> from vtool_ibeis.image import * # NOQA
|
|
334
337
|
>>> url = 'http://www.sherv.net/cm/emo/funny/2/big-dancing-banana-smiley-emoticon.gif'
|
|
335
338
|
>>> img_fpath = ut.grab_file_url(url)
|
|
@@ -537,10 +540,10 @@ def imwrite(img_fpath, imgBGR, fallback=False):
|
|
|
537
540
|
>>> from vtool_ibeis.image import * # NOQA
|
|
538
541
|
>>> import vtool_ibeis as vt
|
|
539
542
|
>>> import utool as ut
|
|
540
|
-
>>> img_fpath1 = ut.grab_test_imgpath('
|
|
543
|
+
>>> img_fpath1 = ut.grab_test_imgpath('astro')
|
|
541
544
|
>>> imgBGR = vt.imread(img_fpath1)
|
|
542
545
|
>>> img_dpath = ub.ensure_app_cache_dir('vtool_ibeis', 'testwrite')
|
|
543
|
-
>>> img_fpath2 = ut.unixjoin(img_dpath, '
|
|
546
|
+
>>> img_fpath2 = ut.unixjoin(img_dpath, 'astro.png')
|
|
544
547
|
>>> fallback = False
|
|
545
548
|
>>> imwrite(img_fpath2, imgBGR, fallback=fallback)
|
|
546
549
|
>>> imgBGR2 = vt.imread(img_fpath2)
|
|
@@ -552,7 +555,7 @@ def imwrite(img_fpath, imgBGR, fallback=False):
|
|
|
552
555
|
if fallback:
|
|
553
556
|
try:
|
|
554
557
|
imwrite_fallback(img_fpath, imgBGR)
|
|
555
|
-
except Exception
|
|
558
|
+
except Exception:
|
|
556
559
|
pass
|
|
557
560
|
msg = '[vt.image] ERROR writing: %s' % (img_fpath,)
|
|
558
561
|
ut.printex(ex, msg, keys=['imgBGR.shape'])
|
|
@@ -654,11 +657,11 @@ def open_image_size(image_fpath):
|
|
|
654
657
|
|
|
655
658
|
Doctest:
|
|
656
659
|
>>> from vtool_ibeis.image import * # NOQA
|
|
657
|
-
>>> image_fpath = ut.grab_test_imgpath('
|
|
660
|
+
>>> image_fpath = ut.grab_test_imgpath('carl')
|
|
658
661
|
>>> size = open_image_size(image_fpath)
|
|
659
662
|
>>> result = ('size = %s' % (str(size),))
|
|
660
663
|
>>> print(result)
|
|
661
|
-
size = (
|
|
664
|
+
size = (328, 448)
|
|
662
665
|
|
|
663
666
|
Ignore:
|
|
664
667
|
# Confirm that Image.open is a lazy load
|
|
@@ -727,7 +730,7 @@ def warpAffine(img, Aff, dsize, assume_float01=True):
|
|
|
727
730
|
>>> # DISABLE_DOCTEST
|
|
728
731
|
>>> from vtool_ibeis.image import * # NOQA
|
|
729
732
|
>>> import vtool_ibeis as vt
|
|
730
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
733
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
731
734
|
>>> img = vt.imread(img_fpath)
|
|
732
735
|
>>> Aff = vt.rotation_mat3x3(TAU / 8)
|
|
733
736
|
>>> dsize = vt.get_size(img)
|
|
@@ -1103,7 +1106,7 @@ def rotate_image_ondisk(img_fpath, theta, out_fpath=None, **kwargs):
|
|
|
1103
1106
|
>>> # DISABLE_DOCTEST
|
|
1104
1107
|
>>> from vtool_ibeis.image import * # NOQA
|
|
1105
1108
|
>>> # build test data
|
|
1106
|
-
>>> img_fpath = ut.grab_test_imgpath('
|
|
1109
|
+
>>> img_fpath = ut.grab_test_imgpath('astro')
|
|
1107
1110
|
>>> theta = TAU * 3 / 8
|
|
1108
1111
|
>>> # execute function
|
|
1109
1112
|
>>> out_fpath = None
|
|
@@ -1419,9 +1422,9 @@ def convert_colorspace(img, colorspace, src_colorspace='BGR'):
|
|
|
1419
1422
|
>>> # DISABLE_DOCTEST
|
|
1420
1423
|
>>> from vtool_ibeis.image import * # NOQA
|
|
1421
1424
|
>>> import vtool_ibeis as vt
|
|
1422
|
-
>>> img_fpath = ut.
|
|
1423
|
-
>>> img_fpath = ut.
|
|
1424
|
-
>>> img_fpath = ut.grab_test_imgpath('
|
|
1425
|
+
>>> #img_fpath = ut.grab_file_url('http://itsnasb.com/wp-content/uploads/2013/03/lisa-frank-logo1.jpg')
|
|
1426
|
+
>>> #img_fpath = ut.grab_test_imgpath('carl')
|
|
1427
|
+
>>> img_fpath = ut.grab_test_imgpath('pm5644')
|
|
1425
1428
|
>>> img = vt.imread(img_fpath)
|
|
1426
1429
|
>>> img_float = vt.rectify_to_float01(img, np.float32)
|
|
1427
1430
|
>>> colorspace = 'LAB'
|
|
@@ -1505,9 +1508,9 @@ def padded_resize(img, target_size=(64, 64), interpolation=None):
|
|
|
1505
1508
|
>>> # ENABLE_DOCTEST
|
|
1506
1509
|
>>> from vtool_ibeis.image import * # NOQA
|
|
1507
1510
|
>>> import vtool_ibeis as vt
|
|
1508
|
-
>>> imgA = vt.imread(ut.grab_test_imgpath('carl
|
|
1509
|
-
>>> imgB = vt.imread(ut.grab_test_imgpath('
|
|
1510
|
-
>>> imgC = vt.imread(ut.grab_test_imgpath('carl
|
|
1511
|
+
>>> imgA = vt.imread(ut.grab_test_imgpath('carl'))
|
|
1512
|
+
>>> imgB = vt.imread(ut.grab_test_imgpath('astro'))
|
|
1513
|
+
>>> imgC = vt.imread(ut.grab_test_imgpath('carl'), grayscale=True)
|
|
1511
1514
|
>>> #target_size = (64, 64)
|
|
1512
1515
|
>>> target_size = (1024, 1024)
|
|
1513
1516
|
>>> img3_list = [padded_resize(img, target_size) for img in [imgA, imgB, imgC]]
|
|
@@ -1551,7 +1554,7 @@ def embed_in_square_image(img, target_size, img_origin=(.5, .5),
|
|
|
1551
1554
|
>>> # DISABLE_DOCTEST
|
|
1552
1555
|
>>> from vtool_ibeis.image import * # NOQA
|
|
1553
1556
|
>>> import vtool_ibeis as vt
|
|
1554
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
1557
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
1555
1558
|
>>> img = vt.imread(img_fpath)
|
|
1556
1559
|
>>> target_size = tuple(np.array(vt.get_size(img)) * 3)
|
|
1557
1560
|
>>> img_origin = (.5, .5)
|
|
@@ -1596,16 +1599,16 @@ def embed_in_square_image(img, target_size, img_origin=(.5, .5),
|
|
|
1596
1599
|
|
|
1597
1600
|
## Find start slice in the target image
|
|
1598
1601
|
target_diff = np.floor(target_origin_abs - img_origin_abs)
|
|
1599
|
-
target_rc_start = np.maximum(target_diff, 0).astype(
|
|
1602
|
+
target_rc_start = np.maximum(target_diff, 0).astype(int)
|
|
1600
1603
|
|
|
1601
|
-
img_rc_start = (-(target_diff - target_rc_start)).astype(
|
|
1604
|
+
img_rc_start = (-(target_diff - target_rc_start)).astype(int)
|
|
1602
1605
|
img_clip_rc_low = img_rc - img_rc_start
|
|
1603
1606
|
|
|
1604
1607
|
end_hang = np.maximum((target_rc_start + img_clip_rc_low) - target_rc, 0)
|
|
1605
1608
|
img_clip_rc = img_clip_rc_low - end_hang
|
|
1606
1609
|
|
|
1607
|
-
img_rc_end = (img_rc_start + img_clip_rc).astype(
|
|
1608
|
-
target_rc_end = (target_rc_start + img_clip_rc).astype(
|
|
1610
|
+
img_rc_end = (img_rc_start + img_clip_rc).astype(int)
|
|
1611
|
+
target_rc_end = (target_rc_start + img_clip_rc).astype(int)
|
|
1609
1612
|
|
|
1610
1613
|
img_rc_slice = [slice(b, e) for (b, e) in zip(img_rc_start, img_rc_end)]
|
|
1611
1614
|
target_rc_slice = [slice(b, e) for (b, e) in zip(target_rc_start, target_rc_end)]
|
|
@@ -1704,7 +1707,7 @@ def resize_to_maxdims(img, max_dsize=(64, 64),
|
|
|
1704
1707
|
>>> # ENABLE_DOCTEST
|
|
1705
1708
|
>>> from vtool_ibeis.image import * # NOQA
|
|
1706
1709
|
>>> import vtool_ibeis as vt
|
|
1707
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
1710
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
1708
1711
|
>>> img = vt.imread(img_fpath)
|
|
1709
1712
|
>>> max_dsize = (1024, 1024)
|
|
1710
1713
|
>>> img2 = resize_to_maxdims(img, max_dsize)
|
|
@@ -1734,7 +1737,7 @@ def resize_thumb(img, max_dsize=(64, 64), interpolation=None):
|
|
|
1734
1737
|
>>> from vtool_ibeis.image import * # NOQA
|
|
1735
1738
|
>>> import vtool_ibeis as vt
|
|
1736
1739
|
>>> # build test data
|
|
1737
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
1740
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
1738
1741
|
>>> img = vt.imread(img_fpath)
|
|
1739
1742
|
>>> max_dsize = (64, 64)
|
|
1740
1743
|
>>> # execute function
|
|
@@ -2005,11 +2008,11 @@ def perlin_noise(size, scale=32.0, rng=np.random):
|
|
|
2005
2008
|
def testdata_imglist():
|
|
2006
2009
|
# build test data
|
|
2007
2010
|
import vtool_ibeis as vt
|
|
2008
|
-
img1 = vt.imread(ut.grab_test_imgpath('carl
|
|
2009
|
-
img2 = vt.imread(ut.grab_test_imgpath('astro
|
|
2010
|
-
img3 = vt.imread(ut.grab_test_imgpath('
|
|
2011
|
-
img4 = vt.imread(ut.grab_test_imgpath('
|
|
2012
|
-
img5 = vt.imread(ut.grab_test_imgpath('
|
|
2011
|
+
img1 = vt.imread(ut.grab_test_imgpath('carl'))
|
|
2012
|
+
img2 = vt.imread(ut.grab_test_imgpath('astro'))
|
|
2013
|
+
img3 = vt.imread(ut.grab_test_imgpath('stars'))
|
|
2014
|
+
img4 = vt.imread(ut.grab_test_imgpath('pm5644'))
|
|
2015
|
+
img5 = vt.imread(ut.grab_test_imgpath('parrot'))
|
|
2013
2016
|
img_list = [img1, img2, img3, img4, img5]
|
|
2014
2017
|
return img_list
|
|
2015
2018
|
|
|
@@ -2420,9 +2423,9 @@ def ensure_3channel(patch):
|
|
|
2420
2423
|
>>> # ENABLE_DOCTEST
|
|
2421
2424
|
>>> from vtool_ibeis.image import * # NOQA
|
|
2422
2425
|
>>> import vtool_ibeis as vt
|
|
2423
|
-
>>> patch1 = vt.imread(ut.grab_test_imgpath('astro
|
|
2424
|
-
>>> patch2 = vt.imread(ut.grab_test_imgpath('
|
|
2425
|
-
>>> patch3 = vt.imread(ut.grab_test_imgpath('
|
|
2426
|
+
>>> patch1 = vt.imread(ut.grab_test_imgpath('astro'))[0:512, 0:500, :]
|
|
2427
|
+
>>> patch2 = vt.imread(ut.grab_test_imgpath('carl'))[:, :, 0:1]
|
|
2428
|
+
>>> patch3 = vt.imread(ut.grab_test_imgpath('paraview'))[0:390, 0:400, 0]
|
|
2426
2429
|
>>> res1 = ensure_3channel(patch1)
|
|
2427
2430
|
>>> res2 = ensure_3channel(patch2)
|
|
2428
2431
|
>>> res3 = ensure_3channel(patch3)
|
|
@@ -2486,8 +2489,8 @@ def stack_images(img1, img2, vert=None, modifysize=False, return_sf=False,
|
|
|
2486
2489
|
>>> from vtool_ibeis.image import * # NOQA
|
|
2487
2490
|
>>> import vtool_ibeis as vt
|
|
2488
2491
|
>>> # build test data
|
|
2489
|
-
>>> img1 = vt.imread(ut.grab_test_imgpath('carl
|
|
2490
|
-
>>> img2 = vt.imread(ut.grab_test_imgpath('astro
|
|
2492
|
+
>>> img1 = vt.imread(ut.grab_test_imgpath('carl'))
|
|
2493
|
+
>>> img2 = vt.imread(ut.grab_test_imgpath('astro'))
|
|
2491
2494
|
>>> vert = True
|
|
2492
2495
|
>>> modifysize = False
|
|
2493
2496
|
>>> # execute function
|
|
@@ -2642,11 +2645,11 @@ def stack_image_recurse(img_list1, img_list2=None, vert=True, modifysize=False,
|
|
|
2642
2645
|
>>> from vtool_ibeis.image import * # NOQA
|
|
2643
2646
|
>>> import vtool_ibeis as vt
|
|
2644
2647
|
>>> # build test data
|
|
2645
|
-
>>> img1 = vt.imread(ut.grab_test_imgpath('carl
|
|
2646
|
-
>>> img2 = vt.imread(ut.grab_test_imgpath('astro
|
|
2647
|
-
>>> img3 = vt.imread(ut.grab_test_imgpath('
|
|
2648
|
-
>>> img4 = vt.imread(ut.grab_test_imgpath('
|
|
2649
|
-
>>> img5 = vt.imread(ut.grab_test_imgpath('
|
|
2648
|
+
>>> img1 = vt.imread(ut.grab_test_imgpath('carl'))
|
|
2649
|
+
>>> img2 = vt.imread(ut.grab_test_imgpath('astro'))
|
|
2650
|
+
>>> img3 = vt.imread(ut.grab_test_imgpath('paraview'))
|
|
2651
|
+
>>> img4 = vt.imread(ut.grab_test_imgpath('lowcontrast'))
|
|
2652
|
+
>>> img5 = vt.imread(ut.grab_test_imgpath('stars'))
|
|
2650
2653
|
>>> img_list1 = [img1, img2, img3, img4, img5]
|
|
2651
2654
|
>>> img_list2 = None
|
|
2652
2655
|
>>> vert = True
|
|
@@ -2655,7 +2658,7 @@ def stack_image_recurse(img_list1, img_list2=None, vert=True, modifysize=False,
|
|
|
2655
2658
|
>>> # verify results
|
|
2656
2659
|
>>> # xdoctest: +REQUIRES(--show)
|
|
2657
2660
|
>>> import plottool_ibeis as pt
|
|
2658
|
-
>>> imshow(imgB)
|
|
2661
|
+
>>> pt.imshow(imgB)
|
|
2659
2662
|
>>> #wh1 = img1.shape[0:2][::-1]
|
|
2660
2663
|
>>> #wh2 = img2.shape[0:2][::-1]
|
|
2661
2664
|
>>> #pt.draw_bbox((0, 0) + wh1, bbox_color=(1, 0, 0))
|
|
@@ -2729,8 +2732,8 @@ def filterflags_valid_images(gpaths, valid_formats=None,
|
|
|
2729
2732
|
Example:
|
|
2730
2733
|
>>> # ENABLE_DOCTEST
|
|
2731
2734
|
>>> from vtool_ibeis.image import * # NOQA
|
|
2732
|
-
>>> gpaths = [ut.grab_test_imgpath('carl
|
|
2733
|
-
>>> ut.grab_test_imgpath('astro
|
|
2735
|
+
>>> gpaths = [ut.grab_test_imgpath('carl'),
|
|
2736
|
+
>>> ut.grab_test_imgpath('astro')]
|
|
2734
2737
|
>>> flags = filterflags_valid_images(gpaths)
|
|
2735
2738
|
>>> assert all(flags)
|
|
2736
2739
|
"""
|
vtool_ibeis/image_filters.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function
|
|
3
|
-
from six.moves import range
|
|
4
1
|
import numpy as np
|
|
5
|
-
import utool as ut
|
|
6
|
-
import ubelt as ub
|
|
2
|
+
import utool as ut # NOQA
|
|
3
|
+
import ubelt as ub # NOQA
|
|
7
4
|
import cv2
|
|
8
5
|
|
|
9
6
|
|
|
@@ -17,7 +14,8 @@ class IntensityPreproc(object):
|
|
|
17
14
|
Doctest:
|
|
18
15
|
>>> from vtool_ibeis.image_filters import *
|
|
19
16
|
>>> import vtool_ibeis as vt
|
|
20
|
-
>>> chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
17
|
+
>>> #chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
18
|
+
>>> chipBGR = vt.imread(ut.grab_test_imgpath('astro'))
|
|
21
19
|
>>> filter_list = [
|
|
22
20
|
>>> ('medianblur', {}),
|
|
23
21
|
>>> ('adapteq', {}),
|
|
@@ -74,7 +72,9 @@ def manta_matcher_filters(chipBGR):
|
|
|
74
72
|
>>> from ibeis.core_annots import * # NOQA
|
|
75
73
|
>>> import ibeis
|
|
76
74
|
>>> ibs = ibeis.opendb('Mantas')
|
|
77
|
-
>>> chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
75
|
+
>>> #chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
76
|
+
>>> chipBGR = vt.imread(ut.grab_test_imgpath('astro'))
|
|
77
|
+
|
|
78
78
|
"""
|
|
79
79
|
chipLAB = cv2.cvtColor(chipBGR, cv2.COLOR_BGR2LAB)
|
|
80
80
|
|
|
@@ -102,7 +102,8 @@ def adapteq_fn(chipBGR):
|
|
|
102
102
|
>>> from vtool_ibeis.image_filters import *
|
|
103
103
|
>>> import vtool_ibeis as vt
|
|
104
104
|
>>> import utool as ut
|
|
105
|
-
>>> chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
105
|
+
>>> #chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
106
|
+
>>> chipBGR = vt.imread(ut.grab_test_imgpath('astro'))
|
|
106
107
|
>>> chip2 = adapteq_fn(chipBGR)
|
|
107
108
|
>>> # xdoctest: +REQUIRES(--show)
|
|
108
109
|
>>> import plottool_ibeis as pt
|
|
@@ -127,8 +128,9 @@ def medianfilter_fn(chipBGR):
|
|
|
127
128
|
>>> from vtool_ibeis.image_filters import *
|
|
128
129
|
>>> import vtool_ibeis as vt
|
|
129
130
|
>>> import utool as ut
|
|
130
|
-
>>> chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
131
|
-
>>>
|
|
131
|
+
>>> #chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
132
|
+
>>> chipBGR = vt.imread(ut.grab_test_imgpath('astro'))
|
|
133
|
+
>>> chip2 = medianfilter_fn(chipBGR)
|
|
132
134
|
>>> # xdoctest: +REQUIRES(--show)
|
|
133
135
|
>>> import plottool_ibeis as pt
|
|
134
136
|
>>> pt.imshow(chipBGR, pnum=(1, 2, 1), fnum=1)
|
|
@@ -192,17 +194,16 @@ def grabcut_fn(chipBGR):
|
|
|
192
194
|
chip_mask = np.where(is_forground, 255, 0).astype('uint8')
|
|
193
195
|
# Crop
|
|
194
196
|
chip_mask = clean_mask(chip_mask)
|
|
195
|
-
chip_mask = np.array(chip_mask,
|
|
197
|
+
chip_mask = np.array(chip_mask, float) / 255.0
|
|
196
198
|
# Mask value component of HSV space
|
|
197
199
|
chipHSV = cv2.cvtColor(chipRGB, cv2.COLOR_RGB2HSV)
|
|
198
|
-
chipHSV = np.array(chipHSV, dtype=
|
|
200
|
+
chipHSV = np.array(chipHSV, dtype=float) / 255.0
|
|
199
201
|
chipHSV[:, :, 2] *= chip_mask
|
|
200
202
|
chipHSV = np.array(np.round(chipHSV * 255.0), dtype=np.uint8)
|
|
201
203
|
seg_chipBGR = cv2.cvtColor(chipHSV, cv2.COLOR_HSV2BGR)
|
|
202
204
|
return seg_chipBGR
|
|
203
205
|
|
|
204
206
|
|
|
205
|
-
|
|
206
207
|
if __name__ == '__main__':
|
|
207
208
|
"""
|
|
208
209
|
CommandLine:
|
vtool_ibeis/image_shared.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
1
|
from PIL import Image
|
|
4
|
-
import cv2
|
|
5
2
|
import utool as ut
|
|
6
3
|
|
|
7
4
|
|
|
@@ -16,5 +13,5 @@ def print_image_checks(img_fpath):
|
|
|
16
13
|
_tup = (img_fpath, ut.filesize_str(img_fpath))
|
|
17
14
|
print('[io] Image %r (%s) exists. Is it corrupted?' % _tup)
|
|
18
15
|
else:
|
|
19
|
-
print('[io] Image %r does not
|
|
16
|
+
print('[io] Image %r does not exist ' % (img_fpath,))
|
|
20
17
|
return hasimg
|
vtool_ibeis/inspect_matches.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function
|
|
3
1
|
import utool as ut
|
|
4
2
|
import ubelt as ub
|
|
5
3
|
try:
|
|
@@ -71,8 +69,8 @@ class MatchInspector(INSPECT_BASE):
|
|
|
71
69
|
>>> import vtool_ibeis as vt
|
|
72
70
|
>>> gt.ensure_qapp()
|
|
73
71
|
>>> ut.qtensure()
|
|
74
|
-
>>> annot1 = lazy_test_annot('
|
|
75
|
-
>>> annot2 = lazy_test_annot('
|
|
72
|
+
>>> annot1 = lazy_test_annot('tsukuba_r')
|
|
73
|
+
>>> annot2 = lazy_test_annot('tsukuba_l')
|
|
76
74
|
>>> match = vt.PairwiseMatch(annot1, annot2)
|
|
77
75
|
>>> self = MatchInspector(match=match)
|
|
78
76
|
>>> self.show()
|
vtool_ibeis/keypoint.py
CHANGED
|
@@ -129,8 +129,7 @@ Efficiency Notes:
|
|
|
129
129
|
using np.take is a better idea, but its a bit harder
|
|
130
130
|
to use with multidimensional arrays (nope use axis=x)
|
|
131
131
|
"""
|
|
132
|
-
from
|
|
133
|
-
from six.moves import zip, range, reduce
|
|
132
|
+
from functools import reduce
|
|
134
133
|
import numpy as np
|
|
135
134
|
import numpy.linalg as npl
|
|
136
135
|
from vtool_ibeis import linalg as linalgtool
|
|
@@ -524,7 +523,6 @@ def get_invVR_mats3x3(kpts):
|
|
|
524
523
|
... [30, 40, 1, 2, 3, TAU / 4.0],
|
|
525
524
|
... ])
|
|
526
525
|
>>> invVR_mats3x3 = get_invVR_mats3x3(kpts)
|
|
527
|
-
>>> # verify results
|
|
528
526
|
>>> result = kpts_repr(invVR_mats3x3)
|
|
529
527
|
>>> print(result)
|
|
530
528
|
array([[[ 1., 0., 10.],
|
|
@@ -537,20 +535,6 @@ def get_invVR_mats3x3(kpts):
|
|
|
537
535
|
#nKpts = len(kpts)
|
|
538
536
|
invVR_mats2x2 = get_invVR_mats2x2(kpts)
|
|
539
537
|
invVR_mats3x3 = augment_2x2_with_translation(kpts, invVR_mats2x2)
|
|
540
|
-
# Unpack shape components
|
|
541
|
-
#_iv11s = invVR_mats2x2.T[0, 0]
|
|
542
|
-
#_iv12s = invVR_mats2x2.T[1, 0]
|
|
543
|
-
#_iv21s = invVR_mats2x2.T[0, 1]
|
|
544
|
-
#_iv22s = invVR_mats2x2.T[1, 1]
|
|
545
|
-
## Get translation components
|
|
546
|
-
#_iv13s, _iv23s = get_xys(kpts)
|
|
547
|
-
## Use homogenous coordinates
|
|
548
|
-
#_zeros = np.zeros(nKpts)
|
|
549
|
-
#_ones = np.ones(nKpts)
|
|
550
|
-
#invVR_arrs = np.array([[_iv11s, _iv12s, _iv13s],
|
|
551
|
-
# [_iv21s, _iv22s, _iv23s],
|
|
552
|
-
# [_zeros, _zeros, _ones]]) # R x C x N
|
|
553
|
-
#invVR_mats = np.rollaxis(invVR_arrs, 2) # N x R x C
|
|
554
538
|
return invVR_mats3x3
|
|
555
539
|
|
|
556
540
|
|
|
@@ -1204,13 +1188,11 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1204
1188
|
>>> #
|
|
1205
1189
|
|
|
1206
1190
|
nptheta = np.linspace(0, 2 * np.pi, 32, endpoint=False)
|
|
1207
|
-
|
|
1208
1191
|
mapping = np.arctan(np.tan(nptheta))
|
|
1209
1192
|
print(ub.repr2(zip(nptheta / (2 * np.pi), nptheta, mapping, nptheta == mapping), precision=3))
|
|
1210
1193
|
print(ub.repr2(zip(nptheta / (2 * np.pi), nptheta, mapping % (np.pi * 2), nptheta == mapping % (np.pi * 2)), precision=3))
|
|
1211
|
-
|
|
1194
|
+
>>> # xdoctest: +SKIP
|
|
1212
1195
|
>>> # NUMPY CHECKS
|
|
1213
|
-
|
|
1214
1196
|
>>> nptheta_special = [ np.arccos(0), -np.arccos(0), -np.arcsin(0), np.arcsin(0) ]
|
|
1215
1197
|
>>> nptheta = np.array(np.linspace(0, 2 * np.pi, 64, endpoint=False).tolist() + nptheta_special)
|
|
1216
1198
|
>>> # Case 1
|
|
@@ -1220,6 +1202,7 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1220
1202
|
>>> case1_result = (-np.arctan(np.tan(-case1_theta)) % TAU)
|
|
1221
1203
|
>>> case1_theta == case1_result
|
|
1222
1204
|
|
|
1205
|
+
>>> # xdoctest: +SKIP
|
|
1223
1206
|
>>> print(ub.repr2(zip(case1_theta, case1_result, vt.ori_distance(case1_theta, case1_result) ), precision=3))
|
|
1224
1207
|
>>> #
|
|
1225
1208
|
>>> # Case 2
|
|
@@ -1252,8 +1235,8 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1252
1235
|
|
|
1253
1236
|
# numpy check
|
|
1254
1237
|
|
|
1255
|
-
|
|
1256
1238
|
>>> # LATEX PART
|
|
1239
|
+
>>> # xdoctest: +SKIP
|
|
1257
1240
|
>>> expr1_repr = vt.sympy_latex_repr(invTVR_held_full)
|
|
1258
1241
|
>>> print(expr1_repr)
|
|
1259
1242
|
>>>
|
|
@@ -1261,6 +1244,7 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1261
1244
|
>>> print(expr1_repr)
|
|
1262
1245
|
|
|
1263
1246
|
|
|
1247
|
+
>>> # xdoctest: +SKIP
|
|
1264
1248
|
>>> from sympy import Symbol, Q, refine, atan2
|
|
1265
1249
|
>>> from sympy.assumptions.refine import refine_atan2
|
|
1266
1250
|
>>> from sympy.abc import x, y
|
|
@@ -1271,9 +1255,9 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1271
1255
|
atan(y/x) - pi
|
|
1272
1256
|
atan(y/x) + pi
|
|
1273
1257
|
|
|
1258
|
+
>>> # xdoctest: +SKIP
|
|
1274
1259
|
>>> negtheta = sympy.symbols('negtheta', **symkw)
|
|
1275
1260
|
>>> ori_subs2 = sympy.simplify(sympy.trigsimp(ori_subs))
|
|
1276
|
-
|
|
1277
1261
|
>>> ori_subs3 = ori_subs2.subs({theta:-negtheta})
|
|
1278
1262
|
>>> ori_subs4 = sympy.simplify(ori_subs3)
|
|
1279
1263
|
Out[45]: Mod(-atan2(sin(negtheta)/a, cos(negtheta)/a), 2*pi)
|
|
@@ -1298,17 +1282,20 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1298
1282
|
|
|
1299
1283
|
|
|
1300
1284
|
|
|
1285
|
+
>>> # xdoctest: +SKIP
|
|
1301
1286
|
>>> ori_subs3 = ori_subs2.subs({theta:0})
|
|
1302
1287
|
>>> ori_subs3 = ori_subs2.subs(dict(theta=0), simultanious=True)
|
|
1303
1288
|
for sym in ori_subs2.free_symbols:
|
|
1304
1289
|
print('%r.assumptions0 = %s' % (sym, ub.repr2(sym.assumptions0),))
|
|
1305
1290
|
|
|
1306
1291
|
|
|
1292
|
+
>>> # xdoctest: +SKIP
|
|
1307
1293
|
>>> #invTVR = sympy.simplify(RVT_full.inv())
|
|
1308
1294
|
>>> expr1_repr = vt.sympy_latex_repr(invTVR_full)
|
|
1309
1295
|
>>> print(expr1_repr)
|
|
1310
1296
|
|
|
1311
1297
|
Sympy:
|
|
1298
|
+
>>> # xdoctest: +SKIP
|
|
1312
1299
|
>>> import sympy
|
|
1313
1300
|
>>> import vtool_ibeis as vt
|
|
1314
1301
|
>>> # First orient a unit circle
|
|
@@ -1355,6 +1342,7 @@ def get_invVR_mats_oris(invVR_mats):
|
|
|
1355
1342
|
|
|
1356
1343
|
Sympy:
|
|
1357
1344
|
>>> # Show orientation property
|
|
1345
|
+
>>> # xdoctest: +SKIP
|
|
1358
1346
|
>>> import sympy
|
|
1359
1347
|
>>> import vtool_ibeis as vt
|
|
1360
1348
|
>>> # First orient a unit circle
|
|
@@ -2169,10 +2157,11 @@ def get_even_point_sample(kpts):
|
|
|
2169
2157
|
pyhesaff.tests.test_ellipse
|
|
2170
2158
|
|
|
2171
2159
|
Example:
|
|
2172
|
-
>>> #
|
|
2160
|
+
>>> # DISABLE_DOCTEST
|
|
2173
2161
|
>>> from vtool_ibeis.keypoint import * # NOQA
|
|
2174
2162
|
>>> import vtool_ibeis as vt
|
|
2175
2163
|
>>> kpts = vt.demodata.get_dummy_kpts()[0:2]
|
|
2164
|
+
>>> # not sure why this is failing
|
|
2176
2165
|
>>> ell_border_pts_list = get_even_point_sample(kpts)
|
|
2177
2166
|
>>> # xdoctest: +REQUIRES(--show)
|
|
2178
2167
|
>>> import plottool_ibeis as pt
|
vtool_ibeis/linalg.py
CHANGED
|
@@ -33,7 +33,6 @@ TODO: Look at this file
|
|
|
33
33
|
# >>> print(xdev.align('\\\\\n'.join(sympy.latex(R).split(r'\\')).replace('{matrix}', '{matrix}\n'), '&')
|
|
34
34
|
|
|
35
35
|
"""
|
|
36
|
-
from __future__ import absolute_import, division, print_function
|
|
37
36
|
import cv2
|
|
38
37
|
import numpy as np
|
|
39
38
|
import numpy.linalg as npl
|
vtool_ibeis/matching.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""
|
|
3
2
|
vt
|
|
4
3
|
python -m utool.util_inspect check_module_usage --pat="matching.py"
|
|
5
4
|
|
|
6
5
|
"""
|
|
7
|
-
from __future__ import absolute_import, division, print_function
|
|
8
6
|
from vtool_ibeis import _rhomb_dist
|
|
9
7
|
import six
|
|
10
8
|
import warnings
|
|
@@ -104,13 +102,13 @@ def demodata_match(cfgdict={}, apply=True, use_cache=True, recompute=False):
|
|
|
104
102
|
cfgstr = ub.hash_data(cfgdict) + hashid
|
|
105
103
|
cacher = ub.Cacher(
|
|
106
104
|
'test_match_v5',
|
|
107
|
-
|
|
105
|
+
depends=cfgstr,
|
|
108
106
|
appname='vtool_ibeis',
|
|
109
107
|
enabled=use_cache
|
|
110
108
|
)
|
|
111
109
|
match = cacher.tryload()
|
|
112
|
-
annot1 = lazy_test_annot('
|
|
113
|
-
annot2 = lazy_test_annot('
|
|
110
|
+
annot1 = lazy_test_annot('tsukuba_l')
|
|
111
|
+
annot2 = lazy_test_annot('tsukuba_r')
|
|
114
112
|
if match is None or recompute:
|
|
115
113
|
match = vt.PairwiseMatch(annot1, annot2)
|
|
116
114
|
if apply:
|
|
@@ -143,8 +141,10 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
143
141
|
>>> # xdoctest: +REQUIRES(module:pyhesaff)
|
|
144
142
|
>>> from vtool_ibeis.matching import * # NOQA
|
|
145
143
|
>>> import vtool_ibeis as vt
|
|
146
|
-
>>> imgR = vt.imread(ut.grab_test_imgpath('easy1.png'))
|
|
147
|
-
>>> imgL = vt.imread(ut.grab_test_imgpath('easy2.png'))
|
|
144
|
+
>>> #imgR = vt.imread(ut.grab_test_imgpath('easy1.png'))
|
|
145
|
+
>>> #imgL = vt.imread(ut.grab_test_imgpath('easy2.png'))
|
|
146
|
+
>>> imgR = vt.imread(ut.grab_test_imgpath('tsukuba_r'))
|
|
147
|
+
>>> imgL = vt.imread(ut.grab_test_imgpath('tsukuba_l'))
|
|
148
148
|
>>> annot1 = {'rchip': imgR}
|
|
149
149
|
>>> annot2 = {'rchip': imgL}
|
|
150
150
|
>>> match = vt.PairwiseMatch(annot1, annot2)
|
|
@@ -164,8 +164,8 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
164
164
|
>>> match.ishow()
|
|
165
165
|
>>> from vtool_ibeis.matching import * # NOQA
|
|
166
166
|
>>> import vtool_ibeis as vt
|
|
167
|
-
>>> imgR = vt.imread(ut.grab_test_imgpath('
|
|
168
|
-
>>> imgL = vt.imread(ut.grab_test_imgpath('
|
|
167
|
+
>>> imgR = vt.imread(ut.grab_test_imgpath('tsukuba_r'))
|
|
168
|
+
>>> imgL = vt.imread(ut.grab_test_imgpath('tsukuba_l'))
|
|
169
169
|
>>> annot1 = {'rchip': imgR}
|
|
170
170
|
>>> annot2 = {'rchip': imgL}
|
|
171
171
|
>>> match = vt.PairwiseMatch(annot1, annot2)
|
|
@@ -455,8 +455,10 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
455
455
|
K, Knorm, symmetric, checks, weight_key = params
|
|
456
456
|
annot1 = match.annot1
|
|
457
457
|
annot2 = match.annot2
|
|
458
|
+
if verbose is None:
|
|
459
|
+
verbose = match.verbose
|
|
458
460
|
|
|
459
|
-
if
|
|
461
|
+
if verbose:
|
|
460
462
|
print('[match] assign')
|
|
461
463
|
print('[match] params = ' + ub.repr2(params))
|
|
462
464
|
|
|
@@ -576,7 +578,7 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
576
578
|
ori_err = np.full(n_fm, fill_value=np.inf)
|
|
577
579
|
agg_errors = (xy_err, scale_err, ori_err)
|
|
578
580
|
|
|
579
|
-
agg_inlier_flags = np.zeros(n_fm, dtype=
|
|
581
|
+
agg_inlier_flags = np.zeros(n_fm, dtype=bool)
|
|
580
582
|
|
|
581
583
|
agg_H_12 = None
|
|
582
584
|
prev_best = 50
|
|
@@ -1449,7 +1451,7 @@ def ensure_metadata_feats(annot, cfgdict={}):
|
|
|
1449
1451
|
>>> # ENABLE_DOCTEST
|
|
1450
1452
|
>>> # xdoctest: +REQUIRES(module:pyhesaff)
|
|
1451
1453
|
>>> from vtool_ibeis.matching import * # NOQA
|
|
1452
|
-
>>> rchip_fpath = ut.grab_test_imgpath('
|
|
1454
|
+
>>> rchip_fpath = ut.grab_test_imgpath('astro')
|
|
1453
1455
|
>>> annot = ut.LazyDict({'rchip_fpath': rchip_fpath})
|
|
1454
1456
|
>>> cfgdict = {}
|
|
1455
1457
|
>>> ensure_metadata_feats(annot, cfgdict)
|
|
@@ -1636,7 +1638,7 @@ def asymmetric_correspondence(annot1, annot2, K, Knorm, checks, allow_shrink=Tru
|
|
|
1636
1638
|
|
|
1637
1639
|
fx2_to_fx1, fx2_to_dist = normalized_nearest_neighbors(
|
|
1638
1640
|
annot1['flann'], annot2['vecs'], num_neighbors, checks)
|
|
1639
|
-
fx2_to_flags = np.ones((len(fx2_to_fx1), K), dtype=
|
|
1641
|
+
fx2_to_flags = np.ones((len(fx2_to_fx1), K), dtype=bool)
|
|
1640
1642
|
# Assign correspondences
|
|
1641
1643
|
assigntup = assign_unconstrained_matches(fx2_to_fx1, fx2_to_dist, K,
|
|
1642
1644
|
Knorm, fx2_to_flags)
|
|
@@ -1706,8 +1708,8 @@ def assign_symmetric_matches(fx2_to_fx1, fx2_to_dist, fx1_to_fx2, fx1_to_dist,
|
|
|
1706
1708
|
fx12.columns.name = 'K'
|
|
1707
1709
|
fx12.index.name = 'fx2'
|
|
1708
1710
|
|
|
1709
|
-
fx12 = fx12.T[0:K].T.astype(
|
|
1710
|
-
fx21 = fx21.T[0:K].T.astype(
|
|
1711
|
+
fx12 = fx12.T[0:K].T.astype(float)
|
|
1712
|
+
fx21 = fx21.T[0:K].T.astype(float)
|
|
1711
1713
|
|
|
1712
1714
|
fx12.values[~fx1_to_flags] = np.nan
|
|
1713
1715
|
fx21.values[~fx2_to_flags] = np.nan
|
|
@@ -1867,7 +1869,7 @@ def assign_unconstrained_matches(fx2_to_fx1, fx2_to_dist, K, Knorm=None,
|
|
|
1867
1869
|
# make everything valid
|
|
1868
1870
|
flat_validx = np.arange(len(fx2_to_fx1) * K, dtype=index_dtype)
|
|
1869
1871
|
else:
|
|
1870
|
-
#fx2_to_flags = np.ones((len(fx2_to_fx1), K), dtype=
|
|
1872
|
+
#fx2_to_flags = np.ones((len(fx2_to_fx1), K), dtype=bool)
|
|
1871
1873
|
flat_validx = np.flatnonzero(fx2_to_flags)
|
|
1872
1874
|
|
|
1873
1875
|
match_fx2 = np.floor_divide(flat_validx, K, dtype=index_dtype)
|
|
@@ -1912,7 +1914,7 @@ def flag_sym_slow(fx1_to_fx2, fx2_to_fx1, K):
|
|
|
1912
1914
|
fx2_m = fx1_to_fx2[fx1, :K]
|
|
1913
1915
|
# Find img2 features that have fx1 in their top K
|
|
1914
1916
|
reverse_m = fx2_to_fx1[fx2_m, :K]
|
|
1915
|
-
is_recip = (reverse_m == fx1).sum(axis=1).astype(
|
|
1917
|
+
is_recip = (reverse_m == fx1).sum(axis=1).astype(bool)
|
|
1916
1918
|
fx1_to_flags.append(is_recip)
|
|
1917
1919
|
fx1_to_flags = np.array(fx1_to_flags)
|
|
1918
1920
|
return fx1_to_flags
|