Camera geometry blocks#
These blocks model camera projection functions.
Machine Vision blocks:
- have inputs and outputs
- are a subclass of FunctionBlock → Block for kinematics and have no states
- are a subclass of TransferBlock → Block for dynamics and have states
- class Camera(*args: Any, **kwargs: Any)[source][source]#
Bases:
FunctionBlockCAMERA
Camera projection block.
- Parameters:
camera – camera model, a subclass of
CameraBaseargs – not used
blockargs – Additional options for the block, passed as a dictionary
- Raises:
ValueError – if
camerais None- Returns:
a CAMERA block
- Return type:
Camera instance
Camera projection model.
Block ports
- input P:
world points as ndarray(3,N)
- input ξ:
camera pose as an SE3 object
- output p:
image plane points as ndarray(2,N)
- __init__(camera: CameraBase | None = None, args: dict[str, Any] = {}, **blockargs: Any) None[source][source]#
- Parameters:
camera – camera model, a subclass of
CameraBaseargs – not used
blockargs – Additional options for the block, passed as a dictionary
- Raises:
ValueError – if
camerais None- Returns:
a CAMERA block
- Return type:
Camera instance
Camera projection model.
Block ports
- input P:
world points as ndarray(3,N)
- input ξ:
camera pose as an SE3 object
- output p:
image plane points as ndarray(2,N)
- class Visjac_p(*args: Any, **kwargs: Any)[source][source]#
Bases:
FunctionBlockVISJAC_P
Interaction-matrix block for image points.
- Parameters:
camera – camera model
depth (float or ndarray(N)) – point depth, a scalar or one value per point
depthest – use depth estimation, not implemented so it must be False (the default). Give the depth with
depth.blockargs – Additional options for the block, passed as a dictionary
- Raises:
ValueError – if
camerais NoneNotImplementedError – if
depthestis True
- Returns:
a VISJAC_P block
- Return type:
Visjac_p instance
Computes the image Jacobian (interaction matrix) of the image plane points on its input, using the same
depthfor every point, seevisjac_p.Block ports
- input p:
image plane points as ndarray(2,N)
- output J:
image Jacobian as ndarray(2N,6)
Changed in version 2.5.0:
depthest=TrueraisesNotImplementedError. It was accepted but did nothing, so the Jacobian was computed withdepth.- __init__(camera: CentralCamera, depth: float | ndarray = 1, depthest: bool = False, **blockargs: Any) None[source][source]#
- Parameters:
camera – camera model
depth (float or ndarray(N)) – point depth, a scalar or one value per point
depthest – use depth estimation, not implemented so it must be False (the default). Give the depth with
depth.blockargs – Additional options for the block, passed as a dictionary
- Raises:
ValueError – if
camerais NoneNotImplementedError – if
depthestis True
- Returns:
a VISJAC_P block
- Return type:
Visjac_p instance
Computes the image Jacobian (interaction matrix) of the image plane points on its input, using the same
depthfor every point, seevisjac_p.Block ports
- input p:
image plane points as ndarray(2,N)
- output J:
image Jacobian as ndarray(2N,6)
Changed in version 2.5.0:
depthest=TrueraisesNotImplementedError. It was accepted but did nothing, so the Jacobian was computed withdepth.
- class EstPose_p(*args: Any, **kwargs: Any)[source][source]#
Bases:
FunctionBlockESTPOSE_P
Pose-estimation block for image points.
- Parameters:
camera – camera model
P (ndarray(3,N)) – world point coordinates
frame – return pose of points with respect to reference frame which is one of: ‘world’ [default] or ‘camera’
method – pose estimation algorithm one of: ‘iterative’ [default], ‘epnp’, ‘p3p’, ‘ap3p’, ‘ippe’, ‘ippe-square’
blockargs – Additional options for the block, passed as a dictionary
- Returns:
a ESTPOSE_P block
- Return type:
EstPose_p instance
- Raises:
ValueError – if
camerais None orframeis not"world"or"camera"RuntimeError – when the diagram is evaluated, if the pose estimation finds no solution for the points. bdsim prints the block, the time and the input, and stops the run with a “Fatal failure” error caused by this one.
Changed in version 2.5.0:
frameis now passed toestpose. Previously it was accepted but ignored, so the pose was always given with respect to the world frame.Changed in version 2.5.0: A pose estimate that fails raises
RuntimeError. It used to outputNone, which the next block received as its input.- __init__(camera: CentralCamera, P: ndarray, frame: str = 'world', method: str = 'iterative', **blockargs: Any) None[source][source]#
- Parameters:
camera – camera model
P (ndarray(3,N)) – world point coordinates
frame – return pose of points with respect to reference frame which is one of: ‘world’ [default] or ‘camera’
method – pose estimation algorithm one of: ‘iterative’ [default], ‘epnp’, ‘p3p’, ‘ap3p’, ‘ippe’, ‘ippe-square’
blockargs – Additional options for the block, passed as a dictionary
- Returns:
a ESTPOSE_P block
- Return type:
EstPose_p instance
- Raises:
ValueError – if
camerais None orframeis not"world"or"camera"RuntimeError – when the diagram is evaluated, if the pose estimation finds no solution for the points. bdsim prints the block, the time and the input, and stops the run with a “Fatal failure” error caused by this one.
Changed in version 2.5.0:
frameis now passed toestpose. Previously it was accepted but ignored, so the pose was always given with respect to the world frame.Changed in version 2.5.0: A pose estimate that fails raises
RuntimeError. It used to outputNone, which the next block received as its input.
- class ImagePlane(*args: Any, **kwargs: Any)[source][source]#
Bases:
GraphicsBlockIMAGEPLANE
Graphics block that displays points on the image plane.
Create a block that plots image plane coordinates.
- Parameters:
camera – camera model, which draws the image plane
style – style for the points to be plotted, a dict of Matplotlib line properties which is added to the default style, or a format string such as
"r*"labels – not used
grid – draw a grid, defaults to True. Can be a bool or a tuple of options for
grid()retain – keep previous image plane points, defaults to False
watch – add the input signal to the watchlist, defaults to False
init – function to initialize the graphics, called once with the camera when the simulation starts, defaults to None
blockargs – Additional options for the block, passed as a dictionary
- Raises:
ValueError – if
camerais None orstyleis not a str or dict- Returns:
An IMAGEPLANE block
- Return type:
ImagePlane instance
Create a block that plots points on a camera object’s virtual image plane.
Block ports
- input p:
image plane points as ndarray(2,N)
Examples:
IMAGEPLANE(camera) IMAGEPLANE(camera, style="r*") IMAGEPLANE(camera, style=dict(marker="s", markersize=9), retain=True) IMAGEPLANE(camera, grid=False)
Changed in version 2.5.0: Works with the graphics block interface of bdsim 1.5:
watch=Trueno longer fails, only one figure is opened, and nothing is drawn when graphics are turned off.- __init__(camera: CameraBase, style: str | dict[str, Any] | None = None, labels: Any = None, grid: bool | list[Any] | tuple[Any, ...] = True, retain: bool = False, watch: bool = False, init: Callable[[CameraBase], None] | None = None, **blockargs: Any) None[source][source]#
Create a block that plots image plane coordinates.
- Parameters:
camera – camera model, which draws the image plane
style – style for the points to be plotted, a dict of Matplotlib line properties which is added to the default style, or a format string such as
"r*"labels – not used
grid – draw a grid, defaults to True. Can be a bool or a tuple of options for
grid()retain – keep previous image plane points, defaults to False
watch – add the input signal to the watchlist, defaults to False
init – function to initialize the graphics, called once with the camera when the simulation starts, defaults to None
blockargs – Additional options for the block, passed as a dictionary
- Raises:
ValueError – if
camerais None orstyleis not a str or dict- Returns:
An IMAGEPLANE block
- Return type:
ImagePlane instance
Create a block that plots points on a camera object’s virtual image plane.
Block ports
- input p:
image plane points as ndarray(2,N)
Examples:
IMAGEPLANE(camera) IMAGEPLANE(camera, style="r*") IMAGEPLANE(camera, style=dict(marker="s", markersize=9), retain=True) IMAGEPLANE(camera, grid=False)
Changed in version 2.5.0: Works with the graphics block interface of bdsim 1.5:
watch=Trueno longer fails, only one figure is opened, and nothing is drawn when graphics are turned off.