machinevision-toolbox-python 0.9.4__tar.gz → 0.9.7__tar.gz
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.
- {machinevision-toolbox-python-0.9.4/machinevision_toolbox_python.egg-info → machinevision_toolbox_python-0.9.7}/PKG-INFO +33 -14
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/README.md +1 -3
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7/machinevision_toolbox_python.egg-info}/PKG-INFO +33 -14
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevision_toolbox_python.egg-info/SOURCES.txt +10 -5
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevision_toolbox_python.egg-info/requires.txt +8 -4
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/BagOfWords.py +51 -48
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/BundleAdjust.py +193 -172
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/Camera.py +551 -454
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageBlobs.py +151 -119
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageColor.py +93 -87
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageConstants.py +34 -27
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageCore.py +171 -138
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageIO.py +135 -73
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageLineFeatures.py +50 -42
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageMorph.py +101 -94
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageMultiview.py +52 -49
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImagePointFeatures.py +331 -209
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageProcessing.py +119 -111
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageRegionFeatures.py +90 -84
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageReshape.py +165 -112
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageSpatial.py +181 -170
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/ImageWholeFeatures.py +77 -66
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/PointCloud.py +43 -34
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/Sources.py +106 -76
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/VisualServo.py +326 -267
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/__init__.py +22 -5
- machinevision_toolbox_python-0.9.7/machinevisiontoolbox/base/__init__.py +69 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/color.py +246 -200
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/data.py +17 -13
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/esttheta.py +13 -9
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/findpeaks.py +40 -36
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/graphics.py +123 -68
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/imageio.py +235 -200
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/meshgrid.py +4 -2
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/shapes.py +59 -51
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/base/types.py +19 -10
- machinevision_toolbox_python-0.9.7/machinevisiontoolbox/blocks/__init__.py +3 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/blocks/camera.py +62 -54
- machinevision-toolbox-python-0.9.4/machinevisiontoolbox/blocks/aside_test_blocks.py → machinevision_toolbox_python-0.9.7/machinevisiontoolbox/blocks/test_blocks.py +3 -5
- machinevision_toolbox_python-0.9.7/machinevisiontoolbox/fiducial.py +46 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/newcameras.py +11 -6
- machinevision_toolbox_python-0.9.7/pyproject.toml +98 -0
- machinevision_toolbox_python-0.9.7/tests/test_base_color.py +98 -0
- machinevision_toolbox_python-0.9.7/tests/test_camera.py +188 -0
- machinevision_toolbox_python-0.9.7/tests/test_color.py +80 -0
- machinevision_toolbox_python-0.9.7/tests/test_core.py +522 -0
- machinevision_toolbox_python-0.9.7/tests/test_image_io.py +146 -0
- machinevision_toolbox_python-0.9.7/tests/test_imageprocessing_kernel.py +85 -0
- machinevision_toolbox_python-0.9.7/tests/test_imageprocessing_morph.py +257 -0
- machinevision_toolbox_python-0.9.7/tests/test_processing.py +342 -0
- machinevision-toolbox-python-0.9.4/RELEASE +0 -1
- machinevision-toolbox-python-0.9.4/machinevisiontoolbox/base/__init__.py +0 -76
- machinevision-toolbox-python-0.9.4/machinevisiontoolbox/base/io.py +0 -954
- machinevision-toolbox-python-0.9.4/machinevisiontoolbox/blocks/__init__.py +0 -3
- machinevision-toolbox-python-0.9.4/machinevisiontoolbox/blocks/tex2icon.py +0 -108
- machinevision-toolbox-python-0.9.4/machinevisiontoolbox/fiducial.py +0 -50
- machinevision-toolbox-python-0.9.4/setup.py +0 -77
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/LICENSE +0 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevision_toolbox_python.egg-info/dependency_links.txt +0 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevision_toolbox_python.egg-info/top_level.txt +0 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/machinevisiontoolbox/camera_derivatives.py +0 -0
- {machinevision-toolbox-python-0.9.4 → machinevision_toolbox_python-0.9.7}/setup.cfg +0 -0
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: machinevision-toolbox-python
|
|
3
|
-
Version: 0.9.
|
|
4
|
-
Summary:
|
|
5
|
-
|
|
6
|
-
Author: Peter Corke
|
|
7
|
-
|
|
3
|
+
Version: 0.9.7
|
|
4
|
+
Summary: Python tools for machine vision - education and research
|
|
5
|
+
Author: Dorian Tsai
|
|
6
|
+
Author-email: Peter Corke <rvc@petercorke.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/petercorke/machinevision-toolbox-python
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues
|
|
8
9
|
Project-URL: Documentation, https://petercorke.github.io/machinevision-toolbox-python
|
|
9
10
|
Project-URL: Source, https://github.com/petercorke/machinevision-toolbox-python
|
|
10
|
-
|
|
11
|
-
Project-URL: Coverage, https://codecov.io/gh/petercorke/machinevision-toolbox-python
|
|
12
|
-
Keywords: python machine-vision computer-vision multiview-geometry features color blobs
|
|
11
|
+
Keywords: machine vision,computer vision,multiview geometry,stereo vision,bundle adjustment,visual servoing,image features,color,blobs,morphology,image segmentation,opencv,open3d
|
|
13
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
14
13
|
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.7
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
20
21
|
Requires-Python: >=3.7
|
|
21
22
|
Description-Content-Type: text/markdown
|
|
22
|
-
Provides-Extra: docs
|
|
23
|
-
Provides-Extra: dev
|
|
24
23
|
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.17.4
|
|
25
|
+
Requires-Dist: scipy
|
|
26
|
+
Requires-Dist: matplotlib
|
|
27
|
+
Requires-Dist: opencv-python
|
|
28
|
+
Requires-Dist: open3d
|
|
29
|
+
Requires-Dist: opencv-contrib-python
|
|
30
|
+
Requires-Dist: spatialmath-python
|
|
31
|
+
Requires-Dist: pgraph-python
|
|
32
|
+
Requires-Dist: ansitable
|
|
33
|
+
Requires-Dist: mvtb-data
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: coverage; extra == "dev"
|
|
37
|
+
Requires-Dist: flake8; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
40
|
+
Requires-Dist: recommonmark; extra == "docs"
|
|
41
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinx-autorun; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinxcontrib-jsmath; extra == "docs"
|
|
44
|
+
Requires-Dist: sphinx-markdown-tables; extra == "docs"
|
|
45
|
+
Requires-Dist: sphinx-favicon; extra == "docs"
|
|
25
46
|
|
|
26
47
|
# Machine Vision Toolbox for Python
|
|
27
48
|
|
|
@@ -35,9 +56,8 @@ License-File: LICENSE
|
|
|
35
56
|
[](https://open3d.org)
|
|
36
57
|
[](https://opensource.org/licenses/MIT)
|
|
37
58
|
|
|
38
|
-
[](https://github.com/petercorke/machinevision-toolbox-python/actions?query=workflow%3Abuild)
|
|
39
60
|
[](https://codecov.io/gh/petercorke/machinevision-toolbox-python)
|
|
40
|
-
[](https://lgtm.com/projects/g/petercorke/machinevision-toolbox-python/context:python)
|
|
41
61
|
[](https://pypistats.org/packages/machinevision-toolbox-python)
|
|
42
62
|
|
|
43
63
|
<!-- [](https://GitHub.com/petercorke/machinevision-toolbox-python/stargazers/) -->
|
|
@@ -107,7 +127,6 @@ Install the current code base from GitHub and pip install a link to that cloned
|
|
|
107
127
|
from machinevisiontoolbox import Image
|
|
108
128
|
mona = Image.Read("monalisa.png")
|
|
109
129
|
mona.disp()
|
|
110
|
-
mona.smooth(sigma=5).disp()
|
|
111
130
|
```
|
|
112
131
|
|
|
113
132
|

|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
[](https://open3d.org)
|
|
11
11
|
[](https://opensource.org/licenses/MIT)
|
|
12
12
|
|
|
13
|
-
[](https://github.com/petercorke/machinevision-toolbox-python/actions?query=workflow%3Abuild)
|
|
14
14
|
[](https://codecov.io/gh/petercorke/machinevision-toolbox-python)
|
|
15
|
-
[](https://lgtm.com/projects/g/petercorke/machinevision-toolbox-python/context:python)
|
|
16
15
|
[](https://pypistats.org/packages/machinevision-toolbox-python)
|
|
17
16
|
|
|
18
17
|
<!-- [](https://GitHub.com/petercorke/machinevision-toolbox-python/stargazers/) -->
|
|
@@ -82,7 +81,6 @@ Install the current code base from GitHub and pip install a link to that cloned
|
|
|
82
81
|
from machinevisiontoolbox import Image
|
|
83
82
|
mona = Image.Read("monalisa.png")
|
|
84
83
|
mona.disp()
|
|
85
|
-
mona.smooth(sigma=5).disp()
|
|
86
84
|
```
|
|
87
85
|
|
|
88
86
|

|
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: machinevision-toolbox-python
|
|
3
|
-
Version: 0.9.
|
|
4
|
-
Summary:
|
|
5
|
-
|
|
6
|
-
Author: Peter Corke
|
|
7
|
-
|
|
3
|
+
Version: 0.9.7
|
|
4
|
+
Summary: Python tools for machine vision - education and research
|
|
5
|
+
Author: Dorian Tsai
|
|
6
|
+
Author-email: Peter Corke <rvc@petercorke.com>
|
|
7
|
+
Project-URL: Homepage, https://github.com/petercorke/machinevision-toolbox-python
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/pypa/sampleproject/issues
|
|
8
9
|
Project-URL: Documentation, https://petercorke.github.io/machinevision-toolbox-python
|
|
9
10
|
Project-URL: Source, https://github.com/petercorke/machinevision-toolbox-python
|
|
10
|
-
|
|
11
|
-
Project-URL: Coverage, https://codecov.io/gh/petercorke/machinevision-toolbox-python
|
|
12
|
-
Keywords: python machine-vision computer-vision multiview-geometry features color blobs
|
|
11
|
+
Keywords: machine vision,computer vision,multiview geometry,stereo vision,bundle adjustment,visual servoing,image features,color,blobs,morphology,image segmentation,opencv,open3d
|
|
13
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
14
13
|
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.7
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
20
21
|
Requires-Python: >=3.7
|
|
21
22
|
Description-Content-Type: text/markdown
|
|
22
|
-
Provides-Extra: docs
|
|
23
|
-
Provides-Extra: dev
|
|
24
23
|
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy>=1.17.4
|
|
25
|
+
Requires-Dist: scipy
|
|
26
|
+
Requires-Dist: matplotlib
|
|
27
|
+
Requires-Dist: opencv-python
|
|
28
|
+
Requires-Dist: open3d
|
|
29
|
+
Requires-Dist: opencv-contrib-python
|
|
30
|
+
Requires-Dist: spatialmath-python
|
|
31
|
+
Requires-Dist: pgraph-python
|
|
32
|
+
Requires-Dist: ansitable
|
|
33
|
+
Requires-Dist: mvtb-data
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: coverage; extra == "dev"
|
|
37
|
+
Requires-Dist: flake8; extra == "dev"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
40
|
+
Requires-Dist: recommonmark; extra == "docs"
|
|
41
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinx-autorun; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinxcontrib-jsmath; extra == "docs"
|
|
44
|
+
Requires-Dist: sphinx-markdown-tables; extra == "docs"
|
|
45
|
+
Requires-Dist: sphinx-favicon; extra == "docs"
|
|
25
46
|
|
|
26
47
|
# Machine Vision Toolbox for Python
|
|
27
48
|
|
|
@@ -35,9 +56,8 @@ License-File: LICENSE
|
|
|
35
56
|
[](https://open3d.org)
|
|
36
57
|
[](https://opensource.org/licenses/MIT)
|
|
37
58
|
|
|
38
|
-
[](https://github.com/petercorke/machinevision-toolbox-python/actions?query=workflow%3Abuild)
|
|
39
60
|
[](https://codecov.io/gh/petercorke/machinevision-toolbox-python)
|
|
40
|
-
[](https://lgtm.com/projects/g/petercorke/machinevision-toolbox-python/context:python)
|
|
41
61
|
[](https://pypistats.org/packages/machinevision-toolbox-python)
|
|
42
62
|
|
|
43
63
|
<!-- [](https://GitHub.com/petercorke/machinevision-toolbox-python/stargazers/) -->
|
|
@@ -107,7 +127,6 @@ Install the current code base from GitHub and pip install a link to that cloned
|
|
|
107
127
|
from machinevisiontoolbox import Image
|
|
108
128
|
mona = Image.Read("monalisa.png")
|
|
109
129
|
mona.disp()
|
|
110
|
-
mona.smooth(sigma=5).disp()
|
|
111
130
|
```
|
|
112
131
|
|
|
113
132
|

|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
|
-
|
|
4
|
-
setup.py
|
|
3
|
+
pyproject.toml
|
|
5
4
|
machinevision_toolbox_python.egg-info/PKG-INFO
|
|
6
5
|
machinevision_toolbox_python.egg-info/SOURCES.txt
|
|
7
6
|
machinevision_toolbox_python.egg-info/dependency_links.txt
|
|
@@ -38,11 +37,17 @@ machinevisiontoolbox/base/esttheta.py
|
|
|
38
37
|
machinevisiontoolbox/base/findpeaks.py
|
|
39
38
|
machinevisiontoolbox/base/graphics.py
|
|
40
39
|
machinevisiontoolbox/base/imageio.py
|
|
41
|
-
machinevisiontoolbox/base/io.py
|
|
42
40
|
machinevisiontoolbox/base/meshgrid.py
|
|
43
41
|
machinevisiontoolbox/base/shapes.py
|
|
44
42
|
machinevisiontoolbox/base/types.py
|
|
45
43
|
machinevisiontoolbox/blocks/__init__.py
|
|
46
|
-
machinevisiontoolbox/blocks/aside_test_blocks.py
|
|
47
44
|
machinevisiontoolbox/blocks/camera.py
|
|
48
|
-
machinevisiontoolbox/blocks/
|
|
45
|
+
machinevisiontoolbox/blocks/test_blocks.py
|
|
46
|
+
tests/test_base_color.py
|
|
47
|
+
tests/test_camera.py
|
|
48
|
+
tests/test_color.py
|
|
49
|
+
tests/test_core.py
|
|
50
|
+
tests/test_image_io.py
|
|
51
|
+
tests/test_imageprocessing_kernel.py
|
|
52
|
+
tests/test_imageprocessing_morph.py
|
|
53
|
+
tests/test_processing.py
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
numpy
|
|
1
|
+
numpy>=1.17.4
|
|
2
2
|
scipy
|
|
3
3
|
matplotlib
|
|
4
4
|
opencv-python
|
|
5
|
+
open3d
|
|
5
6
|
opencv-contrib-python
|
|
6
7
|
spatialmath-python
|
|
7
8
|
pgraph-python
|
|
@@ -10,11 +11,14 @@ mvtb-data
|
|
|
10
11
|
|
|
11
12
|
[dev]
|
|
12
13
|
pytest
|
|
13
|
-
|
|
14
|
+
coverage
|
|
14
15
|
flake8
|
|
15
|
-
pyyaml
|
|
16
16
|
|
|
17
17
|
[docs]
|
|
18
18
|
sphinx
|
|
19
|
-
|
|
19
|
+
recommonmark
|
|
20
|
+
sphinx-rtd-theme
|
|
20
21
|
sphinx-autorun
|
|
22
|
+
sphinxcontrib-jsmath
|
|
23
|
+
sphinx-markdown-tables
|
|
24
|
+
sphinx-favicon
|
|
@@ -7,7 +7,6 @@ import cv2 as cv
|
|
|
7
7
|
|
|
8
8
|
# TODO: remove top N% and bottom M% of words by frequency
|
|
9
9
|
class BagOfWords:
|
|
10
|
-
|
|
11
10
|
def __init__(self, images, k=2_000, nstopwords=0, attempts=1, seed=None):
|
|
12
11
|
r"""
|
|
13
12
|
Bag of words class
|
|
@@ -22,8 +21,8 @@ class BagOfWords:
|
|
|
22
21
|
:type attempts: int, optional
|
|
23
22
|
|
|
24
23
|
Bag of words is a powerful feature-based method for matching images
|
|
25
|
-
from widely different viewpoints.
|
|
26
|
-
|
|
24
|
+
from widely different viewpoints.
|
|
25
|
+
|
|
27
26
|
This class creates a bag of words from a sequence of images or a set of
|
|
28
27
|
point features. In the former case, the features will have an ``.id``
|
|
29
28
|
equal to the index of the image in the sequence. For the latter case,
|
|
@@ -45,12 +44,12 @@ class BagOfWords:
|
|
|
45
44
|
of image features is assigned labels from the ``.centroids`` any with a
|
|
46
45
|
label greater that ``.nstopwords`` is a stop word and can be discarded.
|
|
47
46
|
|
|
48
|
-
:reference:
|
|
47
|
+
:reference:
|
|
49
48
|
- Video Google: a text retrieval approach to object matching in videos
|
|
50
|
-
J.Sivic and A.Zisserman,
|
|
51
|
-
in Proc. Ninth IEEE Int. Conf. on Computer Vision,
|
|
49
|
+
J.Sivic and A.Zisserman,
|
|
50
|
+
in Proc. Ninth IEEE Int. Conf. on Computer Vision,
|
|
52
51
|
pp.1470-1477, Oct. 2003.
|
|
53
|
-
- Robotics, Vision & Control for Python, Section 12.4.2,
|
|
52
|
+
- Robotics, Vision & Control for Python, Section 12.4.2,
|
|
54
53
|
P. Corke, Springer 2023.
|
|
55
54
|
|
|
56
55
|
:seealso: :meth:`recall` :meth:`~machinevisiontoolbox.ImagePointFeatures.BaseFeature2D`
|
|
@@ -73,7 +72,7 @@ class BagOfWords:
|
|
|
73
72
|
|
|
74
73
|
self._images = images
|
|
75
74
|
|
|
76
|
-
# save the image id's
|
|
75
|
+
# save the image id's
|
|
77
76
|
self._image_id = np.r_[features.id]
|
|
78
77
|
self._nimages = self._image_id.max() + 1
|
|
79
78
|
self._features = features
|
|
@@ -87,12 +86,13 @@ class BagOfWords:
|
|
|
87
86
|
cv.setRNGSeed(seed)
|
|
88
87
|
|
|
89
88
|
ret, labels, centroids = cv.kmeans(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
data=features._descriptor,
|
|
90
|
+
K=k,
|
|
91
|
+
bestLabels=None,
|
|
92
|
+
criteria=criteria,
|
|
93
|
+
attempts=attempts,
|
|
94
|
+
flags=cv.KMEANS_RANDOM_CENTERS,
|
|
95
|
+
)
|
|
96
96
|
|
|
97
97
|
self._k = k
|
|
98
98
|
|
|
@@ -128,7 +128,7 @@ class BagOfWords:
|
|
|
128
128
|
idf = np.log(N / ni)
|
|
129
129
|
|
|
130
130
|
M = []
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
for i in range(self.nimages):
|
|
133
133
|
# number of words in this image
|
|
134
134
|
nd = W[:, i].sum()
|
|
@@ -136,13 +136,13 @@ class BagOfWords:
|
|
|
136
136
|
# word occurrence frequency
|
|
137
137
|
nid = W[:, i]
|
|
138
138
|
|
|
139
|
-
with np.errstate(divide=
|
|
139
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
140
140
|
v = nid / nd * idf
|
|
141
141
|
|
|
142
142
|
v[~np.isfinite(v)] = 0
|
|
143
143
|
M.append(v)
|
|
144
144
|
|
|
145
|
-
self._word_freq_vectors =
|
|
145
|
+
self._word_freq_vectors = np.column_stack(M)
|
|
146
146
|
self._idf = idf
|
|
147
147
|
|
|
148
148
|
def wwfv(self, i=None):
|
|
@@ -298,7 +298,7 @@ class BagOfWords:
|
|
|
298
298
|
return s
|
|
299
299
|
|
|
300
300
|
def _remove_stopwords(self, verbose=True):
|
|
301
|
-
#BagOfWords.remove_stop Remove stop words
|
|
301
|
+
# BagOfWords.remove_stop Remove stop words
|
|
302
302
|
#
|
|
303
303
|
# B.remove_stop(N) removes the N most frequent words (the stop words)
|
|
304
304
|
# from the self. All remaining words are renumbered so that the word
|
|
@@ -314,10 +314,12 @@ class BagOfWords:
|
|
|
314
314
|
|
|
315
315
|
# unique_words will be [0,k)
|
|
316
316
|
index = np.argsort(-freq) # sort descending order
|
|
317
|
-
stopwords = unique_words[index[:self.nstopwords]] # array of stop words
|
|
317
|
+
stopwords = unique_words[index[: self.nstopwords]] # array of stop words
|
|
318
318
|
|
|
319
319
|
stopfeatures = freq[stopwords].sum()
|
|
320
|
-
print(
|
|
320
|
+
print(
|
|
321
|
+
f"Removing {stopfeatures} features ({stopfeatures/len(self.words) * 100:.1f}%) associated with {self.nstopwords} most frequent words"
|
|
322
|
+
)
|
|
321
323
|
|
|
322
324
|
k = np.full(index.shape, False, dtype=bool)
|
|
323
325
|
k[stopwords] = True
|
|
@@ -334,7 +336,7 @@ class BagOfWords:
|
|
|
334
336
|
words = np.array([mapdict[w] for w in self.words])
|
|
335
337
|
|
|
336
338
|
self._labels = words
|
|
337
|
-
|
|
339
|
+
|
|
338
340
|
# only retain the non stop words
|
|
339
341
|
keep = words < self.nstopwords
|
|
340
342
|
self._words = words[keep]
|
|
@@ -353,7 +355,7 @@ class BagOfWords:
|
|
|
353
355
|
:return: confusion matrix
|
|
354
356
|
:rtype: ndarray(M,N)
|
|
355
357
|
|
|
356
|
-
The array has rows corresponding to the images in ``self`` and
|
|
358
|
+
The array has rows corresponding to the images in ``self`` and
|
|
357
359
|
columns corresponding to the images in ``other``.
|
|
358
360
|
|
|
359
361
|
:seealso: :meth:`.closest`
|
|
@@ -361,16 +363,18 @@ class BagOfWords:
|
|
|
361
363
|
if isinstance(arg, np.ndarray):
|
|
362
364
|
wwfv = arg
|
|
363
365
|
sim = np.empty((wwfv.shape[1], self.nimages))
|
|
364
|
-
|
|
366
|
+
|
|
365
367
|
for j, vj in enumerate(wwfv.T):
|
|
366
368
|
for i in range(self.nimages):
|
|
367
369
|
vi = self.wwfv(i)
|
|
368
370
|
|
|
369
|
-
with np.errstate(divide=
|
|
370
|
-
sim[j, i] = np.dot(vi.ravel(), vj) / (
|
|
371
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
372
|
+
sim[j, i] = np.dot(vi.ravel(), vj) / (
|
|
373
|
+
np.linalg.norm(vi) * np.linalg.norm(vj)
|
|
374
|
+
)
|
|
371
375
|
else:
|
|
372
376
|
images = arg
|
|
373
|
-
if not hasattr(images,
|
|
377
|
+
if not hasattr(images, "__iter__"):
|
|
374
378
|
# if not iterable like a FileCollection or VideoFile turn the image
|
|
375
379
|
# into a list of 1
|
|
376
380
|
images = [images]
|
|
@@ -378,7 +382,7 @@ class BagOfWords:
|
|
|
378
382
|
# similarity has bag index as column, query index as row
|
|
379
383
|
sim = np.empty((len(images), self.nimages))
|
|
380
384
|
for j, image in enumerate(images):
|
|
381
|
-
features = image.SIFT(id=
|
|
385
|
+
features = image.SIFT(id="image")
|
|
382
386
|
|
|
383
387
|
# assign features to given cluster centroids
|
|
384
388
|
# the elements of matches are:
|
|
@@ -393,11 +397,11 @@ class BagOfWords:
|
|
|
393
397
|
|
|
394
398
|
# word occurrence frequency
|
|
395
399
|
nid = BagOfWords._word_freq_vector(words, self.k - self.nstopwords)
|
|
396
|
-
|
|
400
|
+
|
|
397
401
|
# number of words in this image
|
|
398
402
|
nd = nid.sum()
|
|
399
403
|
|
|
400
|
-
with np.errstate(divide=
|
|
404
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
401
405
|
v2 = nid / nd * self._idf
|
|
402
406
|
|
|
403
407
|
v2[~np.isfinite(v2)] = 0
|
|
@@ -405,9 +409,11 @@ class BagOfWords:
|
|
|
405
409
|
for i in range(self.nimages):
|
|
406
410
|
v1 = self.wwfv(i).ravel()
|
|
407
411
|
|
|
408
|
-
with np.errstate(divide=
|
|
409
|
-
sim[j, i] = np.dot(v1, v2) / (
|
|
410
|
-
|
|
412
|
+
with np.errstate(divide="ignore", invalid="ignore"):
|
|
413
|
+
sim[j, i] = np.dot(v1, v2) / (
|
|
414
|
+
np.linalg.norm(v1) * np.linalg.norm(v2)
|
|
415
|
+
)
|
|
416
|
+
|
|
411
417
|
if sim.shape[0] == 1:
|
|
412
418
|
sim = sim[0, :]
|
|
413
419
|
return sim
|
|
@@ -464,7 +470,7 @@ class BagOfWords:
|
|
|
464
470
|
the frequency of the corresponding word across all images.
|
|
465
471
|
"""
|
|
466
472
|
|
|
467
|
-
#BagOfWords.wordfreq Word frequency statistics
|
|
473
|
+
# BagOfWords.wordfreq Word frequency statistics
|
|
468
474
|
#
|
|
469
475
|
# [W,N] = B.wordfreq[] is a vector of word labels W and the corresponding
|
|
470
476
|
# elements of N are the number of occurrences of that word.
|
|
@@ -485,7 +491,7 @@ class BagOfWords:
|
|
|
485
491
|
"""
|
|
486
492
|
s = S[:, i]
|
|
487
493
|
index = np.argsort(-s)
|
|
488
|
-
|
|
494
|
+
|
|
489
495
|
return index, s[index]
|
|
490
496
|
|
|
491
497
|
def contains(self, word):
|
|
@@ -500,15 +506,16 @@ class BagOfWords:
|
|
|
500
506
|
:seealso: :meth:`exemplars`
|
|
501
507
|
"""
|
|
502
508
|
return np.unique(self._image_id[self.words == word])
|
|
503
|
-
|
|
504
509
|
|
|
505
|
-
def exemplars(
|
|
510
|
+
def exemplars(
|
|
511
|
+
self, word, images=None, maxperimage=2, columns=10, max=None, width=50, **kwargs
|
|
512
|
+
):
|
|
506
513
|
"""
|
|
507
514
|
Composite image containing exemplars of specified word
|
|
508
515
|
|
|
509
516
|
:param word: visual word label
|
|
510
517
|
:type word: int
|
|
511
|
-
:param images: the set of images corresponding to this bag, only
|
|
518
|
+
:param images: the set of images corresponding to this bag, only
|
|
512
519
|
required if the bag was constructed from features not images.
|
|
513
520
|
:param maxperimage: maximum number of exemplars drawn from any one image, defaults to 2
|
|
514
521
|
:type maxperimage: int, optional
|
|
@@ -523,8 +530,8 @@ class BagOfWords:
|
|
|
523
530
|
|
|
524
531
|
Produces a grid of examples of a particular visual word.
|
|
525
532
|
|
|
526
|
-
:seealso: :meth:`contains`
|
|
527
|
-
:meth:`~machinevisiontoolbox.ImagePointFeatures.BaseFeature2D.support`
|
|
533
|
+
:seealso: :meth:`contains`
|
|
534
|
+
:meth:`~machinevisiontoolbox.ImagePointFeatures.BaseFeature2D.support`
|
|
528
535
|
:meth:`~machinevisiontoolbox.Image.Tile`
|
|
529
536
|
"""
|
|
530
537
|
from machinevisiontoolbox import Image
|
|
@@ -545,6 +552,7 @@ class BagOfWords:
|
|
|
545
552
|
|
|
546
553
|
return Image.Tile(exemplars, columns=columns, **kwargs)
|
|
547
554
|
|
|
555
|
+
|
|
548
556
|
if __name__ == "__main__":
|
|
549
557
|
|
|
550
558
|
import numpy as np
|
|
@@ -554,7 +562,7 @@ if __name__ == "__main__":
|
|
|
554
562
|
|
|
555
563
|
cv.setRNGSeed(0)
|
|
556
564
|
|
|
557
|
-
images = ImageCollection(
|
|
565
|
+
images = ImageCollection("campus/*.png", mono=True)
|
|
558
566
|
|
|
559
567
|
features = []
|
|
560
568
|
for image in images:
|
|
@@ -570,7 +578,6 @@ if __name__ == "__main__":
|
|
|
570
578
|
|
|
571
579
|
Image.Tile(ex, columns=20).disp(plain=True)
|
|
572
580
|
|
|
573
|
-
|
|
574
581
|
feature = features[108]
|
|
575
582
|
print(feature)
|
|
576
583
|
|
|
@@ -600,7 +607,7 @@ if __name__ == "__main__":
|
|
|
600
607
|
|
|
601
608
|
sim_8 = bag.similarity(images[8]).ravel()
|
|
602
609
|
print(sim_8)
|
|
603
|
-
k = np.argsort(-sim_8)
|
|
610
|
+
k = np.argsort(-sim_8)
|
|
604
611
|
print(np.c_[sim_8[k], k])
|
|
605
612
|
|
|
606
613
|
ss = []
|
|
@@ -608,13 +615,13 @@ if __name__ == "__main__":
|
|
|
608
615
|
ss.append(images[k[i]])
|
|
609
616
|
Image.Tile(ss, columns=2).disp()
|
|
610
617
|
|
|
611
|
-
holdout = ImageCollection("campus/holdout/*.png", mono=True)
|
|
618
|
+
holdout = ImageCollection("campus/holdout/*.png", mono=True)
|
|
612
619
|
|
|
613
620
|
sim = bag.similarity(holdout)
|
|
614
621
|
|
|
615
622
|
sim_2 = bag.similarity(holdout[2]).ravel()
|
|
616
623
|
print(sim_2)
|
|
617
|
-
k = np.argsort(-sim_2)
|
|
624
|
+
k = np.argsort(-sim_2)
|
|
618
625
|
print(np.c_[sim_2[k], k])
|
|
619
626
|
|
|
620
627
|
ss = [holdout[2]]
|
|
@@ -623,7 +630,3 @@ if __name__ == "__main__":
|
|
|
623
630
|
Image.Tile(ss, columns=2).disp()
|
|
624
631
|
|
|
625
632
|
Image(sim).disp(block=True)
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|