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
30 changes: 3 additions & 27 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,32 +109,6 @@ jobs:
meta.setdefault("language_info", {})
meta["language_info"]["name"] = "python"

for cell in nb.get("cells", []):
if cell.get("cell_type") != "code":
continue
source = cell.get("source", [])
if isinstance(source, str):
lines = source.splitlines(keepends=True)
else:
lines = source

new_lines = []
changed = False
for line in lines:
if line.strip() in ("%matplotlib ipympl", "%matplotlib widget"):
newline = "\n" if line.endswith("\n") else ""
new_lines.append(f"%matplotlib inline{newline}")
changed = True
else:
new_lines.append(line)

if changed:
cell["source"] = (
new_lines
if not isinstance(source, str)
else "".join(new_lines)
)

with nb_path.open("w", encoding="utf-8") as f:
json.dump(nb, f, indent=1)
f.write("\n")
Expand All @@ -147,11 +121,13 @@ jobs:
# ships JSPI, and the old Pyodide then misbehaved there (the kernel never
# finished starting). A browser with no JSPI (Safari before 27; Firefox
# before 153) is now told so by a banner, added below, not supported by a pin.
# ipympl is installed here so that the site carries the jupyter-matplotlib
# extension, which the notebooks' %matplotlib ipympl needs in the browser.
# Installing jupyterlite-core directly rather than the jupyterlite metapackage.
# Keep docs/lite/wasm_check/package.json's pyodide in step with the Pyodide
# that the kernel bundles (0.8.7 bundles 314.0.6).
run: |
pip install jupyterlite-core "jupyterlite-pyodide-kernel>=0.8.7" jupyter-server
pip install jupyterlite-core "jupyterlite-pyodide-kernel>=0.8.7" jupyter-server ipympl
cd docs/lite && jupyter lite build --output-dir ../build/html/lite

- name: Add the browser capability check to JupyterLite
Expand Down
23 changes: 10 additions & 13 deletions docs/notebooks/IBVS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand All @@ -50,7 +50,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -148,7 +148,7 @@
"import numpy as np\n",
"import math\n",
"\n",
"%matplotlib inline\n",
"%matplotlib ipympl\n",
"\n",
"np.set_printoptions(linewidth=120, formatter={'float': lambda x: f\"{x:8.4g}\" if abs(x) > 1e-10 else f\"{0:8.4g}\"})\n",
"from machinevisiontoolbox import Image, CentralCamera\n",
Expand Down Expand Up @@ -252,8 +252,7 @@
"outputs": [],
"source": [
"# setup the plot\n",
"plt.figure()\n",
"ax = plt.gca()\n",
"fig, ax = plt.subplots()\n",
"plt.grid(True)\n",
"ax.set_aspect('equal')\n",
"ax.set_facecolor('yellow')\n",
Expand Down Expand Up @@ -290,8 +289,7 @@
" [900, 180],\n",
" [500, 870] ]).T\n",
"\n",
"plt.figure()\n",
"ax = plt.gca()\n",
"fig, ax = plt.subplots()\n",
"plt.grid(True)\n",
"ax.set_aspect('equal')\n",
"ax.set_facecolor('yellow')\n",
Expand All @@ -302,8 +300,7 @@
"ax.set_ylim(1000, 0) # inverted y-axis\n",
"\n",
"plt.plot(p[0,:], p[1,:], 'o');\n",
"plt.plot(pstar[0,:], pstar[1,:], 'r*', markersize=16);\n",
"plt.show()"
"plt.plot(pstar[0,:], pstar[1,:], 'r*', markersize=16);"
]
},
{
Expand Down Expand Up @@ -348,9 +345,7 @@
},
"outputs": [],
"source": [
"plt.clf()\n",
"plt.figure()\n",
"ax = plt.gca()\n",
"fig, ax = plt.subplots()\n",
"plt.grid(True)\n",
"ax.set_aspect('equal')\n",
"ax.set_facecolor('yellow')\n",
Expand Down Expand Up @@ -550,7 +545,7 @@
},
"outputs": [],
"source": [
"plt.figure()\n",
"fig, ax = plt.subplots()\n",
"plt.plot(pstar[0,:], pstar[1,:], 'r*', markersize=16);\n",
"plt.xlabel('X')\n",
"plt.ylabel('Y')\n",
Expand Down Expand Up @@ -605,6 +600,7 @@
},
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"plt.plot(pose_history.t)\n",
"plt.legend(list(\"XYZ\"))\n",
"plt.xlabel('time step')\n",
Expand All @@ -630,6 +626,7 @@
},
"outputs": [],
"source": [
"fig, ax = plt.subplots()\n",
"plt.plot(enorm_history)\n",
"plt.xlabel('time step')\n",
"plt.ylabel('$\\|e\\|$')\n",
Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/_mvtb_nb_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"numpy",
"scipy",
"matplotlib",
"ipympl",
"pillow",
"typing_extensions",
"opencv-python",
Expand Down
9 changes: 6 additions & 3 deletions docs/notebooks/calibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand All @@ -48,7 +48,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -141,6 +141,9 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib ipympl\n",
"import matplotlib.pyplot as plt\n",
"plt.close(\"all\") # re-running the notebook from the top starts with no figures\n",
"from machinevisiontoolbox import *\n",
"import numpy as np\n",
"np.set_printoptions(linewidth=120, formatter={'float': lambda x: f\"{x:8.4g}\" if abs(x) > 1e-10 else f\"{0:8.4g}\"})"
Expand Down Expand Up @@ -499,7 +502,7 @@
"metadata": {},
"outputs": [],
"source": [
"plt.clf() # clear 3D plot\n",
"fig, ax = plt.subplots()\n",
"plt.quiver(Ud[::50, ::50], Vd[::50, ::50], -delta_u[::50, ::50], -delta_v[::50, ::50]);"
]
},
Expand Down
8 changes: 5 additions & 3 deletions docs/notebooks/camera.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand All @@ -52,7 +52,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -147,7 +147,9 @@
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%matplotlib ipympl\n",
"import matplotlib.pyplot as plt\n",
"plt.close(\"all\") # re-running the notebook from the top starts with no figures\n",
"\n",
"import numpy as np\n",
"import math\n",
Expand Down
18 changes: 11 additions & 7 deletions docs/notebooks/camera_animation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand All @@ -48,7 +48,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -141,12 +141,13 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib ipympl\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"plt.close(\"all\") # re-running the notebook from the top starts with no figures\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"import mpl_toolkits.mplot3d.art3d as art3d\n",
"import ipywidgets as widgets\n",
"%matplotlib inline"
"import ipywidgets as widgets\n"
]
},
{
Expand Down Expand Up @@ -188,13 +189,16 @@
" [ 5, 5],\n",
" [ 5, -5] ])\n",
"\n",
"# create the figure once, the slider callback redraws it\n",
"fig = plt.figure(figsize=(10, 10))\n",
"ax = fig.add_subplot(projection='3d')\n",
"\n",
"@widgets.interact\n",
"def animate( X = widgets.FloatSlider(value=1, description='X:', min=-4, max=4),\n",
" Y = widgets.FloatSlider(value=1, description='Y:', min=-4, max=4),\n",
" Z = widgets.FloatSlider(value=2, description='Z:', min=1, max=5),\n",
" f = widgets.FloatSlider(value=1, description='f', min=0.1, max=1.5)):\n",
" fig = plt.figure(figsize=(10, 10))\n",
" ax = plt.axes(projection='3d')\n",
" ax.clear()\n",
" p = plt.Polygon(verts, alpha=0.7, color=\"lightyellow\")\n",
"\n",
" ax.add_patch(p)\n",
Expand All @@ -216,7 +220,7 @@
"\n",
" ax.text(X, Y, Z, \" P\")\n",
" ax.text(x, y, f, \" p = (%.3f, %.3f)\" % (x, y))\n",
" plt.show()\n",
" fig.canvas.draw_idle()\n",
" \n",
" # uv_coords.value = \"Image-plane coordinate: (%.3f, %.3f)\" % (x, y)\n"
]
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/color-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand All @@ -48,7 +48,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -141,8 +141,9 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"%matplotlib ipympl\n",
"import matplotlib.pyplot as plt\n",
"plt.close(\"all\") # re-running the notebook from the top starts with no figures\n",
"\n",
"import numpy as np\n",
"from machinevisiontoolbox import *\n",
Expand Down Expand Up @@ -520,7 +521,6 @@
"metadata": {},
"outputs": [],
"source": [
"plt.figure()\n",
"hist.plot(type=\"frequency\", style=\"stack\")"
]
},
Expand Down
6 changes: 4 additions & 2 deletions docs/notebooks/exploring-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand Down Expand Up @@ -56,7 +56,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -150,6 +150,8 @@
"outputs": [],
"source": [
"%matplotlib ipympl\n",
"import matplotlib.pyplot as plt\n",
"plt.close(\"all\") # re-running the notebook from the top starts with no figures\n",
"from machinevisiontoolbox import Image"
]
},
Expand Down
9 changes: 5 additions & 4 deletions docs/notebooks/fiducials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"We need to import some packages to help us with linear algebra (`numpy`), graphics (`matplotlib`), and machine vision (`machinevisiontoolbox`). If you're running locally you need to have these packages installed.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow. In the browser environment it is not possible to examine pixel values by hovering the mouse cursor over an image (this is a limitation of Matplotlib in a Pyodide Web Worker).\n",
"If you're running on CoLab or in the browser we have to first install machinevisiontoolbox, which is not preinstalled, so the next cell will be slow.\n",
"</div>"
]
},
Expand All @@ -52,7 +52,7 @@
"PACKAGE = 'machinevision-toolbox-python'\n",
"IMPORT_NAME = 'machinevisiontoolbox'\n",
"GIT_URL: str | None = 'https://github.com/petercorke/machinevision-toolbox-python'\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_PACKAGES = ['numpy', 'scipy', 'matplotlib', 'ipympl', 'pillow', 'typing_extensions', 'opencv-python', 'ansitable', 'mvtb-data', 'tqdm', 'requests', 'ipywidgets', 'spatialmath-python', 'pgraph-python']\n",
"JL_NO_DEPS: list[str] = []\n",
"JL_PACKAGE_NO_DEPS = True\n",
"JL_EXTRAS: dict[str, list[str]] = {}\n",
Expand Down Expand Up @@ -155,7 +155,8 @@
"from spatialmath.base import e2h, h2e\n",
"from machinevisiontoolbox import Image, CentralCamera\n",
"from spatialmath.base import plot_point\n",
"import matplotlib.pyplot as plt\n"
"import matplotlib.pyplot as plt\n",
"plt.close(\"all\") # re-running the notebook from the top starts with no figures\n"
]
},
{
Expand Down Expand Up @@ -307,7 +308,7 @@
},
"outputs": [],
"source": [
"scene.disp(block=None)\n",
"scene.disp()\n",
"plot_point(marker.corners, 'bx')\n",
"plt.xlim(800, 1200)\n",
"plt.ylim(1200, 800)"
Expand Down
Loading
Loading