WireFrameSimulator¶
- class WireFrameSimulator(self)¶
Bases:
pybind11_object
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require third party libraries to be used.
The simulator uses several frames to display the scene in the image. There are:
The world frame : This is a fixed frame used to compute the position of the other frames against each other. By default this frame is positionned at the same location as the initial object frame position.
The object frame : It is the frame linked to the object.
The camera frame : It is the frame linked to the main camera.
The external camera frame : It is the frame which corresponds to one external point of view.
The most used homogeneous matrices which describes the displacement between two frames are :
fMo which is the displacement between the world frame and the object frame.
cMo which is the displacement between the main camera frame and the object frame.
cextMf which is the displacement between one external camera frame and the world frame.
The following picture summarize all the previous information.
<unparsed image <doxmlparser.compound.docImageType object at 0x7f421776c9d0>>
The simulator uses .bnd or .wrl files as 3D scene descriptors. Several scenes can be found in the data folder which is in the directory where you build ViSP.
You can move the main external view while clicking in the image. The left click enables to turn, the middle button enables to zoom and the left to translate along x and y.
The simulator is able to take into account to camera parameters. You can set the internal and external cameras parameters thanks to a vpCameraParameters .
The following example shows how it is easy to use.
#include <visp3/core/vpImage.h> #include <visp3/robot/vpWireFrameSimulator.h> #ifdef ENABLE_VISP_NAMESPACE using namespace VISP_NAMESPACE_NAME; #endif int main() { vpWireFrameSimulator sim; vpImage<vpRGBa> Iint(480, 640, vpRGBa(255)); vpImage<vpRGBa> Iext(480, 640, vpRGBa(255)); //Set the type of scene to use sim.initScene(vpWireFrameSimulator::PLATE, vpWireFrameSimulator::D_STANDARD); //Set the initial pose of the camera sim.setCameraPositionRelObj(vpHomogeneousMatrix(0, 0, 0.5, vpMath::rad(0), vpMath::rad(10), 0)); //Set the desired pose of the camera (for the internal view) sim.setDesiredCameraPosition(vpHomogeneousMatrix(0.0, 0, 0.5, 0, 0, 0)); //Set the pose of the reference frame (for the external view) sim.setExternalCameraPosition(vpHomogeneousMatrix(0.1, 0, 0.2, 0, 0, 0)); //Set the camera parameters vpCameraParameters camera(1000, 1000, 320, 240); sim.setInternalCameraParameters(camera); sim.setExternalCameraParameters(camera); //Get the internal view sim.getInternalImage(Iint); //Get the external view sim.getExternalImage(Iext); return 0; }
Basic constructor.
Set the path to the scene files (*.bnd and *.sln) used by the simulator. If the path set in vpConfig.h in VISP_SCENES_DIR macro is not valid, the path is set from the VISP_SCENES_DIR environment variable that the user has to set.
Methods
Basic constructor.
Delete the history of the main camera position which are displayed in the external views.
Overloaded function.
Overloaded function.
Get the main external camera's position relative to the the world reference frame.
Overloaded function.
Overloaded function.
Overloaded function.
Get the pose between the object and the camera.
Get the homogeneous matrices cMo stored to display the camera trajectory.
Get the pose between the object and the fixed world frame.
Get the homogeneous matrices fMo stored to display the camera trajectory.
Overloaded function.
Set the color used to display the camera in the external view.
Set the transformation between the camera frame and the object frame.
Set the position of the the world reference frame relative to the camera.
Set the parameter which enables to choose the size of the main camera in the external camera views.
Set the color used to display the camera trajectory in the external view.
Set the color used to display the object at the current position.
Set the transformation between the desired position of the camera and the object.
Set the color used to display the object at the desired position.
Enable or disable the displaying of the camera trajectory in the main external camera view.
Set the internal camera parameters.
Set the external camera point of view.
Specify the thickness of the graphics drawings.
Set the internal camera parameters.
Set the maximum number of main camera's positions which are stored.
Set the pose between the object and the fixed world frame.
Inherited Methods
Operators
__doc__
Basic constructor.
__module__
Attributes
CIRCLE
CT_LINE
CT_POINT
CUBE
CYLINDER
DIAMOND
D_CIRCLE
D_STANDARD
D_TOOL
PIPE
PLAN
PLATE
POINT_CLOUD
RECTANGLE
ROAD
SMALL_PLATE
SPHERE
SQUARE_10CM
THREE_LINES
THREE_PTS
TIRE
TRAPEZOID
__annotations__
- class CameraTrajectoryDisplayType(self, value: int)¶
Bases:
pybind11_object
Values:
CT_LINE
CT_POINT
- __init__(self)¶
Basic constructor.
Set the path to the scene files (*.bnd and *.sln) used by the simulator. If the path set in vpConfig.h in VISP_SCENES_DIR macro is not valid, the path is set from the VISP_SCENES_DIR environment variable that the user has to set.
- deleteCameraPositionHistory(self) None ¶
Delete the history of the main camera position which are displayed in the external views.
- displayTrajectory(*args, **kwargs)¶
Overloaded function.
displayTrajectory(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageGray, list_cMo: list[visp._visp.core.HomogeneousMatrix], list_fMo: list[visp._visp.core.HomogeneousMatrix], camMf: visp._visp.core.HomogeneousMatrix) -> None
Display a trajectory thanks to a list of homogeneous matrices which give the position of the camera relative to the object and the position of the object relative to the world reference frame. The trajectory is projected into the view of an external camera whose position is given in parameter.
The two lists must have the same size of homogeneous matrices must have the same size.
- Parameters:
- I
The image where the trajectory is displayed.
- list_cMo
The homogeneous matrices list containing the position of the camera relative to the object.
- list_fMo
The homogeneous matrices list containing the position of the object relative to the world reference frame.
displayTrajectory(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageRGBa, list_cMo: list[visp._visp.core.HomogeneousMatrix], list_fMo: list[visp._visp.core.HomogeneousMatrix], camMf: visp._visp.core.HomogeneousMatrix) -> None
Display a trajectory thanks to a list of homogeneous matrices which give the position of the camera relative to the object and the position of the object relative to the world reference frame. The trajectory is projected into the view of an external camera whose position is given in parameter.
The two lists must have the same size of homogeneous matrices must have the same size.
- Parameters:
- I
The image where the trajectory is displayed.
- list_cMo
The homogeneous matrices list containing the position of the camera relative to the object.
- list_fMo
The homogeneous matrices list containing the position of the object relative to the world reference frame.
- getExternalCameraParameters(*args, **kwargs)¶
Overloaded function.
getExternalCameraParameters(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageGray) -> visp._visp.core.CameraParameters
Get the parameters of the virtual external camera.
- Parameters:
- I
The image used to display the view of the camera.
- Returns:
It returns the camera parameters.
getExternalCameraParameters(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageRGBa) -> visp._visp.core.CameraParameters
Get the parameters of the virtual external camera.
- Parameters:
- I
The image used to display the view of the camera.
- Returns:
It returns the camera parameters.
- getExternalCameraPosition(self) visp._visp.core.HomogeneousMatrix ¶
Get the main external camera’s position relative to the the world reference frame.
- Returns:
the main external camera position relative to the the world reference frame.
- getExternalImage(*args, **kwargs)¶
Overloaded function.
getExternalImage(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageGray) -> None
Get the external view. It corresponds to the view of the scene from a reference frame you have to set.
Warning
: The objects are displayed thanks to overlays. The image I is not modified.
- Parameters:
- I
The image where the external view is displayed.
getExternalImage(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageGray, camMf: visp._visp.core.HomogeneousMatrix) -> None
Get an external view. The point of view is set thanks to the pose between the camera camMf and the fixed world frame.
Warning
: The objects are displayed thanks to overlays. The image I is not modified.
- Parameters:
- I
The image where the external view is displayed.
getExternalImage(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageRGBa) -> None
Get the external view. It corresponds to the view of the scene from a reference frame you have to set.
Warning
: The objects are displayed thanks to overlays. The image I is not modified.
- Parameters:
- I
The image where the external view is displayed.
getExternalImage(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageRGBa, camMf: visp._visp.core.HomogeneousMatrix) -> None
Get an external view. The point of view is set thanks to the pose between the camera camMf and the fixed world frame.
Warning
: The objects are displayed thanks to overlays. The image I is not modified.
- Parameters:
- I
The image where the external view is displayed.
- getInternalCameraParameters(*args, **kwargs)¶
Overloaded function.
getInternalCameraParameters(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageGray) -> visp._visp.core.CameraParameters
Get the parameters of the virtual internal camera.
- Parameters:
- I
The image used to display the view of the camera.
- Returns:
It returns the camera parameters.
getInternalCameraParameters(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageRGBa) -> visp._visp.core.CameraParameters
Get the parameters of the virtual internal camera.
- Parameters:
- I
The image used to display the view of the camera.
- Returns:
It returns the camera parameters.
- getInternalImage(*args, **kwargs)¶
Overloaded function.
getInternalImage(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageGray) -> None
Get the internal view ie the view of the camera.
Warning
: The objects are displayed thanks to overlays. The image I is not modified.
- Parameters:
- I
The image where the internal view is displayed.
getInternalImage(self: visp._visp.robot.WireFrameSimulator, I: visp._visp.core.ImageRGBa) -> None
Get the internal view ie the view of the camera.
Warning
: The objects are displayed thanks to overlays. The image I is not modified.
- Parameters:
- I
The image where the internal view is displayed.
- get_cMo(self) visp._visp.core.HomogeneousMatrix ¶
Get the pose between the object and the camera.
- Returns:
The pose between between the object and the camera.
- get_cMo_History(self) list[visp._visp.core.HomogeneousMatrix] ¶
Get the homogeneous matrices cMo stored to display the camera trajectory.
- Returns:
A tuple containing:
cMo_history: The list of the homogeneous matrices cMo.
- get_fMo(self) visp._visp.core.HomogeneousMatrix ¶
Get the pose between the object and the fixed world frame.
- Returns:
The pose between the object and the fixed world frame.
- get_fMo_History(self) list[visp._visp.core.HomogeneousMatrix] ¶
Get the homogeneous matrices fMo stored to display the camera trajectory.
- Returns:
A tuple containing:
fMo_history: The list of the homogeneous matrices fMo.
- initScene(*args, **kwargs)¶
Overloaded function.
initScene(self: visp._visp.robot.WireFrameSimulator, obj: visp._visp.robot.WireFrameSimulator.SceneObject, desiredObject: visp._visp.robot.WireFrameSimulator.SceneDesiredObject) -> None
initScene(self: visp._visp.robot.WireFrameSimulator, obj: str, desiredObject: str) -> None
Initialize the simulator. It enables to choose the type of scene which will be used to display the object at the current position and at the desired position.
Here you can use the scene you want. You have to set the path to a .bnd or a .wrl file which is a 3D model file.
- Parameters:
- obj
Path to the scene file you want to use.
initScene(self: visp._visp.robot.WireFrameSimulator, obj: visp._visp.robot.WireFrameSimulator.SceneObject) -> None
initScene(self: visp._visp.robot.WireFrameSimulator, obj: str) -> None
Initialize the simulator. It enables to choose the type of scene which will be used to display the object at the current position. The object at the desired position is not displayed.
Here you can use the scene you want. You have to set the path to a .bnd or a .wrl file which is a 3D model file.
- Parameters:
- obj
Path to the scene file you want to use.
initScene(self: visp._visp.robot.WireFrameSimulator, obj: visp._visp.robot.WireFrameSimulator.SceneObject, desiredObject: visp._visp.robot.WireFrameSimulator.SceneDesiredObject, imObj: list[visp._visp.robot.ImageSimulator]) -> None
initScene(self: visp._visp.robot.WireFrameSimulator, obj: str, desiredObject: str, imObj: list[visp._visp.robot.ImageSimulator]) -> None
Initialize the simulator. It enables to choose the type of scene which will be used to display the object at the current position and at the desired position.
Here you can use the scene you want. You have to set the path to a .bnd or a .wrl file which is a 3D model file.
It is also possible to add a list of vpImageSimulator instances. They will be automatically projected into the image. The position of the four corners have to be given in the object frame.
- Parameters:
- obj
Path to the scene file you want to use.
- imObj
A list of vpImageSimulator instances.
initScene(self: visp._visp.robot.WireFrameSimulator, obj: visp._visp.robot.WireFrameSimulator.SceneObject, imObj: list[visp._visp.robot.ImageSimulator]) -> None
initScene(self: visp._visp.robot.WireFrameSimulator, obj: str, imObj: list[visp._visp.robot.ImageSimulator]) -> None
Initialize the simulator. It enables to choose the type of scene which will be used to display the object at the current position. The object at the desired position is not displayed.
Here you can use the scene you want. You have to set the path to a .bnd or a .wrl file which is a 3D model file.
It is also possible to add a list of vpImageSimulator instances. They will be automatically projected into the image. The position of the four corners have to be given in the object frame.
- Parameters:
- obj
Path to the scene file you want to use.
- imObj
A list of vpImageSimulator instances.
- setCameraColor(self, col: visp._visp.core.Color) None ¶
Set the color used to display the camera in the external view.
- Parameters:
- col: visp._visp.core.Color¶
The desired color.
- setCameraPositionRelObj(self, cMo_: visp._visp.core.HomogeneousMatrix) None ¶
Set the transformation between the camera frame and the object frame.
- Parameters:
- cMo_: visp._visp.core.HomogeneousMatrix¶
The pose of the object in the camera frame.
- setCameraPositionRelWorld(self, fMc_: visp._visp.core.HomogeneousMatrix) None ¶
Set the position of the the world reference frame relative to the camera.
- Parameters:
- fMc_: visp._visp.core.HomogeneousMatrix¶
The pose of the camera.
- setCameraSizeFactor(self, factor: float) None ¶
Set the parameter which enables to choose the size of the main camera in the external camera views. By default this parameter is set to 1.
- setCameraTrajectoryColor(self, col: visp._visp.core.Color) None ¶
Set the color used to display the camera trajectory in the external view.
- Parameters:
- col: visp._visp.core.Color¶
The desired color.
- setCameraTrajectoryDisplayType(self, camTraj_type: visp._visp.robot.WireFrameSimulator.CameraTrajectoryDisplayType) None ¶
- setCurrentViewColor(self, col: visp._visp.core.Color) None ¶
Set the color used to display the object at the current position.
- Parameters:
- col: visp._visp.core.Color¶
The desired color.
- setDesiredCameraPosition(self, cdMo_: visp._visp.core.HomogeneousMatrix) None ¶
Set the transformation between the desired position of the camera and the object.
- Parameters:
- cdMo_: visp._visp.core.HomogeneousMatrix¶
The position of the object in the desired camera frame
- setDesiredViewColor(self, col: visp._visp.core.Color) None ¶
Set the color used to display the object at the desired position.
- Parameters:
- col: visp._visp.core.Color¶
The desired color.
- setDisplayCameraTrajectory(self, do_display: bool) None ¶
Enable or disable the displaying of the camera trajectory in the main external camera view.
By default the trajectory is displayed.
- setExternalCameraParameters(self, cam: visp._visp.core.CameraParameters) None ¶
Set the internal camera parameters.
- Parameters:
- cam: visp._visp.core.CameraParameters¶
The desired camera parameters.
- setExternalCameraPosition(self, cam_Mf: visp._visp.core.HomogeneousMatrix) None ¶
Set the external camera point of view.
- Parameters:
- cam_Mf: visp._visp.core.HomogeneousMatrix¶
The pose of the external camera relative to the world reference frame.
- setInternalCameraParameters(self, cam: visp._visp.core.CameraParameters) None ¶
Set the internal camera parameters.
- Parameters:
- cam: visp._visp.core.CameraParameters¶
The desired camera parameters.
- setNbPtTrajectory(self, nbPt: int) None ¶
Set the maximum number of main camera’s positions which are stored. Those position can be displayed in the external camera field of view. By default this parameter is set to 1000.
- set_fMo(self, fMo_: visp._visp.core.HomogeneousMatrix) None ¶
Set the pose between the object and the fixed world frame.
- Parameters:
- fMo_: visp._visp.core.HomogeneousMatrix¶
The pose between the object and the fixed world frame.