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/__init__.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""
|
|
3
2
|
VTool - Computer vision tools
|
|
4
3
|
|
|
@@ -6,9 +5,7 @@ Autogenerate Command:
|
|
|
6
5
|
mkinit vtool_ibeis -i
|
|
7
6
|
"""
|
|
8
7
|
# flake8: noqa
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
__version__ = '2.2.0'
|
|
8
|
+
__version__ = '2.3.0'
|
|
12
9
|
__author__ = 'Jon Crall, Avi Weinstock, Chuck Stewart, Hendrik Weideman, Jason Parham, Zackary Rutfield'
|
|
13
10
|
__author_email__ = 'erotemic@gmail.com'
|
|
14
11
|
__url__ = 'https://github.com/Erotemic/vtool_ibeis'
|
vtool_ibeis/_rhomb_dist.py
CHANGED
vtool_ibeis/blend.py
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# LICENCE: Apache2
|
|
3
|
-
from __future__ import absolute_import, division, print_function
|
|
4
|
-
from six.moves import zip, map, range # NOQA
|
|
5
1
|
import numpy as np
|
|
6
2
|
import utool as ut
|
|
7
3
|
import ubelt as ub
|
|
@@ -9,7 +5,7 @@ import ubelt as ub
|
|
|
9
5
|
|
|
10
6
|
def testdata_blend(scale=128):
|
|
11
7
|
import vtool_ibeis as vt
|
|
12
|
-
img_fpath = ut.grab_test_imgpath('
|
|
8
|
+
img_fpath = ut.grab_test_imgpath('astro')
|
|
13
9
|
img1 = vt.imread(img_fpath)
|
|
14
10
|
rng = np.random.RandomState(0)
|
|
15
11
|
img2 = vt.perlin_noise(img1.shape[0:2], scale=scale, rng=rng)[None, :].T
|
vtool_ibeis/chip.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# LICENCE
|
|
2
|
-
from __future__ import absolute_import, division, print_function
|
|
3
1
|
import numpy as np
|
|
4
2
|
import numpy.linalg as npl
|
|
5
3
|
from vtool_ibeis import linalg as ltool
|
|
@@ -7,10 +5,9 @@ from vtool_ibeis import image as gtool
|
|
|
7
5
|
import utool as ut
|
|
8
6
|
try:
|
|
9
7
|
import cv2
|
|
10
|
-
except ImportError
|
|
8
|
+
except ImportError:
|
|
11
9
|
print('ERROR: import cv2 is failing!')
|
|
12
|
-
|
|
13
|
-
cv2.INTER_LANCZOS4 = None
|
|
10
|
+
raise
|
|
14
11
|
|
|
15
12
|
|
|
16
13
|
def get_image_to_chip_transform(bbox, chipsz, theta):
|
vtool_ibeis/clustering2.py
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# LICENCE
|
|
3
1
|
"""
|
|
4
2
|
TODO:
|
|
5
3
|
Does HDBSCAN work on 128 dim vectors?
|
|
6
4
|
http://nbviewer.jupyter.org/github/lmcinnes/hdbscan/blob/master/notebooks/Comparing%20Clustering%20Algorithms.ipynb
|
|
7
5
|
"""
|
|
8
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
9
|
-
from six.moves import zip, map # NOQA
|
|
10
6
|
import ubelt as ub
|
|
11
7
|
import numpy as np
|
|
12
8
|
import utool as ut
|
|
@@ -171,7 +167,8 @@ def group_indices(idx2_groupid, assume_sorted=False):
|
|
|
171
167
|
>>> (keys, groupxs) = group_indices(idx2_groupid)
|
|
172
168
|
>>> result = ut.repr2((keys, groupxs), nl=2, nobr=True, with_dtype=True)
|
|
173
169
|
>>> print(result)
|
|
174
|
-
|
|
170
|
+
|
|
171
|
+
np.array([False, True], dtype=bool),
|
|
175
172
|
[
|
|
176
173
|
np.array([2, 4, 5], dtype=np.int64),
|
|
177
174
|
np.array([0, 1, 3, 6], dtype=np.int64),
|
|
@@ -293,10 +290,10 @@ def find_duplicate_items(item_arr):
|
|
|
293
290
|
sortx = item_arr.argsort()
|
|
294
291
|
groupids_sorted = item_arr.take(sortx)
|
|
295
292
|
|
|
296
|
-
#duplicate_idxs = np.flatnonzero(~np.diff(groupids_sorted).astype(
|
|
293
|
+
#duplicate_idxs = np.flatnonzero(~np.diff(groupids_sorted).astype(bool))
|
|
297
294
|
diff = np.diff(groupids_sorted)
|
|
298
|
-
#notdiff = np.bitwise_not(diff.astype(
|
|
299
|
-
edges = np.flatnonzero(diff.astype(
|
|
295
|
+
#notdiff = np.bitwise_not(diff.astype(bool))
|
|
296
|
+
edges = np.flatnonzero(diff.astype(bool)) + 1
|
|
300
297
|
duplicate_items = [group[0] for group in np.split(groupids_sorted, edges)
|
|
301
298
|
if group.shape[0] > 1]
|
|
302
299
|
#duplicate_items = groupids_sorted.take(duplicate_idxs)
|
vtool_ibeis/confusion.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
"""
|
|
3
2
|
Module for -- Confusion matrix, contingency, error matrix,
|
|
4
3
|
|
|
5
4
|
References:
|
|
6
5
|
http://en.wikipedia.org/wiki/Confusion_matrix
|
|
7
6
|
"""
|
|
8
|
-
from __future__ import absolute_import, division, print_function
|
|
9
7
|
import utool as ut
|
|
10
8
|
import ubelt as ub
|
|
11
9
|
import numpy as np
|
|
@@ -373,7 +371,7 @@ class ConfusionMetrics(ub.NiceRepr):
|
|
|
373
371
|
scores = np.asarray(scores)
|
|
374
372
|
labels = np.asarray(labels)
|
|
375
373
|
# must be binary
|
|
376
|
-
labels = labels.astype(
|
|
374
|
+
labels = labels.astype(bool)
|
|
377
375
|
if verbose:
|
|
378
376
|
print('[confusion] building confusion metrics.')
|
|
379
377
|
print('[confusion] * scores.shape=%r, scores.dtype=%r' %
|
|
@@ -499,7 +497,7 @@ class ConfusionMetrics(ub.NiceRepr):
|
|
|
499
497
|
python -m vtool_ibeis.confusion --exec-interact_roc_factory --show
|
|
500
498
|
|
|
501
499
|
Example:
|
|
502
|
-
>>> #
|
|
500
|
+
>>> # xdoctest: +SKIP
|
|
503
501
|
>>> from vtool_ibeis.confusion import * # NOQA
|
|
504
502
|
>>> scores, labels = testdata_scores_labels()
|
|
505
503
|
>>> self = ConfusionMetrics().fit(scores, labels)
|
|
@@ -798,15 +796,15 @@ def interpolate_replbounds(xdata, ydata, pt, maximize=True):
|
|
|
798
796
|
>>> print('thresh = %r' % (thresh,))
|
|
799
797
|
|
|
800
798
|
Example:
|
|
801
|
-
>>> #
|
|
799
|
+
>>> # xdoctest: +SKIP
|
|
802
800
|
>>> from vtool_ibeis.confusion import * # NOQA
|
|
803
801
|
>>> xdata = np.array([0.7, 0.8, 0.8, 0.9, 0.9, 0.9])
|
|
804
802
|
>>> ydata = np.array([34, 26, 23, 22, 19, 17])
|
|
805
803
|
>>> pt = np.array([.85, 1.0, -1.0])
|
|
806
804
|
>>> interp_vals = interpolate_replbounds(xdata, ydata, pt)
|
|
807
805
|
>>> result = ('interp_vals = %s' % (str(interp_vals),))
|
|
806
|
+
>>> assert np.allclose(results, [ 22.5, 17., 34., ])
|
|
808
807
|
>>> print(result)
|
|
809
|
-
interp_vals = [ 22.5 17. 34. ]
|
|
810
808
|
"""
|
|
811
809
|
if not ut.issorted(xdata):
|
|
812
810
|
if ut.issorted(xdata[::-1]):
|
|
@@ -939,7 +937,7 @@ def interact_roc_factory(confusions, target_tpr=None, show_operating_point=False
|
|
|
939
937
|
python -m vtool_ibeis.confusion --exec-interact_roc_factory --show
|
|
940
938
|
|
|
941
939
|
Example:
|
|
942
|
-
>>> #
|
|
940
|
+
>>> # xdoctest: +SKIP
|
|
943
941
|
>>> from vtool_ibeis.confusion import * # NOQA
|
|
944
942
|
>>> scores, labels = testdata_scores_labels()
|
|
945
943
|
>>> print('scores = %r' % (scores,))
|
|
@@ -1026,7 +1024,7 @@ def draw_roc_curve(fpr, tpr, fnum=None, pnum=None, marker='', target_tpr=None,
|
|
|
1026
1024
|
python -m vtool_ibeis.confusion --exec-draw_roc_curve --show --lightbg
|
|
1027
1025
|
|
|
1028
1026
|
Example:
|
|
1029
|
-
>>> #
|
|
1027
|
+
>>> # xdoctest: +SKIP
|
|
1030
1028
|
>>> from vtool_ibeis.confusion import * # NOQA
|
|
1031
1029
|
>>> scores, labels = testdata_scores_labels()
|
|
1032
1030
|
>>> confusions = ConfusionMetrics().fit(scores, labels)
|
vtool_ibeis/coverage_grid.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
|
-
from six.moves import zip, range, map # NOQA
|
|
4
1
|
import numpy as np
|
|
5
2
|
import utool as ut
|
|
6
3
|
import ubelt as ub
|
|
@@ -37,7 +34,7 @@ def make_grid_coverage_mask(kpts, chipsize, weights, pxl_per_bin=4,
|
|
|
37
34
|
>>> from vtool_ibeis.coverage_grid import * # NOQA
|
|
38
35
|
>>> import vtool_ibeis as vt
|
|
39
36
|
>>> # build test data
|
|
40
|
-
>>> kpts, chipsize, weights = coverage_kpts.testdata_coverage('
|
|
37
|
+
>>> kpts, chipsize, weights = coverage_kpts.testdata_coverage('tsukuba_l')
|
|
41
38
|
>>> pxl_per_bin = 4
|
|
42
39
|
>>> grid_steps = 2
|
|
43
40
|
>>> # execute function
|
|
@@ -326,7 +323,7 @@ def gridsearch_coverage_grid_mask():
|
|
|
326
323
|
"""
|
|
327
324
|
import plottool_ibeis as pt
|
|
328
325
|
cfgdict_list, cfglbl_list = get_coverage_grid_gridsearch_configs()
|
|
329
|
-
kpts, chipsize, weights = coverage_kpts.testdata_coverage('
|
|
326
|
+
kpts, chipsize, weights = coverage_kpts.testdata_coverage('astro')
|
|
330
327
|
gridmask_list = [
|
|
331
328
|
255 * make_grid_coverage_mask(kpts, chipsize, weights, **cfgdict)
|
|
332
329
|
for cfgdict in ub.ProgIter(cfgdict_list, desc='coverage grid')
|
vtool_ibeis/coverage_kpts.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
|
-
from six.moves import zip, range, map, reduce # NOQA
|
|
1
|
+
from functools import reduce
|
|
4
2
|
import cv2
|
|
5
3
|
import numpy as np
|
|
6
4
|
import utool as ut
|
|
@@ -39,7 +37,7 @@ def make_kpts_heatmask(kpts, chipsize, cmap='plasma'):
|
|
|
39
37
|
>>> from vtool_ibeis.coverage_kpts import * # NOQA
|
|
40
38
|
>>> import vtool_ibeis as vt
|
|
41
39
|
>>> import pyhesaff
|
|
42
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
40
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
43
41
|
>>> (kpts, vecs) = pyhesaff.detect_feats(img_fpath)
|
|
44
42
|
>>> chip = vt.imread(img_fpath)
|
|
45
43
|
>>> kpts = kpts[0:100]
|
|
@@ -131,7 +129,7 @@ def make_kpts_coverage_mask(
|
|
|
131
129
|
>>> import vtool_ibeis as vt
|
|
132
130
|
>>> import plottool_ibeis as pt
|
|
133
131
|
>>> import pyhesaff
|
|
134
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
132
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
135
133
|
>>> (kpts, vecs) = pyhesaff.detect_feats(img_fpath)
|
|
136
134
|
>>> kpts = kpts[::10]
|
|
137
135
|
>>> chip = vt.imread(img_fpath)
|
|
@@ -212,7 +210,7 @@ def warp_patch_onto_kpts(
|
|
|
212
210
|
>>> from vtool_ibeis.coverage_kpts import * # NOQA
|
|
213
211
|
>>> import vtool_ibeis as vt
|
|
214
212
|
>>> import pyhesaff
|
|
215
|
-
>>> img_fpath = ut.grab_test_imgpath('carl
|
|
213
|
+
>>> img_fpath = ut.grab_test_imgpath('carl')
|
|
216
214
|
>>> (kpts, vecs) = pyhesaff.detect_feats(img_fpath)
|
|
217
215
|
>>> kpts = kpts[::15]
|
|
218
216
|
>>> chip = vt.imread(img_fpath)
|
|
@@ -436,7 +434,8 @@ def gridsearch_kpts_coverage_mask():
|
|
|
436
434
|
"""
|
|
437
435
|
import plottool_ibeis as pt
|
|
438
436
|
cfgdict_list, cfglbl_list = get_coverage_kpts_gridsearch_configs()
|
|
439
|
-
kpts, chipsize, weights = testdata_coverage('easy1.png')
|
|
437
|
+
# kpts, chipsize, weights = testdata_coverage('easy1.png')
|
|
438
|
+
kpts, chipsize, weights = testdata_coverage('astro')
|
|
440
439
|
imgmask_list = [
|
|
441
440
|
255 * make_kpts_coverage_mask(kpts, chipsize, weights,
|
|
442
441
|
return_patch=False, **cfgdict)
|
|
@@ -461,18 +460,18 @@ def testdata_coverage(fname=None):
|
|
|
461
460
|
# build test data
|
|
462
461
|
kpts, vecs = vt.demodata.get_testdata_kpts(fname, with_vecs=True)
|
|
463
462
|
# HACK IN DISTINCTIVENESS
|
|
464
|
-
if fname is not None:
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
else:
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
463
|
+
# if fname is not None:
|
|
464
|
+
# from ibeis.algo.hots import distinctiveness_normalizer
|
|
465
|
+
# cachedir = ub.ensure_app_cache_dir('ibeis', 'distinctiveness_model')
|
|
466
|
+
# species = 'zebra_plains'
|
|
467
|
+
# dstcnvs_normer = distinctiveness_normalizer.DistinctivnessNormalizer(species, cachedir=cachedir)
|
|
468
|
+
# dstcnvs_normer.load(cachedir)
|
|
469
|
+
# weights = dstcnvs_normer.get_distinctiveness(vecs)
|
|
470
|
+
# else:
|
|
471
|
+
kpts = np.vstack((kpts, [0, 0, 1, 1, 1, 0]))
|
|
472
|
+
kpts = np.vstack((kpts, [0.01, 10, 1, 1, 1, 0]))
|
|
473
|
+
kpts = np.vstack((kpts, [0.94, 11.5, 1, 1, 1, 0]))
|
|
474
|
+
weights = np.ones(len(kpts))
|
|
476
475
|
chipsize = tuple(vt.iceil(vt.get_kpts_image_extent(kpts)[2:4]).tolist())
|
|
477
476
|
return kpts, chipsize, weights
|
|
478
477
|
|
vtool_ibeis/demodata.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
1
|
from vtool_ibeis import keypoint as ktool
|
|
4
2
|
import vtool_ibeis.util_math as mtool
|
|
5
3
|
import numpy as np
|
|
@@ -314,7 +312,7 @@ def testdata_binary_scores():
|
|
|
314
312
|
-0.6 , 5.76, -0.79, 13.99, 9.82, 30.6 , -1.13, -2.05, 21.3 ,
|
|
315
313
|
-1.87, 17.61, -1.25, 8.64, -2.06, 4.48, 19.48, -0.64, 15.85,
|
|
316
314
|
4.54, -1.57, -1.28, 12.3 , -1.39, -0.04, 12.81, -0.09, 4.83,
|
|
317
|
-
6.42, 4.26, 7.65, -0.43, -0.23, -1.98], dtype=
|
|
315
|
+
6.42, 4.26, 7.65, -0.43, -0.23, -1.98], dtype=float)
|
|
318
316
|
|
|
319
317
|
y = np.array([
|
|
320
318
|
1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1,
|
|
@@ -358,7 +356,7 @@ def testdata_binary_scores():
|
|
|
358
356
|
1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0,
|
|
359
357
|
0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0,
|
|
360
358
|
0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1,
|
|
361
|
-
0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], dtype=
|
|
359
|
+
0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], dtype=bool)
|
|
362
360
|
return X, y
|
|
363
361
|
|
|
364
362
|
|
|
@@ -635,7 +633,7 @@ def get_testdata_kpts(fname=None, with_vecs=False):
|
|
|
635
633
|
return kpts
|
|
636
634
|
|
|
637
635
|
|
|
638
|
-
def testdata_ratio_matches(fname1='
|
|
636
|
+
def testdata_ratio_matches(fname1='tsukuba_r', fname2='tsukuba_l', **kwargs):
|
|
639
637
|
r"""
|
|
640
638
|
Runs simple ratio-test matching between two images.
|
|
641
639
|
Technically this is not demodata data.
|
|
@@ -661,8 +659,8 @@ def testdata_ratio_matches(fname1='easy1.png', fname2='easy2.png', **kwargs):
|
|
|
661
659
|
>>> # xdoctest: +REQUIRES(module:pyhesaff)
|
|
662
660
|
>>> from vtool_ibeis.demodata import * # NOQA
|
|
663
661
|
>>> import vtool_ibeis as vt
|
|
664
|
-
>>> fname1 = ut.get_argval('--fname1', type_=str, default='
|
|
665
|
-
>>> fname2 = ut.get_argval('--fname2', type_=str, default='
|
|
662
|
+
>>> fname1 = ut.get_argval('--fname1', type_=str, default='tsukuba_l')
|
|
663
|
+
>>> fname2 = ut.get_argval('--fname2', type_=str, default='tsukuba_r')
|
|
666
664
|
>>> default_dict = vt.get_extract_features_default_params()
|
|
667
665
|
>>> default_dict['ratio_thresh'] = .625
|
|
668
666
|
>>> kwargs = ut.argparse_dict(default_dict)
|
vtool_ibeis/distance.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
1
|
import numpy as np
|
|
4
|
-
import utool as ut
|
|
5
2
|
import ubelt as ub
|
|
6
3
|
import itertools
|
|
7
|
-
from six.moves import range, zip
|
|
8
4
|
from collections import OrderedDict
|
|
9
5
|
import scipy.spatial.distance as spdist
|
|
10
6
|
from .util_math import TAU
|
|
@@ -129,8 +125,8 @@ def ori_distance(ori1, ori2, out=None):
|
|
|
129
125
|
func_orig()
|
|
130
126
|
'''
|
|
131
127
|
>>> ).split('\n')
|
|
132
|
-
>>> ut.util_dev.rrr()
|
|
133
|
-
>>> ut.util_dev.timeit_compare(stmt_list, setup, int(1E3))
|
|
128
|
+
>>> # ut.util_dev.rrr()
|
|
129
|
+
>>> # ut.util_dev.timeit_compare(stmt_list, setup, int(1E3))
|
|
134
130
|
|
|
135
131
|
CommandLine:
|
|
136
132
|
python -m vtool_ibeis.distance --test-ori_distance
|
|
@@ -258,7 +254,7 @@ def L2_sqrd(hist1, hist2, dtype=TEMP_VEC_DTYPE):
|
|
|
258
254
|
>>> # ENABLE_DOCTEST
|
|
259
255
|
>>> from vtool_ibeis.distance import * # NOQA
|
|
260
256
|
>>> import numpy
|
|
261
|
-
>>> ut.exec_funckw(L2_sqrd, globals())
|
|
257
|
+
>>> #ut.exec_funckw(L2_sqrd, globals())
|
|
262
258
|
>>> rng = np.random.RandomState(53)
|
|
263
259
|
>>> hist1 = rng.rand(5, 2)
|
|
264
260
|
>>> hist2 = rng.rand(5, 2)
|
|
@@ -622,10 +618,10 @@ def emd(hist1, hist2, cost_matrix='sift'):
|
|
|
622
618
|
|
|
623
619
|
if len(hist1.shape) == 2:
|
|
624
620
|
dist = np.array([
|
|
625
|
-
pyemd.emd(hist1_.astype(
|
|
621
|
+
pyemd.emd(hist1_.astype(float), hist2_.astype(float), cost_matrix)
|
|
626
622
|
for hist1_, hist2_ in zip(hist1, hist2)])
|
|
627
623
|
else:
|
|
628
|
-
dist = pyemd.emd(hist1.astype(
|
|
624
|
+
dist = pyemd.emd(hist1.astype(float), hist2.astype(float), cost_matrix)
|
|
629
625
|
return dist
|
|
630
626
|
|
|
631
627
|
|
|
@@ -634,7 +630,6 @@ def nearest_point(x, y, pts, conflict_mode='next', __next_counter=[0]):
|
|
|
634
630
|
|
|
635
631
|
TODO: depricate
|
|
636
632
|
"""
|
|
637
|
-
#with ut.embed_on_exception_context:
|
|
638
633
|
dists = (pts.T[0] - x) ** 2 + (pts.T[1] - y) ** 2
|
|
639
634
|
fx = dists.argmin()
|
|
640
635
|
mindist = dists[fx]
|
|
@@ -713,7 +708,7 @@ def haversine(latlon1, latlon2):
|
|
|
713
708
|
>>> dist_vector_list = list(map(haversin_pdist, gpsarr_track_list_))
|
|
714
709
|
>>> dist_matrix_list = list(map(spdist.squareform, dist_vector_list))
|
|
715
710
|
>>> #xdoctest: +IGNORE_WHITESPACE
|
|
716
|
-
>>> result = ('dist_matrix_list = %s' % (
|
|
711
|
+
>>> result = ('dist_matrix_list = %s' % (ub.repr2(dist_matrix_list, precision=2, with_dtype=True),))
|
|
717
712
|
>>> print(result)
|
|
718
713
|
"""
|
|
719
714
|
# FIXME; lat, lon should be different columns not different rows
|
|
@@ -787,10 +782,10 @@ def pdist_argsort(x):
|
|
|
787
782
|
sortx_2d = [(r, c) for r, c in zip(sortx_row, sortx_col) if (c > r)]
|
|
788
783
|
else:
|
|
789
784
|
num_rows = len(x) // 2
|
|
790
|
-
compare_idxs =
|
|
791
|
-
|
|
785
|
+
compare_idxs = list(ub.flatten([[(r, c) for c in range(r + 1, num_rows)]
|
|
786
|
+
for r in range(num_rows)]))
|
|
792
787
|
sortx = x.argsort()
|
|
793
|
-
sortx_2d =
|
|
788
|
+
sortx_2d = list(ub.take(compare_idxs, sortx))
|
|
794
789
|
return sortx_2d
|
|
795
790
|
|
|
796
791
|
|
vtool_ibeis/ellipse.py
CHANGED
|
@@ -3,20 +3,17 @@ OLD MODULE, needs reimplemenetation of select features and deprication
|
|
|
3
3
|
|
|
4
4
|
This module should handle all things elliptical
|
|
5
5
|
"""
|
|
6
|
-
from __future__ import absolute_import, division, print_function
|
|
7
|
-
from six.moves import zip, range
|
|
8
6
|
# from numpy.core.umath_tests import matrix_multiply
|
|
9
7
|
import operator as op
|
|
10
8
|
import scipy.signal as spsignal
|
|
11
9
|
import numpy as np
|
|
12
10
|
from vtool_ibeis import keypoint as ktool
|
|
13
11
|
from vtool_ibeis import image as gtool
|
|
14
|
-
import utool as ut
|
|
15
12
|
try:
|
|
16
13
|
import cv2
|
|
17
14
|
except ImportError:
|
|
18
15
|
print('ERROR: import cv2 is failing!')
|
|
19
|
-
cv2 =
|
|
16
|
+
cv2 = object()
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
def adaptive_scale(img_fpath, kpts, nScales=4, low=-.5, high=.5, nSamples=16):
|
|
@@ -60,7 +57,7 @@ def check_kpts_in_bounds(kpts_, width, height):
|
|
|
60
57
|
minx = np.array([pts[0].min() for pts in bbox_pts]) > 0
|
|
61
58
|
maxy = np.array([pts[1].max() for pts in bbox_pts]) < height
|
|
62
59
|
miny = np.array([pts[1].min() for pts in bbox_pts]) > 0
|
|
63
|
-
isvalid = np.array(maxx * minx * maxy * miny, dtype=
|
|
60
|
+
isvalid = np.array(maxx * minx * maxy * miny, dtype=bool)
|
|
64
61
|
return isvalid
|
|
65
62
|
|
|
66
63
|
|
vtool_ibeis/exif.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# LICENCE
|
|
3
1
|
"""
|
|
4
2
|
References:
|
|
5
3
|
http://www.exiv2.org/tags.html
|
|
@@ -7,9 +5,6 @@ References:
|
|
|
7
5
|
TODO:
|
|
8
6
|
https://github.com/recurser/exif-orientation-examples
|
|
9
7
|
"""
|
|
10
|
-
from __future__ import absolute_import, division, print_function
|
|
11
|
-
from six.moves import zip, range
|
|
12
|
-
import six
|
|
13
8
|
from PIL.ExifTags import TAGS, GPSTAGS
|
|
14
9
|
import PIL.ExifTags # NOQA
|
|
15
10
|
from PIL import Image
|
|
@@ -20,8 +15,8 @@ from vtool_ibeis import image_shared
|
|
|
20
15
|
|
|
21
16
|
|
|
22
17
|
# Inverse of PIL.ExifTags.TAGS
|
|
23
|
-
EXIF_TAG_TO_TAGID = {val: key for (key, val) in
|
|
24
|
-
GPS_TAG_TO_GPSID = {val: key for (key, val) in
|
|
18
|
+
EXIF_TAG_TO_TAGID = {val: key for (key, val) in TAGS.items()}
|
|
19
|
+
GPS_TAG_TO_GPSID = {val: key for (key, val) in GPSTAGS.items()}
|
|
25
20
|
|
|
26
21
|
# Relevant EXIF Tags
|
|
27
22
|
#'GPSInfo': 34853
|
|
@@ -115,7 +110,7 @@ def get_exif_dict2(pil_img):
|
|
|
115
110
|
|
|
116
111
|
def make_exif_dict_human_readable(exif_dict):
|
|
117
112
|
exif_dict2 = {TAGS.get(key, key): val
|
|
118
|
-
for (key, val) in
|
|
113
|
+
for (key, val) in exif_dict.items()}
|
|
119
114
|
return exif_dict2
|
|
120
115
|
|
|
121
116
|
|
|
@@ -123,7 +118,7 @@ def check_exif_keys(pil_img):
|
|
|
123
118
|
info_ = pil_img._getexif()
|
|
124
119
|
valid_keys = []
|
|
125
120
|
invalid_keys = []
|
|
126
|
-
for key, val in
|
|
121
|
+
for key, val in info_.items():
|
|
127
122
|
try:
|
|
128
123
|
exif_keyval = TAGS[key]
|
|
129
124
|
valid_keys.append((key, exif_keyval))
|
|
@@ -137,7 +132,7 @@ def read_all_exif_tags(pil_img):
|
|
|
137
132
|
info_ = pil_img._getexif()
|
|
138
133
|
exif = {} if info_ is None else {
|
|
139
134
|
TAGS.get(key, key): val
|
|
140
|
-
for key, val in
|
|
135
|
+
for key, val in info_.items()
|
|
141
136
|
}
|
|
142
137
|
return exif
|
|
143
138
|
|
vtool_ibeis/features.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, print_function, division
|
|
3
1
|
import utool as ut
|
|
4
2
|
import ubelt as ub
|
|
5
3
|
import six
|
|
@@ -43,7 +41,7 @@ def extract_features(img_or_fpath, feat_type='hesaff+sift', **kwargs):
|
|
|
43
41
|
>>> from vtool_ibeis.features import * # NOQA
|
|
44
42
|
>>> import vtool_ibeis as vt
|
|
45
43
|
>>> # build test data
|
|
46
|
-
>>> img_fpath = ut.grab_test_imgpath(ut.get_argval('--fname', default='
|
|
44
|
+
>>> img_fpath = ut.grab_test_imgpath(ut.get_argval('--fname', default='astro'))
|
|
47
45
|
>>> imgBGR = vt.imread(img_fpath)
|
|
48
46
|
>>> feat_type = ub.argval('--feat_type', default='hesaff+sift')
|
|
49
47
|
>>> import pyhesaff
|
|
@@ -111,8 +109,7 @@ def detect_opencv_keypoints():
|
|
|
111
109
|
import vtool_ibeis as vt
|
|
112
110
|
import numpy as np # NOQA
|
|
113
111
|
|
|
114
|
-
|
|
115
|
-
img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='zebra.png'))
|
|
112
|
+
img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='astro'))
|
|
116
113
|
imgBGR = vt.imread(img_fpath)
|
|
117
114
|
imgGray = cv2.cvtColor(imgBGR, cv2.COLOR_BGR2GRAY)
|
|
118
115
|
|
|
@@ -253,7 +250,7 @@ def test_mser():
|
|
|
253
250
|
info = {key: list(ub.compress(val, flags)) for key, val in self.info.items()}
|
|
254
251
|
return Keypoints(subarr, info)
|
|
255
252
|
|
|
256
|
-
img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='
|
|
253
|
+
img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='astro'))
|
|
257
254
|
imgBGR = vt.imread(img_fpath)
|
|
258
255
|
imgGray = cv2.cvtColor(imgBGR, cv2.COLOR_BGR2GRAY)
|
|
259
256
|
# http://docs.opencv.org/master/d3/d28/classcv_1_1MSER.html#gsc.tab=0
|
vtool_ibeis/fontdemo.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
1
|
# Needs freetype-py>=1.0
|
|
4
2
|
# The MIT License (MIT)
|
|
5
3
|
#
|
|
@@ -27,7 +25,6 @@ References:
|
|
|
27
25
|
https://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
|
|
28
26
|
https://gist.github.com/dbader/5488053#file-fontdemo-py-L244
|
|
29
27
|
"""
|
|
30
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
31
28
|
|
|
32
29
|
|
|
33
30
|
class Bitmap(object):
|
vtool_ibeis/geometry.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# LICENCE
|
|
3
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
4
|
-
from six.moves import zip
|
|
5
1
|
import numpy as np
|
|
6
2
|
import utool as ut
|
|
7
|
-
import ubelt as ub
|
|
3
|
+
import ubelt as ub # NOQA
|
|
8
4
|
import cv2
|
|
9
5
|
|
|
10
6
|
|
|
@@ -27,9 +23,6 @@ def verts_from_bbox(bbox, close=False):
|
|
|
27
23
|
Returns:
|
|
28
24
|
list: verts
|
|
29
25
|
|
|
30
|
-
CommandLine:
|
|
31
|
-
python -m vtool_ibeis.geometry --test-verts_from_bbox
|
|
32
|
-
|
|
33
26
|
Example:
|
|
34
27
|
>>> # ENABLE_DOCTEST
|
|
35
28
|
>>> from vtool_ibeis.geometry import * # NOQA
|
|
@@ -70,14 +63,11 @@ def draw_border(img_in, color=(0, 128, 255), thickness=2, out=None):
|
|
|
70
63
|
thickness (int):
|
|
71
64
|
out (None):
|
|
72
65
|
|
|
73
|
-
CommandLine:
|
|
74
|
-
python -m vtool_ibeis.geometry --test-draw_border --show
|
|
75
|
-
|
|
76
66
|
Example:
|
|
77
67
|
>>> # ENABLE_DOCTEST
|
|
78
68
|
>>> from vtool_ibeis.geometry import * # NOQA
|
|
79
69
|
>>> import vtool_ibeis as vt
|
|
80
|
-
>>> img_in = vt.imread(ut.grab_test_imgpath('carl
|
|
70
|
+
>>> img_in = vt.imread(ut.grab_test_imgpath('carl'))
|
|
81
71
|
>>> color = (0, 128, 255)
|
|
82
72
|
>>> thickness = 20
|
|
83
73
|
>>> out = None
|
|
@@ -125,7 +115,7 @@ def draw_verts(img_in, verts, color=(0, 128, 255), thickness=2, out=None):
|
|
|
125
115
|
>>> import plottool_ibeis as pt
|
|
126
116
|
>>> import vtool_ibeis as vt
|
|
127
117
|
>>> # build test data
|
|
128
|
-
>>> img_in = vt.imread(ut.grab_test_imgpath('carl
|
|
118
|
+
>>> img_in = vt.imread(ut.grab_test_imgpath('carl'))
|
|
129
119
|
>>> verts = ((10, 10), (10, 100), (100, 100), (100, 10))
|
|
130
120
|
>>> color = (0, 128, 255)
|
|
131
121
|
>>> thickness = 2
|
|
@@ -147,7 +137,7 @@ def draw_verts(img_in, verts, color=(0, 128, 255), thickness=2, out=None):
|
|
|
147
137
|
>>> import plottool_ibeis as pt
|
|
148
138
|
>>> import vtool_ibeis as vt
|
|
149
139
|
>>> # build test data
|
|
150
|
-
>>> img_in = vt.imread(ut.grab_test_imgpath('carl
|
|
140
|
+
>>> img_in = vt.imread(ut.grab_test_imgpath('carl'))
|
|
151
141
|
>>> verts = ((10, 10), (10, 100), (100, 100), (100, 10))
|
|
152
142
|
>>> color = (0, 128, 255)
|
|
153
143
|
>>> thickness = 2
|
|
@@ -205,7 +195,7 @@ def closest_point_on_line_segment(p, e1, e2):
|
|
|
205
195
|
>>> # ENABLE_DOCTEST
|
|
206
196
|
>>> from vtool_ibeis.geometry import * # NOQA
|
|
207
197
|
>>> import vtool_ibeis as vt
|
|
208
|
-
>>> #bbox = np.array([10, 10, 10, 10], dtype=
|
|
198
|
+
>>> #bbox = np.array([10, 10, 10, 10], dtype=float)
|
|
209
199
|
>>> #verts_ = np.array(vt.verts_from_bbox(bbox, close=True))
|
|
210
200
|
>>> #R = vt.rotation_around_bbox_mat3x3(vt.TAU / 3, bbox)
|
|
211
201
|
>>> #verts = vt.transform_points_with_homography(R, verts_.T).T
|
|
@@ -325,8 +315,8 @@ def closest_point_on_bbox(p, bbox):
|
|
|
325
315
|
Example1:
|
|
326
316
|
>>> # ENABLE_DOCTEST
|
|
327
317
|
>>> from vtool_ibeis.geometry import * # NOQA
|
|
328
|
-
>>> p_list = np.array([[19, 7], [7, 14], [14, 11], [8, 7], [23, 21]], dtype=
|
|
329
|
-
>>> bbox = np.array([10, 10, 10, 10], dtype=
|
|
318
|
+
>>> p_list = np.array([[19, 7], [7, 14], [14, 11], [8, 7], [23, 21]], dtype=float)
|
|
319
|
+
>>> bbox = np.array([10, 10, 10, 10], dtype=float)
|
|
330
320
|
>>> [closest_point_on_bbox(p, bbox) for p in p_list]
|
|
331
321
|
"""
|
|
332
322
|
import vtool_ibeis as vt
|
|
@@ -557,7 +547,7 @@ def point_inside_bbox(point, bbox):
|
|
|
557
547
|
>>> ]).T
|
|
558
548
|
>>> bbox = (3, 2, 5, 7)
|
|
559
549
|
>>> flag = point_inside_bbox(point, bbox)
|
|
560
|
-
>>> flag = flag.astype(
|
|
550
|
+
>>> flag = flag.astype(int)
|
|
561
551
|
>>> result = ('flag = %s' % (ub.repr2(flag),))
|
|
562
552
|
>>> print(result)
|
|
563
553
|
>>> # xdoctest: +REQUIRES(--show)
|
vtool_ibeis/histogram.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
3
|
-
from six.moves import zip
|
|
4
1
|
import warnings
|
|
5
2
|
import scipy.signal
|
|
6
3
|
import numpy as np
|
|
@@ -241,7 +238,7 @@ def argsubextrema2(op, ydata, xdata=None, thresh_factor=None, normalize_x=True,
|
|
|
241
238
|
|
|
242
239
|
if thresh_factor is None:
|
|
243
240
|
thresh_value = None
|
|
244
|
-
flags = np.ones(len(ydata), dtype=
|
|
241
|
+
flags = np.ones(len(ydata), dtype=bool)
|
|
245
242
|
else:
|
|
246
243
|
# Find relative and flat extrema
|
|
247
244
|
thresh_value = factor_op(abs_extreme_y, thresh_factor)
|
|
@@ -320,7 +317,7 @@ def argsubextrema2(op, ydata, xdata=None, thresh_factor=None, normalize_x=True,
|
|
|
320
317
|
|
|
321
318
|
# Any non-flat mid extrema can be sublocalized
|
|
322
319
|
other_argextrema = np.hstack([boundary_argextrema, flat_argextrema])
|
|
323
|
-
other_argextrema = other_argextrema.astype(
|
|
320
|
+
other_argextrema = other_argextrema.astype(int)
|
|
324
321
|
other_subextrema_y = ydata[other_argextrema]
|
|
325
322
|
if xdata is None:
|
|
326
323
|
other_subextrema_x = other_argextrema
|
|
@@ -396,8 +393,8 @@ def linear_interpolation(arr, subindices):
|
|
|
396
393
|
>>> assert np.allclose(subindices, subvalues)
|
|
397
394
|
>>> assert np.allclose(2.3, linear_interpolation(arr, 2.3))
|
|
398
395
|
"""
|
|
399
|
-
idx1 = np.floor(subindices).astype(
|
|
400
|
-
idx2 = np.floor(subindices + 1).astype(
|
|
396
|
+
idx1 = np.floor(subindices).astype(int)
|
|
397
|
+
idx2 = np.floor(subindices + 1).astype(int)
|
|
401
398
|
idx2 = np.minimum(idx2, len(arr) - 1)
|
|
402
399
|
alpha = idx2 - subindices
|
|
403
400
|
subvalues = arr[idx1] * (alpha) + arr[idx2] * (1 - alpha)
|
|
@@ -469,7 +466,7 @@ def hist_argmaxima2(hist, maxima_thresh=.8):
|
|
|
469
466
|
# FIXME: Not handling general cases
|
|
470
467
|
# [0] index because argrelmaxima returns a tuple
|
|
471
468
|
if len(hist) == 0:
|
|
472
|
-
return np.empty(dtype=
|
|
469
|
+
return np.empty(dtype=int)
|
|
473
470
|
comperetor = np.greater
|
|
474
471
|
argmaxima_ = scipy.signal.argrelextrema(hist, comperetor)[0]
|
|
475
472
|
if len(argmaxima_) == 0:
|
|
@@ -978,8 +975,8 @@ def show_ori_image_ondisk():
|
|
|
978
975
|
>>> pt.show_if_requested()
|
|
979
976
|
"""
|
|
980
977
|
#if img_fpath is not None:
|
|
981
|
-
# img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('
|
|
982
|
-
# img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('
|
|
978
|
+
# img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('astro'))
|
|
979
|
+
# img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('astro'))
|
|
983
980
|
# img = vt.imread(img_fpath)
|
|
984
981
|
# ori_img_fpath = ut.get_argval('--fpath-ori', type_=str,
|
|
985
982
|
# default=ut.augpath(img_fpath, '_ori'))
|