diff --git a/src/machinevisiontoolbox/BundleAdjust.py b/src/machinevisiontoolbox/BundleAdjust.py index 67b41f28..fae5d2ce 100644 --- a/src/machinevisiontoolbox/BundleAdjust.py +++ b/src/machinevisiontoolbox/BundleAdjust.py @@ -405,7 +405,8 @@ def add_projection( :seealso: :meth:`add_view` :meth:`add_landmark` """ - assert len(uv) == 2, "uv must be a 2-vector" + if len(uv) != 2: + raise ValueError("uv must be a 2-vector") edge = Observation(viewpoint, landmark, uv.flatten()) # create edge object e = viewpoint.connect(landmark, edge=edge) # connect nodes with it diff --git a/src/machinevisiontoolbox/Camera.py b/src/machinevisiontoolbox/Camera.py index 9be5c404..e7c76e98 100644 --- a/src/machinevisiontoolbox/Camera.py +++ b/src/machinevisiontoolbox/Camera.py @@ -350,7 +350,8 @@ def nu(self) -> int: :seealso: :meth:`nv` :meth:`width` :meth:`imagesize` """ - assert self._imagesize is not None, "imagesize not set" + if self._imagesize is None: + raise ValueError("imagesize not set") return self._imagesize[0] @property @@ -370,7 +371,8 @@ def nv(self) -> int: :seealso: :meth:`nu` :meth:`height` :meth:`imagesize` """ - assert self._imagesize is not None, "imagesize not set" + if self._imagesize is None: + raise ValueError("imagesize not set") return self._imagesize[1] @property @@ -390,7 +392,8 @@ def width(self) -> int: :seealso: :meth:`nu` :meth:`height` """ - assert self._imagesize is not None, "imagesize not set" + if self._imagesize is None: + raise ValueError("imagesize not set") return self._imagesize[0] @property @@ -410,7 +413,8 @@ def height(self) -> int: :seealso: :meth:`nv` :meth:`width` """ - assert self._imagesize is not None, "imagesize not set" + if self._imagesize is None: + raise ValueError("imagesize not set") return self._imagesize[1] @property diff --git a/src/machinevisiontoolbox/Sources.py b/src/machinevisiontoolbox/Sources.py index 5de72c67..7b05484f 100644 --- a/src/machinevisiontoolbox/Sources.py +++ b/src/machinevisiontoolbox/Sources.py @@ -2348,7 +2348,7 @@ def _pointcloud_to_ros_message( "Install it with: pip install open3d " "or pip install machinevision-toolbox-python[open3d]" ) - assert o3d is not None + assert o3d is not None points = np.asarray(pc._pcd.points) if points.ndim != 2 or points.shape[1] != 3: