Visual Servoing Platform
version 3.3.0 under development (2020-02-17)
|
#include <visp3/robot/vpImageSimulator.h>
Public Types | |
enum | vpColorPlan { COLORED, GRAY_SCALED } |
enum | vpInterpolationType { SIMPLE, BILINEAR_INTERPOLATION } |
Public Member Functions | |
vpImageSimulator (const vpColorPlan &col=COLORED) | |
vpImageSimulator (const vpImageSimulator &text) | |
virtual | ~vpImageSimulator () |
vpImageSimulator & | operator= (const vpImageSimulator &sim) |
void | init (const vpImage< unsigned char > &I, vpColVector *X) |
void | init (const vpImage< vpRGBa > &I, vpColVector *X) |
void | init (const char *file_image, vpColVector *X) |
void | init (const vpImage< unsigned char > &I, const std::vector< vpPoint > &X) |
void | init (const vpImage< vpRGBa > &I, const std::vector< vpPoint > &X) |
void | init (const char *file_image, const std::vector< vpPoint > &X) |
void | setCameraPosition (const vpHomogeneousMatrix &cMt) |
void | setInterpolationType (const vpInterpolationType interplt) |
void | getImage (vpImage< unsigned char > &I, const vpCameraParameters &cam) |
void | getImage (vpImage< vpRGBa > &I, const vpCameraParameters &cam) |
void | getImage (vpImage< unsigned char > &I, vpImage< unsigned char > &Isrc, const vpCameraParameters &cam) |
void | getImage (vpImage< vpRGBa > &I, vpImage< vpRGBa > &Isrc, const vpCameraParameters &cam) |
void | getImage (vpImage< unsigned char > &I, const vpCameraParameters &cam, vpMatrix &zBuffer) |
void | getImage (vpImage< vpRGBa > &I, const vpCameraParameters &cam, vpMatrix &zBuffer) |
std::vector< vpColVector > | get3DcornersTextureRectangle () |
void | setCleanPreviousImage (const bool &clean, const vpColor &color=vpColor::white) |
void | setBackGroundTexture (const vpImage< unsigned char > &Iback) |
Static Public Member Functions | |
static void | getImage (vpImage< unsigned char > &I, std::list< vpImageSimulator > &list, const vpCameraParameters &cam) |
static void | getImage (vpImage< vpRGBa > &I, std::list< vpImageSimulator > &list, const vpCameraParameters &cam) |
Friends | |
VISP_EXPORT std::ostream & | operator<< (std::ostream &os, const vpImageSimulator &) |
Class which enables to project an image in the 3D space and get the view of a virtual camera.
The image is represented by a rectangular image whose corners coordinates are known in the 3D frame linked to the 3D rectangle.
The 3D rectangle is positionned relative to a virtual camera (represented by its intrinsic parameters). Indeed, the pose has to be given by the user of the class.
And finally, the view of the virtual camera is given by the geImage() method.
You can use a colored or a gray scaled image.
To avoid the aliasing especially when the camera is very near from the image plane, a bilinear interpolation can be done for every pixels which have to be filled in. By default this functionality is not used because it consumes lot of time.
The following example explain how to use the class.
Definition at line 142 of file vpImageSimulator.h.
Enumerator | |
---|---|
COLORED | |
GRAY_SCALED |
Definition at line 145 of file vpImageSimulator.h.
Enumerator | |
---|---|
SIMPLE | |
BILINEAR_INTERPOLATION |
Definition at line 147 of file vpImageSimulator.h.
|
explicit |
Basic constructor.
You can choose if you want to use a colored or gray scaled image.
col | : Enable to choose the color space to use for the image which is projected. |
By default the class uses colored images.
Definition at line 62 of file vpImageSimulator.cpp.
References vpColVector::resize().
vpImageSimulator::vpImageSimulator | ( | const vpImageSimulator & | text | ) |
Copy constructor
Definition at line 99 of file vpImageSimulator.cpp.
References vpColVector::resize(), and setCameraPosition().
|
virtual |
Basic destructor.
Definition at line 148 of file vpImageSimulator.cpp.
std::vector< vpColVector > vpImageSimulator::get3DcornersTextureRectangle | ( | ) |
Definition at line 1546 of file vpImageSimulator.cpp.
void vpImageSimulator::getImage | ( | vpImage< unsigned char > & | I, |
const vpCameraParameters & | cam | ||
) |
Get the view of the virtual camera. Be careful, the image I is modified. The projected image is not added as an overlay!
I | : The image used to store the result. |
cam | : The parameters of the virtual camera. |
Definition at line 189 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, COLORED, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpRect::getTop(), vpImage< Type >::getWidth(), GRAY_SCALED, vpRGBa::R, and vpImagePoint::set_ij().
Referenced by vpVirtualGrabber::acquire(), vpWireFrameSimulator::getExternalImage(), and vpWireFrameSimulator::getInternalImage().
void vpImageSimulator::getImage | ( | vpImage< vpRGBa > & | I, |
const vpCameraParameters & | cam | ||
) |
Get the view of the virtual camera. Be careful, the image I is modified. The projected image is not added as an overlay!
I | : The image used to store the result. |
cam | : The parameters of the virtual camera. |
Definition at line 382 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, COLORED, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpRect::getTop(), vpImage< Type >::getWidth(), GRAY_SCALED, vpRGBa::R, and vpImagePoint::set_ij().
void vpImageSimulator::getImage | ( | vpImage< unsigned char > & | I, |
vpImage< unsigned char > & | Isrc, | ||
const vpCameraParameters & | cam | ||
) |
Get the view of the virtual camera. Be careful, the image I is modified. The projected image is not added as an overlay! In this method you specify directly the image which is projected.
I | : The image used to store the result. |
Isrc | : The image which is projected into . |
cam | : The parameters of the virtual camera. |
Definition at line 256 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpRect::getTop(), vpImage< Type >::getWidth(), vpRGBa::R, and vpImagePoint::set_ij().
void vpImageSimulator::getImage | ( | vpImage< vpRGBa > & | I, |
vpImage< vpRGBa > & | Isrc, | ||
const vpCameraParameters & | cam | ||
) |
Get the view of the virtual camera. Be carefull, the image I is modified. The projected image is not added as an overlay! In this method you specify directly the image which is projected.
I | : The image used to store the result. |
Isrc | : The image which is projected into . |
cam | : The parameters of the virtual camera. |
Definition at line 445 of file vpImageSimulator.cpp.
References vpImage< Type >::bitmap, vpPixelMeterConversion::convertPoint(), vpRect::getBottom(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpRect::getTop(), vpImage< Type >::getWidth(), and vpImagePoint::set_ij().
void vpImageSimulator::getImage | ( | vpImage< unsigned char > & | I, |
const vpCameraParameters & | cam, | ||
vpMatrix & | zBuffer | ||
) |
Get the view of the virtual camera. Be careful, the image I is modified. The projected image is not added as an overlay!
To take into account the projection of several images, a matrix is given as argument. This matrix contains the z coordinates of all the pixel of the image in the camera frame. During the projection, the pixels are updated if there is no other plan between the camera and the projected image. The matrix is updated in this case.
I | : The image used to store the result. |
cam | : The parameters of the virtual camera. |
zBuffer | : A matrix containing the z coordinates of the pixels of the image |
Definition at line 313 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, COLORED, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpArray2D< Type >::getCols(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpArray2D< Type >::getRows(), vpRect::getTop(), vpImage< Type >::getWidth(), GRAY_SCALED, vpMatrixException::incorrectMatrixSizeError, vpRGBa::R, and vpImagePoint::set_ij().
void vpImageSimulator::getImage | ( | vpImage< vpRGBa > & | I, |
const vpCameraParameters & | cam, | ||
vpMatrix & | zBuffer | ||
) |
Get the view of the virtual camera. Be carefull, the image I is modified. The projected image is not added as an overlay!
To take into account the projection of several images, a matrix is given as argument. This matrix contains the z coordinates of all the pixel of the image in the camera frame. During the projection, the pixels are updated if there is no other plan between the camera and the projected image. The matrix is updated in this case.
I | : The image used to store the result. |
cam | : The parameters of the virtual camera. |
zBuffer | : A matrix containing the z coordinates of the pixels of the image |
Definition at line 502 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, COLORED, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpArray2D< Type >::getCols(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpArray2D< Type >::getRows(), vpRect::getTop(), vpImage< Type >::getWidth(), GRAY_SCALED, vpMatrixException::incorrectMatrixSizeError, vpRGBa::R, and vpImagePoint::set_ij().
|
static |
Get the view of the virtual camera. Be careful, the image I is modified. The projected image is not added as an overlay! With this method, a list of image is projected into the image. Thus, you have to initialise a list of vpImageSimulator. Then you store them into a vpList. And finally with this method you project them into the image . The depth of the 3D scene is managed such as an image in foreground hides an image background.
The following example shows how to use the method:
I | : The image used to store the result |
list | : List of vpImageSimulator to project |
cam | : The parameters of the virtual camera |
Definition at line 669 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, COLORED, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpRect::getTop(), vpImage< Type >::getWidth(), GRAY_SCALED, vpRGBa::R, and vpImagePoint::set_ij().
|
static |
Get the view of the virtual camera. Be carefull, the image I is modified. The projected image is not added as an overlay!
With this method, a list of image is projected into the image. Thus, you have to initialise a list of vpImageSimulator. Then you store them into a vpList. And finally with this method you project them into the image . The depth of the 3D scene is managed such as an image in foreground hides an image background.
The following example shows how to use the method:
I | : The image used to store the result |
list | : List of vpImageSimulator to project |
cam | : The parameters of the virtual camera |
Definition at line 867 of file vpImageSimulator.cpp.
References vpRGBa::B, vpImage< Type >::bitmap, COLORED, vpPixelMeterConversion::convertPoint(), vpRGBa::G, vpRect::getBottom(), vpImage< Type >::getHeight(), vpRect::getLeft(), vpRect::getRight(), vpRect::getTop(), vpImage< Type >::getWidth(), GRAY_SCALED, vpRGBa::R, and vpImagePoint::set_ij().
void vpImageSimulator::init | ( | const vpImage< unsigned char > & | I, |
vpColVector * | X_ | ||
) |
Initialise the image thanks to an image and a table of vector containing the 3D coordinates of the image's corners.
The table must have a size of 4!
I | : The image which is projected. |
X_ | : table of the 3D coordinates corresponding to the image corners. |
Definition at line 1081 of file vpImageSimulator.cpp.
References vpImageConvert::convert().
Referenced by vpVirtualGrabber::vpVirtualGrabber().
void vpImageSimulator::init | ( | const vpImage< vpRGBa > & | I, |
vpColVector * | X_ | ||
) |
Initialise the image thanks to an image and a table of vector containing the 3D coordinates of the image's corners.
The table must have a size of 4!
I | : The image which is projected. |
X_ | : table of the 3D coordinates corresponding to the image corners. |
Definition at line 1102 of file vpImageSimulator.cpp.
References vpImageConvert::convert().
void vpImageSimulator::init | ( | const char * | file_image, |
vpColVector * | X_ | ||
) |
Initialise the image thanks to an image whose adress is given by and a table of vector containing the 3D coordinates of the image's corners.
The table must have a size of 4!
file_image | : The adress of an image file. |
X_ | : table of the 3D coordinates corresponding to the image corners. |
Definition at line 1125 of file vpImageSimulator.cpp.
References vpImageIo::read().
void vpImageSimulator::init | ( | const vpImage< unsigned char > & | I, |
const std::vector< vpPoint > & | X_ | ||
) |
Initialise the image thanks to an image and a table of vector containing the 3D coordinates of the image's corners.
vpException::dimensionError | if the _X vector is not of size 4. |
I | : The image which is projected. |
X_ | : Vector of the 3D coordinates in the object frame (oX, oY, oZ) corresponding to the image corners. |
Definition at line 1148 of file vpImageSimulator.cpp.
References vpImageConvert::convert(), vpException::dimensionError, and vpColVector::resize().
Initialise the image thanks to an image and a table of vector containing the 3D coordinates of the image's corners.
vpException::dimensionError | if the X_ vector is not of size 4. |
I | : The image which is projected. |
X_ | : Vector of the 3D coordinates in the object frame (oX, oY, oZ) corresponding to the image corners. |
Definition at line 1180 of file vpImageSimulator.cpp.
References vpImageConvert::convert(), vpException::dimensionError, and vpColVector::resize().
void vpImageSimulator::init | ( | const char * | file_image, |
const std::vector< vpPoint > & | X_ | ||
) |
Initialise the image thanks to an image whose adress is given by and a table of vector containing the 3D coordinates of the image's corners.
vpException::dimensionError | if the X_ vector is not of size 4. |
file_image | : The adress of an image file. |
X_ | : Vector of the 3D coordinates in the object frame (oX, oY, oZ) corresponding to the image corners. |
Definition at line 1215 of file vpImageSimulator.cpp.
References BILINEAR_INTERPOLATION, vpMeterPixelConversion::convertPoint(), vpException::dimensionError, vpImagePoint::get_u(), vpImagePoint::get_v(), vpImage< Type >::getHeight(), vpImage< Type >::getValue(), vpImage< Type >::getWidth(), vpImageIo::read(), vpColVector::resize(), vpRect::setBottom(), vpRect::setLeft(), vpRect::setRight(), vpRect::setTop(), and SIMPLE.
vpImageSimulator & vpImageSimulator::operator= | ( | const vpImageSimulator & | sim | ) |
Definition at line 157 of file vpImageSimulator.cpp.
References setCameraPosition().
|
inline |
This function allows to set the background to a texture instead of the default black background.
Iback | : Image/Texture for the background |
Definition at line 272 of file vpImageSimulator.h.
void vpImageSimulator::setCameraPosition | ( | const vpHomogeneousMatrix & | cMt_ | ) |
Enable to set the position of the 3D plane relative to the virtual camera.
cMt_ | : The pose of the plane relative to the virtual camera. |
Definition at line 968 of file vpImageSimulator.cpp.
References vpColVector::crossProd(), vpColVector::dotProd(), vpHomogeneousMatrix::extract(), vpColVector::frobeniusNorm(), vpPolygon3D::getClippedPolygon(), vpPolygon3D::NEAR_CLIPPING, vpImagePoint::set_i(), and vpImagePoint::set_j().
Referenced by vpVirtualGrabber::acquire(), vpWireFrameSimulator::getExternalImage(), vpWireFrameSimulator::getInternalImage(), operator=(), and vpImageSimulator().
|
inline |
As it can be time consuming to reset all the image to a default baground value, this function enable to reset only the pixel which changed the previous time.
By default this functionality is disabled. and the background color is white.
clean | : Enable the reset method. |
color | : Color of the back ground. |
Definition at line 260 of file vpImageSimulator.h.
Referenced by vpVirtualGrabber::acquire().
|
inline |
Definition at line 231 of file vpImageSimulator.h.
Referenced by vpVirtualGrabber::vpVirtualGrabber().
|
friend |
Definition at line 1554 of file vpImageSimulator.cpp.