machinevision-toolbox-python 2.0.1__py3-none-any.whl → 2.2.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.
Files changed (34) hide show
  1. {machinevision_toolbox_python-2.0.1.dist-info → machinevision_toolbox_python-2.2.0.dist-info}/METADATA +13 -5
  2. {machinevision_toolbox_python-2.0.1.dist-info → machinevision_toolbox_python-2.2.0.dist-info}/RECORD +23 -33
  3. {machinevision_toolbox_python-2.0.1.dist-info → machinevision_toolbox_python-2.2.0.dist-info}/WHEEL +1 -1
  4. machinevisiontoolbox/BundleAdjust.py +1 -1
  5. machinevisiontoolbox/Camera.py +95 -80
  6. machinevisiontoolbox/ImageBlobs.py +10 -4
  7. machinevisiontoolbox/ImageCore.py +105 -97
  8. machinevisiontoolbox/ImageFiducials.py +62 -10
  9. machinevisiontoolbox/ImageIO.py +5 -1
  10. machinevisiontoolbox/ImageLineFeatures.py +9 -1
  11. machinevisiontoolbox/ImagePointFeatures.py +29 -8
  12. machinevisiontoolbox/ImageProcessing.py +1 -1
  13. machinevisiontoolbox/ImageRegionFeatures.py +25 -6
  14. machinevisiontoolbox/ImageWholeFeatures.py +113 -72
  15. machinevisiontoolbox/Sources.py +1 -1
  16. machinevisiontoolbox/__init__.py +1 -1
  17. machinevisiontoolbox/base/imageio.py +68 -33
  18. machinevisiontoolbox/bin/_iminteractive.py +461 -0
  19. machinevisiontoolbox/bin/bagtool.py +120 -6
  20. machinevisiontoolbox/bin/imtool.py +34 -5
  21. machinevisiontoolbox/bin/mvtbtool.py +93 -18
  22. machinevisiontoolbox/ImageCore.docstring +0 -2877
  23. machinevisiontoolbox/aruco0.pdf +0 -0
  24. machinevisiontoolbox/aruco50.pdf +0 -0
  25. machinevisiontoolbox/bin/labeltool.py +0 -147
  26. machinevisiontoolbox/blocks/Icons/icons.sh +0 -4
  27. machinevisiontoolbox/cvfuncs.py +0 -40
  28. machinevisiontoolbox/docbugs.py +0 -47
  29. machinevisiontoolbox/newcameras.py +0 -55
  30. machinevisiontoolbox/test_skimage.py +0 -12
  31. machinevisiontoolbox/testblobplots.py +0 -17
  32. machinevisiontoolbox/x.json +0 -296
  33. {machinevision_toolbox_python-2.0.1.dist-info → machinevision_toolbox_python-2.2.0.dist-info}/entry_points.txt +0 -0
  34. {machinevision_toolbox_python-2.0.1.dist-info → machinevision_toolbox_python-2.2.0.dist-info}/licenses/LICENSE +0 -0
Binary file
Binary file
@@ -1,147 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Command-line tool to display and label images using the Machine Vision Toolbox.
4
-
5
- Usage::
6
-
7
- $ labeltool street.png
8
- """
9
-
10
- import argparse
11
-
12
- from colored import Fore, Style
13
-
14
- from machinevisiontoolbox import * # lgtm [py/unused-import]
15
- from machinevisiontoolbox.bin._bintools import (
16
- LineWrapRawTextDefaultsHelpFormatter,
17
- MVTB_LINK,
18
- )
19
-
20
-
21
- def getargs():
22
- parser = argparse.ArgumentParser(
23
- formatter_class=LineWrapRawTextDefaultsHelpFormatter,
24
- description=f"Display an image using {MVTB_LINK}",
25
- )
26
- parser.add_argument(
27
- "files",
28
- nargs="+",
29
- help="list of image files to view, files can also include those distributed with machinevision toolbox, eg. 'monalisa.png'",
30
- )
31
- parser.add_argument(
32
- "--block",
33
- "-b",
34
- action="store_true",
35
- default=False,
36
- help="block after each image",
37
- )
38
- # -m show metadata
39
- parser.add_argument("--metadata", "-m", help="Show metadata", action="store_true")
40
- # -p pick points
41
- parser.add_argument("--points", "-p", help="Pick points", action="store_true")
42
- # csv output for pick points
43
- parser.add_argument(
44
- "--csv", "-c", help="Output picked points as CSV", action="store_true"
45
- )
46
- # -g show grid
47
- parser.add_argument("--grid", "-g", help="Show grid", action="store_true")
48
- # -v verbose show image details
49
- parser.add_argument(
50
- "--verbose", "-v", help="Show image details", action="store_true"
51
- )
52
-
53
- return parser.parse_args()
54
-
55
-
56
- def visualize_image(image, args, block):
57
- if args.verbose:
58
- print(image)
59
-
60
- if args.metadata:
61
- md = image.metadata()
62
- table = ANSITable(
63
- Column("key", width=20),
64
- Column("value", width=58, headalign="<", colalign="<"),
65
- )
66
-
67
- # sort the metadata by key
68
- if md is not None:
69
- for key in sorted(md.keys()):
70
- table.row(key, md[key])
71
- table.print()
72
-
73
- ## pick points and display coordinates as well as delta between points, in an ANSITable
74
- if args.points:
75
- image.disp(block=False, grid=args.grid)
76
- print(
77
- f"""\
78
- {Fore.yellow}Click on points in the image (first click might just select the window and get lost)
79
- * left click to add a point
80
- * right click to remove point
81
- * CR when done
82
- * you can zoom in using the magnifier button at bottom{Style.reset}
83
- """
84
- )
85
- points = plt.gcf().ginput(n=-1, timeout=0)
86
-
87
- if args.csv:
88
- print("u,v")
89
- for p in points:
90
- print(f"{p[0]},{p[1]}")
91
- return
92
- else:
93
- # define the table
94
- fmt = "{:.1f}"
95
- table = ANSITable(
96
- Column("u", headalign="^", colalign="<", fmt=fmt),
97
- Column("v", headalign="^", colalign="<", fmt=fmt),
98
- Column("Δu", headalign="^", colalign="<"),
99
- Column("Δv", headalign="^", colalign="<"),
100
- Column("|Δ|", headalign="^", colalign="<"),
101
- )
102
-
103
- # add rows, first row is just the point, subsequent rows have deltas
104
- for i, p in enumerate(points):
105
- if i == 0:
106
- u0, v0 = p
107
- table.row(u0, v0, "", "", "")
108
- else:
109
- u1, v1 = p
110
- du, dv = u1 - u0, v1 - v0
111
- u0, v0 = u1, v1
112
- table.row(
113
- u1,
114
- v1,
115
- fmt.format(du),
116
- fmt.format(dv),
117
- fmt.format((du**2 + dv**2) ** 0.5),
118
- )
119
- table.print()
120
- else:
121
- image.disp(block=block, grid=args.grid)
122
-
123
-
124
- def main():
125
- args = getargs()
126
-
127
- if len(args.files) > 10:
128
- args.block = True
129
-
130
- for i, file in enumerate(args.files):
131
- try:
132
- img = Image.Read(file)
133
-
134
- if i == len(args.files) - 1:
135
- # last one
136
- block = True
137
- else:
138
- block = args.block
139
-
140
- visualize_image(img, args, block)
141
-
142
- except ValueError:
143
- print(f"File {file} not found")
144
-
145
-
146
- if __name__ == "__main__":
147
- main()
@@ -1,4 +0,0 @@
1
- #! /bin/bash
2
-
3
- bdtex2icon -r 320 -o visjac_p.png -t '\mat{J}_p'
4
- bdtex2icon -r 110 -o estpose_p.png -t '\pose(p, P)'
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env python3
2
- import re
3
- import sys
4
- import argparse
5
- from collections import Counter
6
-
7
- # python cvfuncs.py *py | grep -v \# | cut -d, -f 1 | uniq | wc -l
8
-
9
- def main():
10
- parser = argparse.ArgumentParser(description="Audit unique OpenCV calls and counts.")
11
- parser.add_argument("files", nargs="+", help="Files to scan")
12
- args = parser.parse_args()
13
-
14
- # Regex to capture the cv2.function_name
15
- pattern = re.compile(r'(cv\.[a-zA-Z0-9_]+)\(')
16
-
17
- for filename in args.files:
18
- try:
19
- with open(filename, 'r', encoding='utf-8') as f:
20
- content = f.read()
21
-
22
- # Extract all matches and count them
23
- found_calls = pattern.findall(content)
24
-
25
- if found_calls:
26
- counts = Counter(found_calls)
27
- print(f"# {filename}")
28
-
29
- # Sort alphabetically for a clean report
30
- for call in sorted(counts.keys()):
31
- n = counts[call]
32
- # suffix = f" x {n}" if n > 1 else ""
33
- suffix = f",{n}"
34
- print(f" {call}{suffix}")
35
-
36
- except Exception as e:
37
- print(f"Error reading {filename}: {e}", file=sys.stderr)
38
-
39
- if __name__ == "__main__":
40
- main()
@@ -1,47 +0,0 @@
1
- from machinevisiontoolbox import *
2
-
3
- # showpixels example
4
- # img = Image.Random(size=10)
5
- # window = img.showpixels(windowsize=1) # with 3x3 window
6
- # window.move(2, 3) # position window at (2,3)
7
- # window.move(4, 5, color="blue", alpha=0.7)
8
-
9
- # samesize example
10
- # from machinevisiontoolbox import Image
11
-
12
- # foreground = Image.Read("greenscreen.png", dtype="float")
13
- # foreground
14
- # background = Image.Read("road.png", dtype="float")
15
- # background
16
- # background.samesize(foreground)
17
-
18
- # stdisp example
19
- # from machinevisiontoolbox import Image
20
-
21
- # left = Image.Read("rocks2-l.png", reduce=2)
22
- # right = Image.Read("rocks2-r.png", reduce=2)
23
- # left.stdisp(right, interactive=False)
24
-
25
-
26
- from machinevisiontoolbox import Image
27
- import numpy as np
28
- from spatialmath import SE2
29
-
30
- img = Image.Read("monalisa.png")
31
- M = np.diag([0.25, 0.25, 1]) * SE2(100, 200) # scale and translate
32
- M
33
- out = img.warp_affine(M, bgcolor=np.nan) # unmapped pixels are NaNs
34
- out.disp(badcolor="r") # display warped image with NaNs as red
35
-
36
- from machinevisiontoolbox import Image
37
- import numpy as np
38
- from spatialmath import SE2
39
-
40
- img = Image.Read("monalisa.png")
41
- out = Image.Constant(0, size=(1000, 200))
42
- for i in range(10):
43
- M = (
44
- SE2(90 * (i + 1), 100) * SE2(i * np.pi * 2 / 15) * np.diag([0.1, 0.1, 1])
45
- ) # scale, rotate, translate
46
- img.warp_affine(M, dst=out)
47
- out.disp()
@@ -1,55 +0,0 @@
1
- from math import pi
2
-
3
- import numpy as np
4
- import scipy as sp
5
- from spatialmath import SE3
6
- from spatialmath.base import e2h, h2e, plot_sphere
7
-
8
- from machinevisiontoolbox import *
9
-
10
- u0 = 528.1214
11
- v0 = 384.0784
12
- l = 2.7899
13
- m = 996.4617
14
-
15
- im_fisheye = Image("fisheye_target.png", dtype="float", grey=True)
16
- im_fisheye.disp()
17
-
18
-
19
- n = 500
20
- theta_range = np.linspace(0, pi, n)
21
- phi_range = np.linspace(-pi, pi, n)
22
-
23
- Phi, Theta = np.meshgrid(phi_range, theta_range)
24
-
25
- r = (l + m) * np.sin(Theta) / (l - np.cos(Theta))
26
- Us = r * np.cos(Phi) + u0
27
- Vs = r * np.sin(Phi) + v0
28
-
29
- im_spherical = im_fisheye.interp2d(Us, Vs)
30
- # im_spherical = f(theta_range, phi_range)
31
-
32
- im_spherical.disp(badcolor="red")
33
- # plt.show(block=True)
34
-
35
-
36
- # sphere
37
- R = 1
38
- x = R * np.sin(Theta) * np.cos(Phi)
39
- y = R * np.sin(Theta) * np.sin(Phi)
40
- z = R * np.cos(Theta)
41
-
42
- # create 3d Axes
43
- fig = plt.figure()
44
- ax = fig.add_subplot(111, projection="3d")
45
- img = im_spherical.colorize()
46
- ax.plot_surface(
47
- x.T, y.T, z.T, facecolors=img.image, cstride=1, rstride=1
48
- ) # we've already pruned ourselves
49
-
50
- for az in np.arange(-180, 180, 30):
51
- for el in np.arange(-180, 180, 30):
52
- print(az, el)
53
- ax.view_init(azim=az, elev=el)
54
- safe_plt_show(block=False)
55
- plt.savefig(f"az{az}el{el}.png")
@@ -1,12 +0,0 @@
1
- from skimage.filters import threshold_triangle, threshold_otsu
2
-
3
-
4
- from machinevisiontoolbox import Image
5
-
6
- image = Image.Read("monalisa.png", grey=True, dtype="uint8")
7
-
8
- thresh = threshold_otsu(image.array)
9
- print(f"Otsu threshold: {thresh}")
10
-
11
- thresh = threshold_triangle(image.array)
12
- print(f"Triangle threshold: {thresh}")
@@ -1,17 +0,0 @@
1
- from machinevisiontoolbox import Image
2
- import matplotlib.pyplot as plt
3
-
4
- im = Image.Read("sharks.png")
5
- im.disp()
6
- blobs = im.blobs()
7
-
8
- blobs[0].plot_box("b--") # blue dashed box
9
- # blobs[1].plot_box(color="blue", linestyle="--") # blue dashed box
10
- blobs[2].plot_box(color="g") # solid green box
11
- blobs[3].plot_box(color="r", linewidth=4)
12
-
13
-
14
- blobs[:3].plot_labelbox(color="yellow")
15
- blobs[3].plot_labelbox(color="lightblue", linewidth=2, label="3")
16
-
17
- plt.show(block=True)
@@ -1,296 +0,0 @@
1
- [
2
- {
3
- "id": 0,
4
- "corners": [
5
- [
6
- 1433.0,
7
- 1165.0
8
- ],
9
- [
10
- 1561.0,
11
- 1169.0
12
- ],
13
- [
14
- 1593.0,
15
- 1207.0
16
- ],
17
- [
18
- 1456.0,
19
- 1203.0
20
- ]
21
- ],
22
- "pose": [
23
- [
24
- 0.92835230498794,
25
- -0.34780808326858614,
26
- 0.13111649414399063,
27
- -94.2920947655507
28
- ],
29
- [
30
- -0.00984271358740757,
31
- -0.37562575528276465,
32
- -0.9267191661757562,
33
- -60.93755260773556
34
- ],
35
- [
36
- 0.3715711490587168,
37
- 0.8590313318973207,
38
- -0.35213641107658833,
39
- 568.589997335457
40
- ],
41
- [
42
- 0.0,
43
- 0.0,
44
- 0.0,
45
- 1.0
46
- ]
47
- ],
48
- "rmse": 0.7901603002004954,
49
- "rmax": 1.173062503642086
50
- },
51
- {
52
- "id": 1,
53
- "corners": [
54
- [
55
- 1648.0,
56
- 312.0
57
- ],
58
- [
59
- 1556.0,
60
- 322.0
61
- ],
62
- [
63
- 1541.0,
64
- 223.0
65
- ],
66
- [
67
- 1633.0,
68
- 209.0
69
- ]
70
- ],
71
- "pose": [
72
- [
73
- -0.9898896908818804,
74
- 0.11389739308828616,
75
- -0.0845327376432814,
76
- -111.68559203586254
77
- ],
78
- [
79
- 0.07970808627288817,
80
- 0.9396627644957044,
81
- 0.3326868046722085,
82
- -329.9162724119626
83
- ],
84
- [
85
- 0.1173244257113123,
86
- 0.32258529549249887,
87
- -0.9392410267144042,
88
- 806.7507157660268
89
- ],
90
- [
91
- 0.0,
92
- 0.0,
93
- 0.0,
94
- 1.0
95
- ]
96
- ],
97
- "rmse": 0.6425972432695056,
98
- "rmax": 0.9624657121082691
99
- },
100
- {
101
- "id": 2,
102
- "corners": [
103
- [
104
- 493.0,
105
- 1034.0
106
- ],
107
- [
108
- 386.0,
109
- 1049.0
110
- ],
111
- [
112
- 390.0,
113
- 935.0
114
- ],
115
- [
116
- 497.0,
117
- 924.0
118
- ]
119
- ],
120
- "pose": [
121
- [
122
- -0.47307974332420377,
123
- -0.24332825328373386,
124
- 0.8467508001827886,
125
- -334.2686695782683
126
- ],
127
- [
128
- 0.2561758460129068,
129
- 0.8815840877571635,
130
- 0.3964636580229534,
131
- -111.76693481333844
132
- ],
133
- [
134
- -0.8429528411339968,
135
- 0.4044760281738053,
136
- -0.354724752811058,
137
- 646.8094926267707
138
- ],
139
- [
140
- 0.0,
141
- 0.0,
142
- 0.0,
143
- 1.0
144
- ]
145
- ],
146
- "rmse": 0.2897872602373098,
147
- "rmax": 0.3991507650120525
148
- },
149
- {
150
- "id": 3,
151
- "corners": [
152
- [
153
- 335.0,
154
- 603.0
155
- ],
156
- [
157
- 438.0,
158
- 601.0
159
- ],
160
- [
161
- 438.0,
162
- 707.0
163
- ],
164
- [
165
- 336.0,
166
- 713.0
167
- ]
168
- ],
169
- "pose": [
170
- [
171
- 0.5079328585522592,
172
- 0.22263982156138973,
173
- 0.8321272264852552,
174
- -375.84320103586043
175
- ],
176
- [
177
- -0.26716726080303205,
178
- -0.877664353783423,
179
- 0.3979031752234846,
180
- -197.4695040037398
181
- ],
182
- [
183
- 0.8189174964292406,
184
- -0.42442524895797495,
185
- -0.38631249279440305,
186
- 702.7579462875794
187
- ],
188
- [
189
- 0.0,
190
- 0.0,
191
- 0.0,
192
- 1.0
193
- ]
194
- ],
195
- "rmse": 0.18975245200857788,
196
- "rmax": 0.24180580854795153
197
- },
198
- {
199
- "id": 4,
200
- "corners": [
201
- [
202
- 793.0,
203
- 206.0
204
- ],
205
- [
206
- 868.0,
207
- 251.0
208
- ],
209
- [
210
- 783.0,
211
- 332.0
212
- ],
213
- [
214
- 704.0,
215
- 291.0
216
- ]
217
- ],
218
- "pose": [
219
- [
220
- 0.22675297560842156,
221
- 0.7859223571524304,
222
- 0.5752470222267074,
223
- -247.0133554563952
224
- ],
225
- [
226
- -0.05089423587737285,
227
- -0.5802631719637132,
228
- 0.812837270317416,
229
- -249.62070038117153
230
- ],
231
- [
232
- 0.972621645249161,
233
- -0.21359002736686333,
234
- -0.09157748305253643,
235
- 612.2924977079425
236
- ],
237
- [
238
- 0.0,
239
- 0.0,
240
- 0.0,
241
- 1.0
242
- ]
243
- ],
244
- "rmse": 0.22278080548038556,
245
- "rmax": 0.31878241145602715
246
- },
247
- {
248
- "id": 5,
249
- "corners": [
250
- [
251
- 947.0,
252
- 922.0
253
- ],
254
- [
255
- 1048.0,
256
- 921.0
257
- ],
258
- [
259
- 1031.0,
260
- 1025.0
261
- ],
262
- [
263
- 927.0,
264
- 1024.0
265
- ]
266
- ],
267
- "pose": [
268
- [
269
- 0.981032023570163,
270
- 0.0815147455001875,
271
- -0.17587357674156448,
272
- -229.764524003768
273
- ],
274
- [
275
- 0.03355594198682834,
276
- -0.9650019392362628,
277
- -0.2600870162611516,
278
- -120.53579906337599
279
- ],
280
- [
281
- -0.19091926955445834,
282
- 0.2492520883288475,
283
- -0.9494331092691577,
284
- 680.6514617361494
285
- ],
286
- [
287
- 0.0,
288
- 0.0,
289
- 0.0,
290
- 1.0
291
- ]
292
- ],
293
- "rmse": 0.44865584687899895,
294
- "rmax": 0.5674550487083252
295
- }
296
- ]