vtool-ibeis 2.2.1__py3-none-any.whl → 2.3.1__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 -1
- vtool_ibeis/blend.py +1 -1
- vtool_ibeis/clustering2.py +1 -1
- vtool_ibeis/confusion.py +53 -6
- vtool_ibeis/coverage_grid.py +2 -2
- vtool_ibeis/coverage_kpts.py +17 -16
- vtool_ibeis/demodata.py +3 -3
- vtool_ibeis/distance.py +19 -0
- vtool_ibeis/exif.py +4 -4
- vtool_ibeis/features.py +4 -6
- vtool_ibeis/geometry.py +3 -9
- vtool_ibeis/histogram.py +11 -8
- vtool_ibeis/image.py +46 -44
- vtool_ibeis/image_filters.py +10 -6
- vtool_ibeis/inspect_matches.py +43 -6
- vtool_ibeis/keypoint.py +1 -1
- vtool_ibeis/matching.py +13 -9
- vtool_ibeis/nearest_neighbors.py +4 -2
- vtool_ibeis/other.py +34 -20
- vtool_ibeis/patch.py +11 -23
- vtool_ibeis/quality_classifier.py +2 -2
- vtool_ibeis/score_normalization.py +15 -10
- vtool_ibeis/segmentation.py +1 -1
- vtool_ibeis/spatial_verification.py +4 -6
- vtool_ibeis/symbolic.py +3 -4
- vtool_ibeis-2.3.1.dist-info/METADATA +440 -0
- vtool_ibeis-2.3.1.dist-info/RECORD +42 -0
- {vtool_ibeis-2.2.1.dist-info → vtool_ibeis-2.3.1.dist-info}/WHEEL +1 -1
- vtool_ibeis-2.2.1.dist-info/METADATA +0 -435
- vtool_ibeis-2.2.1.dist-info/RECORD +0 -42
- {vtool_ibeis-2.2.1.dist-info → vtool_ibeis-2.3.1.dist-info/licenses}/LICENSE +0 -0
- {vtool_ibeis-2.2.1.dist-info → vtool_ibeis-2.3.1.dist-info}/top_level.txt +0 -0
vtool_ibeis/image_filters.py
CHANGED
|
@@ -14,7 +14,8 @@ class IntensityPreproc(object):
|
|
|
14
14
|
Doctest:
|
|
15
15
|
>>> from vtool_ibeis.image_filters import *
|
|
16
16
|
>>> import vtool_ibeis as vt
|
|
17
|
-
>>> 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'))
|
|
18
19
|
>>> filter_list = [
|
|
19
20
|
>>> ('medianblur', {}),
|
|
20
21
|
>>> ('adapteq', {}),
|
|
@@ -71,7 +72,9 @@ def manta_matcher_filters(chipBGR):
|
|
|
71
72
|
>>> from ibeis.core_annots import * # NOQA
|
|
72
73
|
>>> import ibeis
|
|
73
74
|
>>> ibs = ibeis.opendb('Mantas')
|
|
74
|
-
>>> 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
|
+
|
|
75
78
|
"""
|
|
76
79
|
chipLAB = cv2.cvtColor(chipBGR, cv2.COLOR_BGR2LAB)
|
|
77
80
|
|
|
@@ -99,7 +102,8 @@ def adapteq_fn(chipBGR):
|
|
|
99
102
|
>>> from vtool_ibeis.image_filters import *
|
|
100
103
|
>>> import vtool_ibeis as vt
|
|
101
104
|
>>> import utool as ut
|
|
102
|
-
>>> 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'))
|
|
103
107
|
>>> chip2 = adapteq_fn(chipBGR)
|
|
104
108
|
>>> # xdoctest: +REQUIRES(--show)
|
|
105
109
|
>>> import plottool_ibeis as pt
|
|
@@ -124,8 +128,9 @@ def medianfilter_fn(chipBGR):
|
|
|
124
128
|
>>> from vtool_ibeis.image_filters import *
|
|
125
129
|
>>> import vtool_ibeis as vt
|
|
126
130
|
>>> import utool as ut
|
|
127
|
-
>>> chipBGR = vt.imread(ut.grab_file_url('http://i.imgur.com/qVWQaex.jpg'))
|
|
128
|
-
>>>
|
|
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)
|
|
129
134
|
>>> # xdoctest: +REQUIRES(--show)
|
|
130
135
|
>>> import plottool_ibeis as pt
|
|
131
136
|
>>> pt.imshow(chipBGR, pnum=(1, 2, 1), fnum=1)
|
|
@@ -199,7 +204,6 @@ def grabcut_fn(chipBGR):
|
|
|
199
204
|
return seg_chipBGR
|
|
200
205
|
|
|
201
206
|
|
|
202
|
-
|
|
203
207
|
if __name__ == '__main__':
|
|
204
208
|
"""
|
|
205
209
|
CommandLine:
|
vtool_ibeis/inspect_matches.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import scriptconfig as scfg
|
|
2
3
|
import ubelt as ub
|
|
4
|
+
import utool as ut
|
|
3
5
|
try:
|
|
4
6
|
import guitool_ibeis as gt
|
|
5
7
|
from guitool_ibeis import mpl_widget
|
|
@@ -69,8 +71,8 @@ class MatchInspector(INSPECT_BASE):
|
|
|
69
71
|
>>> import vtool_ibeis as vt
|
|
70
72
|
>>> gt.ensure_qapp()
|
|
71
73
|
>>> ut.qtensure()
|
|
72
|
-
>>> annot1 = lazy_test_annot('
|
|
73
|
-
>>> annot2 = lazy_test_annot('
|
|
74
|
+
>>> annot1 = lazy_test_annot('tsukuba_r')
|
|
75
|
+
>>> annot2 = lazy_test_annot('tsukuba_l')
|
|
74
76
|
>>> match = vt.PairwiseMatch(annot1, annot2)
|
|
75
77
|
>>> self = MatchInspector(match=match)
|
|
76
78
|
>>> self.show()
|
|
@@ -345,10 +347,45 @@ def show_matching_dict(matches, metadata, *args, **kwargs):
|
|
|
345
347
|
return interact
|
|
346
348
|
|
|
347
349
|
|
|
350
|
+
class InspectMatchesCLI(scfg.DataConfig):
|
|
351
|
+
"""
|
|
352
|
+
Run a 1vs1 matching
|
|
353
|
+
"""
|
|
354
|
+
img1 = scfg.Value('tsukuba_r', type=str, position=1, help='key or path of test image 1')
|
|
355
|
+
img2 = scfg.Value('tsukuba_l', type=str, position=2, help='key or path of test image 2')
|
|
356
|
+
|
|
357
|
+
@classmethod
|
|
358
|
+
def main(cls, argv=1, **kwargs):
|
|
359
|
+
"""
|
|
360
|
+
Example:
|
|
361
|
+
>>> # xdoctest: +SKIP
|
|
362
|
+
>>> from vtool_ibeis.inspect_matches import * # NOQA
|
|
363
|
+
>>> argv = 0
|
|
364
|
+
>>> kwargs = dict()
|
|
365
|
+
>>> cls = InspectMatchesCLI
|
|
366
|
+
>>> config = cls(**kwargs)
|
|
367
|
+
>>> cls.main(argv=argv, **config)
|
|
368
|
+
"""
|
|
369
|
+
import vtool_ibeis as vt
|
|
370
|
+
config = cls.cli(argv=argv, data=kwargs, strict=True, verbose='auto')
|
|
371
|
+
gt.ensure_qapp()
|
|
372
|
+
ut.qtensure()
|
|
373
|
+
annot1 = lazy_test_annot(config.img1)
|
|
374
|
+
annot2 = lazy_test_annot(config.img2)
|
|
375
|
+
match = vt.PairwiseMatch(annot1, annot2)
|
|
376
|
+
self = MatchInspector(match=match)
|
|
377
|
+
self.show()
|
|
378
|
+
# xdoctest: +REQUIRES(--show)
|
|
379
|
+
#self.update()
|
|
380
|
+
gt.qtapp_loop(qwin=self, freq=10)
|
|
381
|
+
|
|
382
|
+
__cli__ = InspectMatchesCLI
|
|
383
|
+
|
|
348
384
|
if __name__ == '__main__':
|
|
349
385
|
"""
|
|
386
|
+
|
|
350
387
|
CommandLine:
|
|
351
|
-
|
|
388
|
+
python ~/code/vtool_ibeis/vtool_ibeis/inspect_matches.py
|
|
389
|
+
python -m vtool_ibeis.inspect_matches /home/joncrall/Downloads/tmp/ibeis/IMG_0070_A.JPG /home/joncrall/Downloads/tmp/ibeis/IMG_0315_A.JPG
|
|
352
390
|
"""
|
|
353
|
-
|
|
354
|
-
xdoctest.doctest_module(__file__)
|
|
391
|
+
__cli__.main()
|
vtool_ibeis/keypoint.py
CHANGED
|
@@ -659,7 +659,7 @@ def get_transforms_from_patch_image_kpts(kpts, patch_shape, scale_factor=1.0):
|
|
|
659
659
|
%timeit np.array([S2.dot(A) for A in invVR_aff2Ds])
|
|
660
660
|
%timeit op.matmul(S2, invVR_aff2Ds)
|
|
661
661
|
|
|
662
|
-
from
|
|
662
|
+
from functools import reduce
|
|
663
663
|
perspective_list2 = np.array([S2.dot(A).dot(S1).dot(T1) for A in invVR_aff2Ds])
|
|
664
664
|
perspective_list = reduce(op.matmul, (S2, invVR_aff2Ds, S1, T1))
|
|
665
665
|
assert np.all(perspective_list == perspective_list2)
|
vtool_ibeis/matching.py
CHANGED
|
@@ -102,13 +102,13 @@ def demodata_match(cfgdict={}, apply=True, use_cache=True, recompute=False):
|
|
|
102
102
|
cfgstr = ub.hash_data(cfgdict) + hashid
|
|
103
103
|
cacher = ub.Cacher(
|
|
104
104
|
'test_match_v5',
|
|
105
|
-
|
|
105
|
+
depends=cfgstr,
|
|
106
106
|
appname='vtool_ibeis',
|
|
107
107
|
enabled=use_cache
|
|
108
108
|
)
|
|
109
109
|
match = cacher.tryload()
|
|
110
|
-
annot1 = lazy_test_annot('
|
|
111
|
-
annot2 = lazy_test_annot('
|
|
110
|
+
annot1 = lazy_test_annot('tsukuba_l')
|
|
111
|
+
annot2 = lazy_test_annot('tsukuba_r')
|
|
112
112
|
if match is None or recompute:
|
|
113
113
|
match = vt.PairwiseMatch(annot1, annot2)
|
|
114
114
|
if apply:
|
|
@@ -141,8 +141,10 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
141
141
|
>>> # xdoctest: +REQUIRES(module:pyhesaff)
|
|
142
142
|
>>> from vtool_ibeis.matching import * # NOQA
|
|
143
143
|
>>> import vtool_ibeis as vt
|
|
144
|
-
>>> imgR = vt.imread(ut.grab_test_imgpath('easy1.png'))
|
|
145
|
-
>>> 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'))
|
|
146
148
|
>>> annot1 = {'rchip': imgR}
|
|
147
149
|
>>> annot2 = {'rchip': imgL}
|
|
148
150
|
>>> match = vt.PairwiseMatch(annot1, annot2)
|
|
@@ -162,8 +164,8 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
162
164
|
>>> match.ishow()
|
|
163
165
|
>>> from vtool_ibeis.matching import * # NOQA
|
|
164
166
|
>>> import vtool_ibeis as vt
|
|
165
|
-
>>> imgR = vt.imread(ut.grab_test_imgpath('
|
|
166
|
-
>>> 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'))
|
|
167
169
|
>>> annot1 = {'rchip': imgR}
|
|
168
170
|
>>> annot2 = {'rchip': imgL}
|
|
169
171
|
>>> match = vt.PairwiseMatch(annot1, annot2)
|
|
@@ -453,8 +455,10 @@ class PairwiseMatch(ub.NiceRepr):
|
|
|
453
455
|
K, Knorm, symmetric, checks, weight_key = params
|
|
454
456
|
annot1 = match.annot1
|
|
455
457
|
annot2 = match.annot2
|
|
458
|
+
if verbose is None:
|
|
459
|
+
verbose = match.verbose
|
|
456
460
|
|
|
457
|
-
if
|
|
461
|
+
if verbose:
|
|
458
462
|
print('[match] assign')
|
|
459
463
|
print('[match] params = ' + ub.repr2(params))
|
|
460
464
|
|
|
@@ -1447,7 +1451,7 @@ def ensure_metadata_feats(annot, cfgdict={}):
|
|
|
1447
1451
|
>>> # ENABLE_DOCTEST
|
|
1448
1452
|
>>> # xdoctest: +REQUIRES(module:pyhesaff)
|
|
1449
1453
|
>>> from vtool_ibeis.matching import * # NOQA
|
|
1450
|
-
>>> rchip_fpath = ut.grab_test_imgpath('
|
|
1454
|
+
>>> rchip_fpath = ut.grab_test_imgpath('astro')
|
|
1451
1455
|
>>> annot = ut.LazyDict({'rchip_fpath': rchip_fpath})
|
|
1452
1456
|
>>> cfgdict = {}
|
|
1453
1457
|
>>> ensure_metadata_feats(annot, cfgdict)
|
vtool_ibeis/nearest_neighbors.py
CHANGED
|
@@ -109,8 +109,10 @@ def test_cv2_flann():
|
|
|
109
109
|
from vtool_ibeis import demodata
|
|
110
110
|
import plottool_ibeis as pt
|
|
111
111
|
import vtool_ibeis as vt
|
|
112
|
-
img1 = vt.imread(ut.grab_test_imgpath('easy1.png'))
|
|
113
|
-
img2 = vt.imread(ut.grab_test_imgpath('easy2.png'))
|
|
112
|
+
# img1 = vt.imread(ut.grab_test_imgpath('easy1.png'))
|
|
113
|
+
# img2 = vt.imread(ut.grab_test_imgpath('easy2.png'))
|
|
114
|
+
img1 = vt.imread(ut.grab_test_imgpath('tsukuba_l'))
|
|
115
|
+
img2 = vt.imread(ut.grab_test_imgpath('tsukuba_r'))
|
|
114
116
|
|
|
115
117
|
stereo = cv2.StereoBM_create(numDisparities=16, blockSize=15)
|
|
116
118
|
disparity = stereo.compute(img1, img2)
|
vtool_ibeis/other.py
CHANGED
|
@@ -1266,9 +1266,14 @@ def intersect2d_numpy(A, B, assume_unique=False, return_indices=False):
|
|
|
1266
1266
|
>>> C, Ax, Bx = intersect2d_numpy(A, B, return_indices=True)
|
|
1267
1267
|
>>> # verify results
|
|
1268
1268
|
>>> result = str((C.T, Ax, Bx))
|
|
1269
|
-
>>>
|
|
1270
|
-
(
|
|
1271
|
-
|
|
1269
|
+
>>> import ubelt as ub
|
|
1270
|
+
>>> print(f'C.T = {ub.urepr(C.T, nl=1, with_dtype=False)}')
|
|
1271
|
+
>>> print(f'Ax = {ub.urepr(Ax, nl=1, with_dtype=False)}')
|
|
1272
|
+
>>> print(f'Bx = {ub.urepr(Bx, nl=1, with_dtype=False)}')
|
|
1273
|
+
C.T = np.array([[ 85, 403, 412],
|
|
1274
|
+
[ 32, 22, 103]])
|
|
1275
|
+
Ax = np.array([2, 6, 7])
|
|
1276
|
+
Bx = np.array([0, 1, 2])
|
|
1272
1277
|
|
|
1273
1278
|
Example2:
|
|
1274
1279
|
>>> # ENABLE_DOCTEST
|
|
@@ -1276,9 +1281,15 @@ def intersect2d_numpy(A, B, assume_unique=False, return_indices=False):
|
|
|
1276
1281
|
>>> A = np.array([[1, 2, 3], [1, 1, 1]])
|
|
1277
1282
|
>>> B = np.array([[1, 2, 3], [1, 2, 14]])
|
|
1278
1283
|
>>> C, Ax, Bx = intersect2d_numpy(A, B, return_indices=True)
|
|
1279
|
-
>>>
|
|
1280
|
-
>>> print(
|
|
1281
|
-
(
|
|
1284
|
+
>>> import ubelt as ub
|
|
1285
|
+
>>> print(f'C.T = {ub.urepr(C.T, nl=1, with_dtype=False)}')
|
|
1286
|
+
>>> print(f'Ax = {ub.urepr(Ax, nl=1, with_dtype=False)}')
|
|
1287
|
+
>>> print(f'Bx = {ub.urepr(Bx, nl=1, with_dtype=False)}')
|
|
1288
|
+
C.T = np.array([[1],
|
|
1289
|
+
[2],
|
|
1290
|
+
[3]])
|
|
1291
|
+
Ax = np.array([0])
|
|
1292
|
+
Bx = np.array([0])
|
|
1282
1293
|
"""
|
|
1283
1294
|
nrows, ncols = A.shape
|
|
1284
1295
|
A_, B_, C_ = intersect2d_structured_numpy(A, B, assume_unique)
|
|
@@ -1672,12 +1683,13 @@ def find_first_true_indices(flags_list):
|
|
|
1672
1683
|
>>> index_list = find_first_true_indices(flags_list)
|
|
1673
1684
|
>>> # verify results
|
|
1674
1685
|
>>> result = str(index_list)
|
|
1675
|
-
>>>
|
|
1676
|
-
|
|
1686
|
+
>>> import ubelt as ub
|
|
1687
|
+
>>> print(f'result = {ub.urepr(result, nl=1)}')
|
|
1688
|
+
result = '[0, None, 1, 2]'
|
|
1677
1689
|
"""
|
|
1678
1690
|
def tryget_fisrt_true(flags):
|
|
1679
1691
|
index_list = np.where(flags)[0]
|
|
1680
|
-
index = None if len(index_list) == 0 else index_list[0]
|
|
1692
|
+
index = None if len(index_list) == 0 else int(index_list[0])
|
|
1681
1693
|
return index
|
|
1682
1694
|
index_list = [tryget_fisrt_true(flags) for flags in flags_list]
|
|
1683
1695
|
return index_list
|
|
@@ -1691,9 +1703,6 @@ def find_k_true_indicies(flags_list, k):
|
|
|
1691
1703
|
Args:
|
|
1692
1704
|
flags_list (list): list of lists of booleans
|
|
1693
1705
|
|
|
1694
|
-
CommandLine:
|
|
1695
|
-
python -m utool.util_list --test-find_next_true_indices
|
|
1696
|
-
|
|
1697
1706
|
Example:
|
|
1698
1707
|
>>> # ENABLE_DOCTEST
|
|
1699
1708
|
>>> from vtool_ibeis.other import * # NOQA
|
|
@@ -1703,9 +1712,14 @@ def find_k_true_indicies(flags_list, k):
|
|
|
1703
1712
|
... [True, True, True]]
|
|
1704
1713
|
>>> k = 2
|
|
1705
1714
|
>>> indices = find_k_true_indicies(flags_list, k)
|
|
1706
|
-
>>>
|
|
1707
|
-
>>> print(result)
|
|
1708
|
-
|
|
1715
|
+
>>> import ubelt as np
|
|
1716
|
+
>>> print(f'result = {ub.urepr(indices, nl=1, with_dtype=False)}')
|
|
1717
|
+
result = [
|
|
1718
|
+
np.array([2]),
|
|
1719
|
+
None,
|
|
1720
|
+
np.array([1, 2]),
|
|
1721
|
+
np.array([0, 1]),
|
|
1722
|
+
]
|
|
1709
1723
|
"""
|
|
1710
1724
|
|
|
1711
1725
|
if False:
|
|
@@ -1733,7 +1747,7 @@ def find_next_true_indices(flags_list, offset_list):
|
|
|
1733
1747
|
flags_list (list): list of lists of booleans
|
|
1734
1748
|
|
|
1735
1749
|
CommandLine:
|
|
1736
|
-
|
|
1750
|
+
xdoctest vtool_ibeis.other find_next_true_indices
|
|
1737
1751
|
|
|
1738
1752
|
Example:
|
|
1739
1753
|
>>> # ENABLE_DOCTEST
|
|
@@ -1747,15 +1761,15 @@ def find_next_true_indices(flags_list, offset_list):
|
|
|
1747
1761
|
>>> # execute function
|
|
1748
1762
|
>>> index_list = find_next_true_indices(flags_list, offset_list)
|
|
1749
1763
|
>>> # verify results
|
|
1750
|
-
>>>
|
|
1751
|
-
>>> print(
|
|
1752
|
-
[2, None, 2, None]
|
|
1764
|
+
>>> import ubelt as ub
|
|
1765
|
+
>>> print(f'index_list = {ub.urepr(index_list, nl=0)}')
|
|
1766
|
+
index_list = [2, None, 2, None]
|
|
1753
1767
|
"""
|
|
1754
1768
|
def tryget_next_true(flags, offset_):
|
|
1755
1769
|
offset = offset_ + 1
|
|
1756
1770
|
relative_flags = flags[offset:]
|
|
1757
1771
|
rel_index_list = np.where(relative_flags)[0]
|
|
1758
|
-
index = None if len(rel_index_list) == 0 else rel_index_list[0] + offset
|
|
1772
|
+
index = None if len(rel_index_list) == 0 else int(rel_index_list[0] + offset)
|
|
1759
1773
|
return index
|
|
1760
1774
|
index_list = [None if offset is None else tryget_next_true(flags, offset)
|
|
1761
1775
|
for flags, offset in zip(flags_list, offset_list)]
|
vtool_ibeis/patch.py
CHANGED
|
@@ -570,7 +570,7 @@ def get_warped_patches(img, kpts, flags=cv2.INTER_LANCZOS4,
|
|
|
570
570
|
>>> from vtool_ibeis.patch import * # NOQA
|
|
571
571
|
>>> import vtool_ibeis as vt
|
|
572
572
|
>>> # build test data
|
|
573
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
573
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
574
574
|
>>> img = vt.imread(img_fpath)
|
|
575
575
|
>>> use_cpp = ut.get_argflag('--use_cpp')
|
|
576
576
|
>>> kpts, desc = vt.extract_features(img_fpath)
|
|
@@ -1065,18 +1065,14 @@ def draw_kp_ori_steps():
|
|
|
1065
1065
|
>>> draw_kp_ori_steps()
|
|
1066
1066
|
>>> pt.show_if_requested()
|
|
1067
1067
|
"""
|
|
1068
|
-
#from vtool_ibeis.patch import * # NOQA
|
|
1069
|
-
#import vtool_ibeis as vt
|
|
1070
1068
|
# build test data
|
|
1071
1069
|
import utool as ut
|
|
1072
1070
|
import plottool_ibeis as pt
|
|
1073
|
-
import vtool_ibeis as vt
|
|
1074
1071
|
|
|
1075
1072
|
if True:
|
|
1076
1073
|
from ibeis.scripts.thesis import TMP_RC
|
|
1077
1074
|
import matplotlib as mpl
|
|
1078
1075
|
mpl.rcParams.update(TMP_RC)
|
|
1079
|
-
#import vtool_ibeis as vt
|
|
1080
1076
|
np.random.seed(0)
|
|
1081
1077
|
USE_COMMANLINE = True
|
|
1082
1078
|
if USE_COMMANLINE:
|
|
@@ -1085,24 +1081,16 @@ def draw_kp_ori_steps():
|
|
|
1085
1081
|
kp = kpts[fx]
|
|
1086
1082
|
else:
|
|
1087
1083
|
fx = 0
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
imgBGR = get_test_patch('star2', jitter=True)
|
|
1099
|
-
#imgBGR = get_test_patch('cross', jitter=False)
|
|
1100
|
-
#imgBGR = cv2.resize(imgBGR, (41, 41), interpolation=cv2.INTER_LANCZOS4)
|
|
1101
|
-
imgBGR = cv2.resize(imgBGR, (41, 41), interpolation=cv2.INTER_CUBIC)
|
|
1102
|
-
theta = 0 # 3.4 # TAU / 16
|
|
1103
|
-
#kpts = make_test_image_keypoints(imgBGR, scale=.9, theta=theta)
|
|
1104
|
-
kpts = make_test_image_keypoints(imgBGR, scale=.3, theta=theta, shift=(.3, .1))
|
|
1105
|
-
kp = kpts[0]
|
|
1084
|
+
#imgBGR = get_test_patch('stripe', jitter=True)
|
|
1085
|
+
#imgBGR = get_test_patch('star', jitter=True)
|
|
1086
|
+
imgBGR = get_test_patch('star2', jitter=True)
|
|
1087
|
+
#imgBGR = get_test_patch('cross', jitter=False)
|
|
1088
|
+
#imgBGR = cv2.resize(imgBGR, (41, 41), interpolation=cv2.INTER_LANCZOS4)
|
|
1089
|
+
imgBGR = cv2.resize(imgBGR, (41, 41), interpolation=cv2.INTER_CUBIC)
|
|
1090
|
+
theta = 0 # 3.4 # TAU / 16
|
|
1091
|
+
#kpts = make_test_image_keypoints(imgBGR, scale=.9, theta=theta)
|
|
1092
|
+
kpts = make_test_image_keypoints(imgBGR, scale=.3, theta=theta, shift=(.3, .1))
|
|
1093
|
+
kp = kpts[0]
|
|
1106
1094
|
bins = 36
|
|
1107
1095
|
maxima_thresh = .8
|
|
1108
1096
|
converge_lists = []
|
|
@@ -19,7 +19,7 @@ def compute_average_contrast(img):
|
|
|
19
19
|
>>> # ENABLE_DOCTEST
|
|
20
20
|
>>> from vtool_ibeis.quality_classifier import * # NOQA
|
|
21
21
|
>>> import vtool_ibeis as vt
|
|
22
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
22
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
23
23
|
>>> img = vt.imread(img_fpath, grayscale=True)
|
|
24
24
|
>>> average_contrast, gradmag_sqrd = compute_average_contrast(img)
|
|
25
25
|
>>> # xdoctest: +REQUIRES(module:plottool_ibeis)
|
|
@@ -104,7 +104,7 @@ def fourier_devtest(img):
|
|
|
104
104
|
>>> # DISABLE_DOCTEST
|
|
105
105
|
>>> from vtool_ibeis.quality_classifier import * # NOQA
|
|
106
106
|
>>> import vtool_ibeis as vt
|
|
107
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
107
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
108
108
|
>>> img = vt.imread(img_fpath, grayscale=True)
|
|
109
109
|
>>> magnitude_spectrum = fourier_devtest(img)
|
|
110
110
|
"""
|
|
@@ -25,17 +25,22 @@ def testdata_score_normalier(tp_bumps=[(6.5, 256)], tn_bumps=[(3.5, 256)], tp_sc
|
|
|
25
25
|
encoder.fit(data, labels)
|
|
26
26
|
return encoder, data, labels
|
|
27
27
|
|
|
28
|
+
try:
|
|
29
|
+
_trapz = np.trapz
|
|
30
|
+
except Exception:
|
|
31
|
+
_trapz = np.trapezoid
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
def get_left_area(ydata, xdata, index_list):
|
|
30
35
|
""" area to the left of each index point """
|
|
31
|
-
left_area = np.array([
|
|
36
|
+
left_area = np.array([_trapz(ydata[:ix + 1], xdata[:ix + 1])
|
|
32
37
|
for ix in index_list])
|
|
33
38
|
return left_area
|
|
34
39
|
|
|
35
40
|
|
|
36
41
|
def get_right_area(ydata, xdata, index_list):
|
|
37
42
|
""" area to the right of each index point """
|
|
38
|
-
right_area = np.array([
|
|
43
|
+
right_area = np.array([_trapz(ydata[ix:], xdata[ix:])
|
|
39
44
|
for ix in index_list])
|
|
40
45
|
return right_area
|
|
41
46
|
|
|
@@ -207,7 +212,7 @@ class ScoreNormalizer(ut.Cachable, ScoreNormVisualizeClass):
|
|
|
207
212
|
>>> # ENABLE_DOCTEST
|
|
208
213
|
>>> from vtool_ibeis.score_normalization import * # NOQA
|
|
209
214
|
>>> encoder = ScoreNormalizer()
|
|
210
|
-
>>>
|
|
215
|
+
>>> import pickle
|
|
211
216
|
>>> dump = pickle.dumps(encoder)
|
|
212
217
|
>>> encoder2 = pickle.loads(dump)
|
|
213
218
|
"""
|
|
@@ -1017,8 +1022,8 @@ def learn_score_normalization(tp_support, tn_support, gridsize=1024, adjust=8,
|
|
|
1017
1022
|
|
|
1018
1023
|
if True:
|
|
1019
1024
|
# Make sure we still have probability functions
|
|
1020
|
-
area_tp =
|
|
1021
|
-
area_tn =
|
|
1025
|
+
area_tp = _trapz(p_score_given_tp, score_domain)
|
|
1026
|
+
area_tn = _trapz(p_score_given_tn, score_domain)
|
|
1022
1027
|
if verbose:
|
|
1023
1028
|
print('pre.area_tp = %r' % (area_tp,))
|
|
1024
1029
|
print('pre.area_tn = %r' % (area_tn,))
|
|
@@ -1027,8 +1032,8 @@ def learn_score_normalization(tp_support, tn_support, gridsize=1024, adjust=8,
|
|
|
1027
1032
|
p_score_given_tp = p_score_given_tp / area_tp
|
|
1028
1033
|
p_score_given_tn = p_score_given_tn / area_tn
|
|
1029
1034
|
|
|
1030
|
-
area_tp =
|
|
1031
|
-
area_tn =
|
|
1035
|
+
area_tp = _trapz(p_score_given_tp, score_domain)
|
|
1036
|
+
area_tn = _trapz(p_score_given_tn, score_domain)
|
|
1032
1037
|
#if ut.DEBUG2:
|
|
1033
1038
|
if verbose:
|
|
1034
1039
|
print('norm.area_tp = %r' % (area_tp,))
|
|
@@ -1055,12 +1060,12 @@ def learn_score_normalization(tp_support, tn_support, gridsize=1024, adjust=8,
|
|
|
1055
1060
|
# Apply bayes
|
|
1056
1061
|
p_tp_given_score = ut.bayes_rule(p_score_given_tp, p_tp, p_score)
|
|
1057
1062
|
if ut.DEBUG2:
|
|
1058
|
-
assert np.isclose(
|
|
1059
|
-
assert np.isclose(
|
|
1063
|
+
assert np.isclose(_trapz(p_score, score_domain), 1.0)
|
|
1064
|
+
assert np.isclose(_trapz(p_score, p_tp_given_score), 1.0)
|
|
1060
1065
|
if np.any(np.isnan(p_tp_given_score)):
|
|
1061
1066
|
p_tp_given_score = vt.interpolate_nans(p_tp_given_score)
|
|
1062
1067
|
if verbose:
|
|
1063
|
-
#
|
|
1068
|
+
# _trapz(p_tp_given_score / _trapz(p_tp_given_score, score_domain), score_domain)
|
|
1064
1069
|
print('stats:p_score_given_tn = ' + ut.get_stats_str(p_score_given_tn, newlines=0, use_nan=True, precision=5))
|
|
1065
1070
|
print('stats:p_score_given_tp = ' + ut.get_stats_str(p_score_given_tp, newlines=0, use_nan=True, precision=5))
|
|
1066
1071
|
print('stats:p_score = ' + ut.get_stats_str(p_score, newlines=0, use_nan=True, precision=5))
|
vtool_ibeis/segmentation.py
CHANGED
|
@@ -85,7 +85,7 @@ def demo_grabcut(bgr_img):
|
|
|
85
85
|
>>> import utool as ut
|
|
86
86
|
>>> import plottool_ibeis as pt
|
|
87
87
|
>>> import vtool_ibeis as vt
|
|
88
|
-
>>> img_fpath = ut.grab_test_imgpath('
|
|
88
|
+
>>> img_fpath = ut.grab_test_imgpath('astro')
|
|
89
89
|
>>> bgr_img = vt.imread(img_fpath)
|
|
90
90
|
>>> # execute function
|
|
91
91
|
>>> print(bgr_img.shape)
|
|
@@ -374,8 +374,8 @@ def testdata_matching_affine_inliers():
|
|
|
374
374
|
ori_thresh = 1.57
|
|
375
375
|
xy_thresh_sqrd = dlen_sqrd2 * xy_thresh
|
|
376
376
|
featkw = ut.argparse_dict(vt.get_extract_features_default_params())
|
|
377
|
-
fname1 = ut.get_argval('--fname1', type_=str, default='
|
|
378
|
-
fname2 = ut.get_argval('--fname2', type_=str, default='
|
|
377
|
+
fname1 = ut.get_argval('--fname1', type_=str, default='tsukuba_l')
|
|
378
|
+
fname2 = ut.get_argval('--fname2', type_=str, default='tsukuba_r')
|
|
379
379
|
(kpts1, kpts2, fm, fs, rchip1, rchip2) = demodata.testdata_ratio_matches(fname1, fname2, **featkw)
|
|
380
380
|
aff_inliers, aff_errors, Aff = get_best_affine_inliers_(
|
|
381
381
|
kpts1, kpts2, fm, fs, xy_thresh_sqrd, scale_thresh, ori_thresh)
|
|
@@ -958,8 +958,8 @@ def spatially_verify_kpts(kpts1, kpts2, fm,
|
|
|
958
958
|
>>> from vtool_ibeis.spatial_verification import *
|
|
959
959
|
>>> import vtool_ibeis.demodata as demodata
|
|
960
960
|
>>> import vtool_ibeis as vt
|
|
961
|
-
>>> fname1 = ut.get_argval('--fname1', type_=str, default='
|
|
962
|
-
>>> fname2 = ut.get_argval('--fname2', type_=str, default='
|
|
961
|
+
>>> fname1 = ut.get_argval('--fname1', type_=str, default='tsukuba_r')
|
|
962
|
+
>>> fname2 = ut.get_argval('--fname2', type_=str, default='tsukuba_l')
|
|
963
963
|
>>> default_dict = vt.get_extract_features_default_params()
|
|
964
964
|
>>> default_dict['ratio_thresh'] = .625
|
|
965
965
|
>>> kwargs = ut.argparse_dict(default_dict)
|
|
@@ -993,8 +993,6 @@ def spatially_verify_kpts(kpts1, kpts2, fm,
|
|
|
993
993
|
>>> aff_tup = (aff_inliers, Aff)
|
|
994
994
|
>>> pt.draw_sv.show_sv(rchip1, rchip2, kpts1, kpts2, fm, aff_tup=aff_tup, homog_tup=homog_tup, refine_method=refine_method)
|
|
995
995
|
>>> pt.show_if_requested()
|
|
996
|
-
tuple(numpy.ndarray, tuple(numpy.ndarray*3), numpy.ndarray, numpy.ndarray, tuple(numpy.ndarray*3), numpy.ndarray)
|
|
997
|
-
|
|
998
996
|
"""
|
|
999
997
|
if len(fm) == 0:
|
|
1000
998
|
if VERBOSE_SVER:
|
vtool_ibeis/symbolic.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Sympy helpers
|
|
3
3
|
"""
|
|
4
4
|
import numpy as np
|
|
5
|
-
import six
|
|
6
5
|
import utool as ut
|
|
7
6
|
import ubelt as ub
|
|
8
7
|
|
|
@@ -38,7 +37,7 @@ def evalprint(str_, globals_=None, locals_=None, simplify=False):
|
|
|
38
37
|
globals_ = ut.get_parent_frame().f_globals
|
|
39
38
|
if locals_ is None:
|
|
40
39
|
locals_ = ut.get_parent_frame().f_locals
|
|
41
|
-
if isinstance(str_,
|
|
40
|
+
if isinstance(str_, str):
|
|
42
41
|
var = eval(str_, globals_, locals_)
|
|
43
42
|
else:
|
|
44
43
|
var = str_
|
|
@@ -72,9 +71,9 @@ def check_expr_eq(expr1, expr2, verbose=True):
|
|
|
72
71
|
>>> print(result)
|
|
73
72
|
"""
|
|
74
73
|
import sympy
|
|
75
|
-
if isinstance(expr1,
|
|
74
|
+
if isinstance(expr1, str):
|
|
76
75
|
expr1 = sympy.simplify(expr1)
|
|
77
|
-
if isinstance(expr2,
|
|
76
|
+
if isinstance(expr2, str):
|
|
78
77
|
expr2 = sympy.simplify(expr2)
|
|
79
78
|
print(ub.hzcat('Checking if ', repr(expr1), ' == ', repr(expr2)))
|
|
80
79
|
random_point_check = expr1.equals(expr2)
|