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
@@ -148,6 +148,15 @@ def parse_arguments():
148
148
  help="images to load on startup. These appear in the variable img; or img[0], img[1], ... if multiple are specified",
149
149
  )
150
150
 
151
+ parser.add_argument(
152
+ "--test",
153
+ default=False,
154
+ action="store_true",
155
+ help="non-interactive environment smoke test: print package versions, "
156
+ "exercise one real numeric code path per package, exit 0/1 "
157
+ "instead of starting an interactive shell",
158
+ )
159
+
151
160
  argv = env_arguments(parser) + sys.argv[1:]
152
161
  return parser.parse_known_args(argv)
153
162
 
@@ -183,23 +192,29 @@ def optional_torch_imports(enable):
183
192
  return modules, warnings
184
193
 
185
194
 
195
+ def get_versions() -> list[str]:
196
+ """Package version strings shown in the banner and by --test."""
197
+ versions = [
198
+ f"Python=={sys.version.split('|')[0].strip()}",
199
+ f"MVTB=={version('machinevision-toolbox-python')}",
200
+ f"SMTB=={version('spatialmath-python')}",
201
+ f"NumPy=={version('numpy')}",
202
+ f"SciPy=={version('scipy')}",
203
+ f"Matplotlib=={version('matplotlib')}",
204
+ f"OpenCV=={cv2.__version__}",
205
+ ]
206
+ try:
207
+ versions.append(f"Open3D=={version('open3d')}")
208
+ except PackageNotFoundError:
209
+ versions.append("Open3D==not installed")
210
+ return versions
211
+
212
+
186
213
  def make_banner(args, optional_modules=None):
187
214
  if optional_modules is None:
188
215
  optional_modules = {}
189
216
 
190
- versions = []
191
-
192
- versions.append(f"Python=={sys.version.split('|')[0].strip()}")
193
- versions.append(f"MVTB=={version('machinevision-toolbox-python')}")
194
- versions.append(f"SMTB=={version('spatialmath-python')}")
195
- versions.append(f"NumPy=={version('numpy')}")
196
- versions.append(f"SciPy=={version('scipy')}")
197
- versions.append(f"Matplotlib=={version('matplotlib')}")
198
- versions.append(f"OpenCV=={cv2.__version__}")
199
- try:
200
- versions.append(f"Open3D=={version('open3d')}")
201
- except PackageNotFoundError:
202
- pass
217
+ versions = get_versions()
203
218
 
204
219
  if "torch" in optional_modules:
205
220
  versions.append(
@@ -260,8 +275,73 @@ func/object?? - show source code"""
260
275
  print(banner)
261
276
 
262
277
 
278
+ def run_smoke_test() -> bool:
279
+ """Non-interactive environment sanity check, used by --test.
280
+
281
+ Not a substitute for the pytest suite -- a fast, human- or script-run
282
+ "did this environment actually come together correctly" check: real
283
+ versions, and one real numeric result per OpenCV- and Open3D-backed
284
+ code path, checked against a sanity condition rather than just "it
285
+ didn't raise". Missing optional dependencies (e.g. Open3D) are
286
+ reported as a FAIL with the reason, not silently skipped.
287
+ """
288
+ print(", ".join(get_versions()))
289
+
290
+ checks: list[tuple[str, bool]] = []
291
+
292
+ try:
293
+ img = Image.Read("monalisa.png", mono=True)
294
+ smoothed = img.smooth(sigma=2)
295
+ ok = smoothed.shape == img.shape and not np.array_equal(
296
+ smoothed.array, img.array
297
+ )
298
+ checks.append(("Image.Read + smooth() (OpenCV-backed)", ok))
299
+ except Exception as e:
300
+ checks.append((f"Image.Read + smooth() (OpenCV-backed): {e}", False))
301
+
302
+ try:
303
+ import open3d # noqa: F401 -- presence check; PointCloud does the real work
304
+ except ImportError as e:
305
+ checks.append(
306
+ (f"PointCloud.Read('bunny.ply') + voxel_grid(): Open3D not installed ({e})", False)
307
+ )
308
+ else:
309
+ try:
310
+ bunny = PointCloud.Read("bunny.ply")
311
+ voxels = bunny.voxel_grid(voxel_size=0.01)
312
+ ok = len(bunny) > 0 and len(voxels._voxels.get_voxels()) > 0
313
+ checks.append(("PointCloud.Read('bunny.ply') + voxel_grid() (Open3D-backed)", ok))
314
+ except Exception as e:
315
+ checks.append(
316
+ (f"PointCloud.Read('bunny.ply') + voxel_grid() (Open3D-backed): {e}", False)
317
+ )
318
+
319
+ for name, passed in checks:
320
+ print(f"[{'PASS' if passed else 'FAIL'}] {name}")
321
+
322
+ n_passed = sum(1 for _, passed in checks if passed)
323
+ print(f"mvtbtool --test: {n_passed}/{len(checks)} checks passed")
324
+ return n_passed == len(checks)
325
+
326
+
263
327
  def main():
264
328
  args, ipython_args = parse_arguments()
329
+
330
+ if args.test:
331
+ sys.exit(0 if run_smoke_test() else 1)
332
+
333
+ try:
334
+ import IPython
335
+ from IPython.terminal.prompts import Prompts
336
+ from pygments.token import Token
337
+ from traitlets.config import Config
338
+ except ImportError as e:
339
+ sys.exit(
340
+ f"mvtbtool requires IPython and pygments, which are not "
341
+ f"installed ({e}).\nInstall them with:\n\n"
342
+ " pip install machinevision-toolbox-python[tool]\n"
343
+ )
344
+
265
345
  torch_modules, torch_warnings = optional_torch_imports(args.torch)
266
346
 
267
347
  if args.backend is not None:
@@ -281,11 +361,6 @@ def main():
281
361
  # exec(path.read_text())
282
362
 
283
363
  ## drop into IPython
284
- import IPython
285
- from IPython.terminal.prompts import ClassicPrompts, Prompts
286
- from pygments.token import Token
287
- from traitlets.config import Config
288
-
289
364
  class MyPrompt(Prompts):
290
365
  def in_prompt_tokens(self, cli=None):
291
366
  return [(Token.Prompt, args.prompt)]