Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/machinevisiontoolbox/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,6 @@ def _plot_camera_icon(
cr = 0.2 # cylinder radius
ch = 0.4 # cylinder height
cn = 12 # number of facets of cylinder
a = 3 # length of axis line segments

# draw the box part of the camera
smb.plot_cuboid(
Expand Down Expand Up @@ -3266,7 +3265,6 @@ def visjac_p_polar(

J = []
p = _getmatrix(p, (2, None))
f = self.f[0]

Zs = [Z] * p.shape[1] if smb.isscalar(Z) else Z

Expand Down Expand Up @@ -4089,7 +4087,6 @@ def project_point( # type: ignore[override]
R = np.linalg.norm(P_arr, axis=0)
x = P_arr[0, :] / R
y = P_arr[1, :] / R
z = P_arr[2, :] / R

phi = np.arctan2(y, x)
r = np.sqrt(x**2 + y**2)
Expand Down
1 change: 0 additions & 1 deletion src/machinevisiontoolbox/ImageBlobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def __init__(
# 2: index of first child,
# 3: index of parent
hierarchy = hierarchy[0, :, :] # drop the first singleton dimension
parents = hierarchy[:, 3]

## Collect blob data in first pass, then instantiate with all fields

Expand Down
2 changes: 0 additions & 2 deletions src/machinevisiontoolbox/ImageConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,6 @@ def Polygons(


if __name__ == "__main__":
from pathlib import Path

import pytest

pytest.main(
Expand Down
2 changes: 0 additions & 2 deletions src/machinevisiontoolbox/ImageCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -4490,8 +4490,6 @@ def fixbad(
Image.__module__ = "machinevisiontoolbox"

if __name__ == "__main__":
from pathlib import Path

import pytest

pytest.main(
Expand Down
2 changes: 1 addition & 1 deletion src/machinevisiontoolbox/ImageIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ def set_cross_hair_visible(self, visible: bool) -> bool:

def on_mouse_move(self, event: Any) -> None:
if event.inaxes == self.ax2 and self.leftclicked:
x, y = event.xdata, event.ydata
x = event.xdata
# update the line positions
self.vertical_line3.set_xdata([x, x])
self.text.set_text("d={:.2f}".format(self.x_left - x))
Expand Down
1 change: 0 additions & 1 deletion src/machinevisiontoolbox/ImageProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ def choose(self, image2: Any, mask: Any) -> Self:
im1 = np.repeat(np.atleast_3d(im1), im2.shape[2], axis=2)

ones = np.ones_like(mask, dtype=np.uint8)
m = cv2.bitwise_and(src1=mask, src2=ones)
m_not = cv2.bitwise_xor(src1=mask, src2=ones)

out = cv2.bitwise_and(src1=im1, src2=im1, mask=m_not) + cv2.bitwise_and(
Expand Down
4 changes: 1 addition & 3 deletions src/machinevisiontoolbox/PointCloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _show_in_notebook(
if file is not None:
raise ValueError("file cannot be used with notebook=True")
try:
import plotly # noqa: F401
__import__("plotly")
except ImportError:
raise ImportError(
"disp(notebook=True) draws with Plotly, which is not installed. "
Expand Down Expand Up @@ -1173,8 +1173,6 @@ def disp(


if __name__ == "__main__":
from pathlib import Path

import pytest

pytest.main(
Expand Down
4 changes: 2 additions & 2 deletions src/machinevisiontoolbox/Sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,12 +1274,12 @@ def __iter__(self) -> FileCollection:

def __str__(self) -> str:
if self._lazy:
return f"FileCollection(lazy mode)"
return "FileCollection(lazy mode)"
return "\n".join([str(f) for f in self.names])

def __repr__(self) -> str:
if self._lazy:
return f"FileCollection(lazy mode)"
return "FileCollection(lazy mode)"
return f"FileCollection(nimages={len(self.images)})"

def __next__(self) -> Image:
Expand Down
2 changes: 0 additions & 2 deletions src/machinevisiontoolbox/base/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ def loadspectrum(

- |RVC3|, Section 10.1.
"""
global _spectra

if filename not in _spectra:
# save an interpolator for every spectrum
if not filename.endswith(".dat"):
Expand Down
5 changes: 0 additions & 5 deletions src/machinevisiontoolbox/base/findpeaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ def findpeaks3d(v: np.ndarray, npeaks: int | None = None) -> np.ndarray:
# create 3x3x3 structuring element and maximum filter
se_nhood = np.ones((3, 3, 3))
se_nhood[1, 1, 1] = 0
eps = np.finfo(np.float64).eps
maxima = v > sp.ndimage.maximum_filter(v, footprint=se_nhood, mode="nearest")

# find the locations of the minima
Expand All @@ -328,10 +327,6 @@ def findpeaks3d(v: np.ndarray, npeaks: int | None = None) -> np.ndarray:


if __name__ == "__main__":
import numpy as np

from machinevisiontoolbox.base import *

y = np.array([0, 0, 1, 2, 0, 0, 0, 3, 1, 0, 0, 0, 0])
print(findpeaks(y, scale=3))
print(findpeaks(y, scale=3, interp=True))
Expand Down
17 changes: 0 additions & 17 deletions src/machinevisiontoolbox/base/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,20 +1226,3 @@ def function(*fmt, ..., **kwargs):
kwargs = cbook.normalize_kwargs(kwargs or {}, artist)
options = (defaults or {}) | res | (kwargs or {})
return {k: v for k, v in options.items() if v is not None}


if __name__ == "__main__":
import numpy as np


# import numpy as np
# from machinevisiontoolbox import idisp, iread, Image

# from machinevisiontoolbox import draw_labelbox

# img = np.zeros((1000, 1000, 3), dtype="float32")
# draw_box(img, lrbt=[100, 400, 100, 400], color="red", thickness=-1)
# draw_box(img, lrbt=[500, 800, 100, 400], color="green", thickness=-1)
# draw_box(img, lrbt=[100, 400, 500, 800], color="blue", thickness=-1)
# draw_box(img, lrbt=[500, 800, 500, 800], color="white", thickness=-1)
# idisp(img, block=True)
5 changes: 2 additions & 3 deletions src/machinevisiontoolbox/base/imageio.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _ensure_mpl_backend() -> None:
return

try:
import google.colab # noqa: F401
__import__("google.colab")

mpl.use("module://matplotlib_inline.backend_inline")
return
Expand Down Expand Up @@ -1194,7 +1194,6 @@ def iread(
raise ValueError(f"Could not fetch {filename}: {e.reason}") from e

if isinstance(filename, (str, Path)):
filename_str = str(filename)
path = Path(filename).expanduser()
if glob.has_magic(str(path)):
images = []
Expand Down Expand Up @@ -1550,7 +1549,7 @@ def click_event(event: Any, x: int, y: int, flags: Any, params: Any) -> None:


if __name__ == "__main__":
from machinevisiontoolbox import *
from machinevisiontoolbox import FileCollection

images = FileCollection("seq/*.png")

Expand Down
2 changes: 1 addition & 1 deletion src/machinevisiontoolbox/bin/bagtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _download_bag(url: str, keep: bool) -> tuple[str, bool]:
def getargs():
parser = argparse.ArgumentParser(
formatter_class=CustomDefaultsHelpFormatter,
description=f"Display images or pointclouds from a ROS bag file using Machine Vision Toolbox for Python.",
description="Display images or pointclouds from a ROS bag file using Machine Vision Toolbox for Python.",
)
parser.add_argument(
"files",
Expand Down
14 changes: 4 additions & 10 deletions src/machinevisiontoolbox/bin/imtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

# Set by figure keypress callback when the user requests immediate exit.
exit_requested = False
cs_image: np.ndarray # image in the display colorspace, set by main()
colorspace: str # name of that colorspace, set by main()
cs_image = np.empty((0, 0)) # image in the display colorspace, set by main()
colorspace = "" # name of that colorspace, set by main()


def getargs():
parser = argparse.ArgumentParser(
formatter_class=CustomDefaultsHelpFormatter,
description=f"Display an image using Machine Vision Toolbox for Python.",
description="Display an image using Machine Vision Toolbox for Python.",
)
parser.add_argument(
"files",
Expand Down Expand Up @@ -149,7 +149,7 @@ def visualize_image(image, args, block):
)
table.print()
else:
global cs_image, colorspace, exit_requested
global cs_image, colorspace

if args.colorspace is not None:
cs_image = (
Expand Down Expand Up @@ -191,8 +191,6 @@ def _on_exit(event):

# format the pixel value display
def format_coord(u: float, v: float) -> str:
global cs_image, colorspace

u = int(u + 0.5)
v = int(v + 0.5)

Expand Down Expand Up @@ -229,17 +227,13 @@ def format_coord(u: float, v: float) -> str:


def main():
global exit_requested

args = getargs()

if args.backend is not None:
matplotlib.use(args.backend)

import matplotlib.pyplot as plt # noqa: F401 — initialises backend, used via globals

from machinevisiontoolbox.bin._iminteractive import ImageInteractor # noqa: F401

if len(args.files) > 10:
args.block = True

Expand Down
2 changes: 1 addition & 1 deletion src/machinevisiontoolbox/bin/mvtbtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def run_smoke_test() -> bool:
checks.append((f"Image.Read + smooth() (OpenCV-backed): {e}", False))

try:
import open3d # noqa: F401 -- presence check; PointCloud does the real work
__import__("open3d") # presence check; PointCloud does the real work
except ImportError as e:
checks.append(
(
Expand Down
2 changes: 1 addition & 1 deletion src/machinevisiontoolbox/bin/ocrtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def getargs():
parser = argparse.ArgumentParser(
formatter_class=CustomDefaultsHelpFormatter,
description=f"Display text words found in image using Machine Vision Toolbox for Python. "
description="Display text words found in image using Machine Vision Toolbox for Python. "
"Words are written to stdout or a JSON file, but can also be highlighted in the image.",
)
parser.add_argument(
Expand Down
3 changes: 1 addition & 2 deletions src/machinevisiontoolbox/bin/tagtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def getargs():
parser = argparse.ArgumentParser(
formatter_class=CustomDefaultsHelpFormatter,
description=f"Display AR tags in image using Machine Vision Toolbox for Python."
description="Display AR tags in image using Machine Vision Toolbox for Python."
"AR tags are highlighted with their IDs and the canonic top-left corner is marked.",
epilog="A camera model is required to determine poses, this requires that focal length is specified.",
)
Expand Down Expand Up @@ -262,7 +262,6 @@ def process_image(image, args, block):

def main():
args = getargs()
json_data = []

if len(args.files) > 10:
args.block = True
Expand Down
2 changes: 0 additions & 2 deletions src/machinevisiontoolbox/mvtb_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
NumPy array type aliases used throughout the Machine Vision Toolbox.
"""

from typing import Any

import numpy as np
import numpy.typing as npt

Expand Down
Loading