Visual Servoing Platform
version 3.1.0
|
#include <visp3/ar/vpAROgre.h>
Public Member Functions | |
vpAROgre (const vpCameraParameters &cam=vpCameraParameters(), unsigned int width=0, unsigned int height=0, const char *resourcePath=VISP_HAVE_OGRE_RESOURCES_PATH, const char *pluginsPath=VISP_HAVE_OGRE_PLUGINS_PATH) | |
virtual | ~vpAROgre (void) |
void | addResource (const std::string &resourceLocation) |
void | addRotation (const std::string &sceneName, const vpRotationMatrix &wRo) |
bool | continueRendering (void) |
virtual bool | customframeStarted (const Ogre::FrameEvent &evt) |
virtual bool | customframeEnded (const Ogre::FrameEvent &evt) |
virtual void | display (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMw) |
virtual void | display (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMw) |
Ogre::Camera * | getCamera () |
double | getFarClippingDistance () const |
double | getNearClippingDistance () const |
vpTranslationVector | getPosition (const std::string &sceneName) const |
void | getRenderingOutput (vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo) |
Ogre::SceneManager * | getSceneManager () |
virtual void | init (vpImage< unsigned char > &I, bool bufferedKeys=false, bool hidden=false) |
virtual void | init (vpImage< vpRGBa > &I, bool bufferedKeys=false, bool hidden=false) |
bool | isWindowHidden () |
virtual bool | keyPressed (const OIS::KeyEvent &) |
virtual bool | keyReleased (const OIS::KeyEvent &) |
void | load (const std::string &entityName, const std::string &model) |
bool | renderOneFrame (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMw) |
bool | renderOneFrame (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMw) |
void | setCameraParameters (const vpCameraParameters &cameraP) |
void | setFarClippingDistance (const double &dist) |
void | setNearClippingDistance (const double &dist) |
void | setPluginsPath (const char *pluginsPath) |
void | setPosition (const std::string &sceneName, const vpTranslationVector &wTo) |
void | setPosition (const std::string &sceneName, const vpHomogeneousMatrix &wMo) |
void | setResourcePath (const char *resourcePath) |
void | setRotation (const std::string &sceneName, const vpRotationMatrix &wRo) |
void | setScale (const std::string &sceneName, const float factorx, const float factory, const float factorz) |
void | setShowConfigDialog (const bool showConfigDialog) |
void | setVisibility (const std::string &sceneName, bool isVisible) |
void | setWindowName (const Ogre::String &n) |
void | setWindowPosition (const unsigned int win_x, const unsigned int win_y) |
virtual void | windowClosed (Ogre::RenderWindow *rw) |
Protected Member Functions | |
virtual void | init (bool bufferedKeys=false, bool hidden=false) |
virtual void | createCamera (void) |
virtual void | createScene (void) |
virtual void | closeOIS (void) |
virtual bool | updateScene (const Ogre::FrameEvent &) |
virtual bool | processInputEvent (const Ogre::FrameEvent &) |
virtual bool | destroyScene (void) |
virtual void | updateCameraParameters (const vpHomogeneousMatrix &cMo) |
virtual void | updateCameraProjection (void) |
virtual void | updateBackgroundTexture (const vpImage< unsigned char > &I) |
virtual void | updateBackgroundTexture (const vpImage< vpRGBa > &I) |
Protected Attributes | |
Ogre::String | name |
Ogre::Root * | mRoot |
Ogre::Camera * | mCamera |
Ogre::SceneManager * | mSceneMgr |
Ogre::RenderWindow * | mWindow |
Ogre::String | mResourcePath |
Ogre::String | mPluginsPath |
OIS::InputManager * | mInputManager |
OIS::Keyboard * | mKeyboard |
bool | keepOn |
vpImage< vpRGBa > | mImageRGBA |
vpImage< unsigned char > | mImage |
Ogre::HardwarePixelBufferSharedPtr | mPixelBuffer |
Ogre::Rectangle2D * | mBackground |
unsigned int | mBackgroundHeight |
unsigned int | mBackgroundWidth |
unsigned int | mWindowHeight |
unsigned int | mWindowWidth |
bool | windowHidden |
double | mNearClipping |
double | mFarClipping |
vpCameraParameters | mcam |
bool | mshowConfigDialog |
std::list< std::string > | mOptionnalResourceLocation |
Implementation of an augmented reality viewer using Ogre3D 3rd party.
Thus to be enabled this class requires Ogre3D 3rd party installation. Installation instructions are provided here https://visp.inria.fr/3rd_ogre.
This class provides methods to show a 3D scene in a real world. To do that you will need to initialise it with the parameters of your camera, then each frame you will need to compute a pose for your camera and give it to the application. With that information and the image to be shown in background it will set up the 3D scene correspondingly.
Definition at line 90 of file vpAROgre.h.
vpAROgre::vpAROgre | ( | const vpCameraParameters & | cam = vpCameraParameters() , |
unsigned int | width = 0 , |
||
unsigned int | height = 0 , |
||
const char * | resourcePath = VISP_HAVE_OGRE_RESOURCES_PATH , |
||
const char * | pluginsPath = VISP_HAVE_OGRE_PLUGINS_PATH |
||
) |
Constructor.
cam | : Camera parameters. |
width | : Width of the window. |
height | : Height of the window. |
resourcePath | : Path to the resources.cfg file telling Ogre where to look for resources. |
pluginsPath | : Path to the plugins.cfg of plugins_d.cfg files telling Ogre where to look for renderer plugins. |
Definition at line 73 of file vpAROgre.cpp.
|
virtual |
Destructor.
Definition at line 454 of file vpAROgre.cpp.
References closeOIS(), customframeEnded(), customframeStarted(), destroyScene(), keepOn, mRoot, mWindow, processInputEvent(), updateScene(), and windowClosed().
|
inline |
Add optional resource location. Since a resource file cannot be always sufficient to manage multiple location media (depending on the computer and the executable path), this method may be used to add such paths.
resourceLocation | : The resource location (it may be a folder or a zip file). |
Definition at line 126 of file vpAROgre.h.
void vpAROgre::addRotation | ( | const std::string & | sceneName, |
const vpRotationMatrix & | wRo | ||
) |
Add a rotation to a SceneNode.
sceneName | : Name of the SceneNode to rotate. |
wRo | : The rotation matrix representing the rotation to apply. |
Definition at line 712 of file vpAROgre.cpp.
References mSceneMgr.
|
protectedvirtual |
Close the OIS based input manager.
Definition at line 920 of file vpAROgre.cpp.
References mInputManager, and mKeyboard.
Referenced by windowClosed(), and ~vpAROgre().
bool vpAROgre::continueRendering | ( | void | ) |
Ask the program if we can continue to render.
Definition at line 647 of file vpAROgre.cpp.
References keepOn.
|
protectedvirtual |
Create the Ogre camera.
Definition at line 770 of file vpAROgre.cpp.
References mBackground, mBackgroundHeight, mBackgroundWidth, mCamera, mPixelBuffer, mRoot, and mSceneMgr.
Referenced by init().
|
inlineprotectedvirtual |
Build the 3D scene Override this to show what you want
Definition at line 299 of file vpAROgre.h.
Referenced by init().
|
virtual |
Function telling what to do after each frame.
evt | : Frame event to process. |
Definition at line 560 of file vpAROgre.cpp.
Referenced by ~vpAROgre().
|
virtual |
Function telling what to do before each frame. This method is called before every frame rendered by Ogre.
evt | : Frame event to process |
Definition at line 540 of file vpAROgre.cpp.
References mKeyboard, and mWindow.
Referenced by ~vpAROgre().
|
inlineprotectedvirtual |
Clean up the 3D scene.
Definition at line 322 of file vpAROgre.h.
Referenced by ~vpAROgre().
|
virtual |
Display a frame.
I | : Grey level image to show in background. |
cMw | : Camera pose as an homogeneous matrix. |
Definition at line 618 of file vpAROgre.cpp.
References keepOn, mWindow, and renderOneFrame().
Referenced by vpMbHiddenFaces< vpMbtPolygon >::displayOgre().
|
virtual |
Display a frame.
I | : RGBa image to show in background. |
cMw | : Camera pose as an homogeneous matrix. |
Definition at line 633 of file vpAROgre.cpp.
References keepOn, mWindow, and renderOneFrame().
|
inline |
Definition at line 143 of file vpAROgre.h.
Referenced by vpMbHiddenFaces< vpMbtPolygon >::isVisibleOgre().
|
inline |
Get the far distance for clipping.
Definition at line 150 of file vpAROgre.h.
|
inline |
Get the near distance for clipping.
Definition at line 157 of file vpAROgre.h.
vpTranslationVector vpAROgre::getPosition | ( | const std::string & | sceneName | ) | const |
Get position of a SceneNode.
sceneName | : Name of the SceneNode in the scene graph. |
Definition at line 684 of file vpAROgre.cpp.
References mSceneMgr.
void vpAROgre::getRenderingOutput | ( | vpImage< vpRGBa > & | I, |
const vpHomogeneousMatrix & | cMo | ||
) |
Get the result of the rendering loop.
I | : The image on which to copy the result of the rendering loop. |
cMo | : The desired camera pose. |
Definition at line 1037 of file vpAROgre.cpp.
References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), mPixelBuffer, mWindow, vpImage< Type >::resize(), and updateCameraParameters().
|
inline |
Definition at line 163 of file vpAROgre.h.
Referenced by vpMbHiddenFaces< vpMbtPolygon >::initOgre(), and vpMbHiddenFaces< vpMbtPolygon >::isVisibleOgre().
|
virtual |
Initialisation of Ogre with a grey level background.
Load the plugins that are specified in the plugins.cfg or plugins_d.cfg files. These files are located in VISP_HAVE_OGRE_PLUGINS_PATH folder that is defined in vpConfig.h. Note that plugins.cfg file is always considered under Unix platforms. The file plugins_d.cfg is only considered under Windows when the build type is Debug.
Load also the resources that are defined in the resources.cfg file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder that is defined in vpConfig.h.
Create also the grey level background used to display the image.
I | : Image that is displayed in the background. |
bufferedKeys | : If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used. |
hidden | : If true, the created window will be hidden. Note that this functionnality requires Ogre3D 1.8.1 at least. |
vpException::ioError | : If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible. |
Definition at line 115 of file vpAROgre.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), mBackgroundHeight, and mBackgroundWidth.
Referenced by init(), and vpMbHiddenFaces< vpMbtPolygon >::initOgre().
|
virtual |
Initialisation of Ogre with a color background.
Load the plugins that are specified in the plugins.cfg or plugins_d.cfg files. These files are located in VISP_HAVE_OGRE_PLUGINS_PATH folder that is defined in vpConfig.h. Note that plugins.cfg file is always considered under Unix platforms. The file plugins_d.cfg is only considered under Windows when the build type is Debug.
Load also the resources that are defined in the resources.cfg file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder that is defined in vpConfig.h.
Create also a color background used to display the image.
I | : Image that is displayed in the background. |
bufferedKeys | : If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used. |
hidden | : If true, the created window will be hidden. Note that this functionnality requires Ogre3D 1.8.1 at least. |
vpException::ioError | : If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible. |
Definition at line 165 of file vpAROgre.cpp.
References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), init(), mBackgroundHeight, and mBackgroundWidth.
|
protectedvirtual |
Initialisation of Ogre.
Load the plugins that are specified in the plugins.cfg or plugins_d.cfg files. These files are located in VISP_HAVE_OGRE_PLUGINS_PATH folder that is defined in vpConfig.h. Note that plugins.cfg file is always considered under Unix platforms. The file plugins_d.cfg is only considered under Windows when the build type is Debug.
Load also the resources that are defined in the resources.cfg file. This file is located in VISP_HAVE_OGRE_RESOURCES_PATH folder that is defined in vpConfig.h.
bufferedKeys | : If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used. |
hidden | : If true, the created window will be hidden. Note that this functionnality requires Ogre3D 1.8.1 at least. |
vpException::ioError | : If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible. |
Definition at line 211 of file vpAROgre.cpp.
References vpIoTools::checkFilename(), createCamera(), createScene(), vpException::ioError, mBackgroundHeight, mBackgroundWidth, mCamera, mInputManager, mKeyboard, mOptionnalResourceLocation, mPluginsPath, mResourcePath, mRoot, mSceneMgr, mshowConfigDialog, mWindow, mWindowHeight, mWindowWidth, name, vpIoTools::splitChain(), updateCameraProjection(), and windowHidden.
|
inline |
Test if the window is hidden or not.
Definition at line 173 of file vpAROgre.h.
Referenced by vpMbHiddenFaces< vpMbtPolygon >::displayOgre().
|
inlinevirtual |
Default event handler
Definition at line 179 of file vpAROgre.h.
|
inlinevirtual |
Default event handler
Definition at line 183 of file vpAROgre.h.
void vpAROgre::load | ( | const std::string & | entityName, |
const std::string & | model | ||
) |
Load a mesh in the 3D world.
entityName | : Name of the Entity and SceneNode to create. |
model | : 3D model to load. |
Definition at line 659 of file vpAROgre.cpp.
References mSceneMgr.
|
inlineprotectedvirtual |
Check for keyboard, mouse and joystick inputs.
Definition at line 315 of file vpAROgre.h.
Referenced by ~vpAROgre().
bool vpAROgre::renderOneFrame | ( | const vpImage< unsigned char > & | I, |
const vpHomogeneousMatrix & | cMw | ||
) |
Render one frame.
I | : Grey level image to show in background. |
cMw | : Camera pose as an homogeneous matrix. |
Definition at line 584 of file vpAROgre.cpp.
References mRoot, updateBackgroundTexture(), and updateCameraParameters().
Referenced by vpMbHiddenFaces< vpMbtPolygon >::computeScanLineQuery(), and display().
bool vpAROgre::renderOneFrame | ( | const vpImage< vpRGBa > & | I, |
const vpHomogeneousMatrix & | cMw | ||
) |
Render one frame.
I | : RGBa image to show in background. |
cMw | : Camera pose as an homogeneous matrix. |
Definition at line 601 of file vpAROgre.cpp.
References mRoot, updateBackgroundTexture(), and updateCameraParameters().
void vpAROgre::setCameraParameters | ( | const vpCameraParameters & | cameraP | ) |
Set the camera intrinsic parameters
Definition at line 652 of file vpAROgre.cpp.
References mcam.
Referenced by vpMbHiddenFaces< vpMbtPolygon >::initOgre().
|
inline |
Set the far distance for clipping.
dist | : Far clipping value. |
Definition at line 199 of file vpAROgre.h.
Referenced by vpMbTracker::setFarClippingDistance().
|
inline |
Set the near distance for clipping.
dist | : Near clipping value. |
Definition at line 210 of file vpAROgre.h.
Referenced by vpMbTracker::setNearClippingDistance().
|
inline |
Set the plugins path used to locate the plugins.cfg file.
By default, this path is set to VISP_HAVE_OGRE_PLUGINS_PATH defined in vpConfig.h
pluginsPath | : The new plugins path (must not have a terminate /). |
Definition at line 227 of file vpAROgre.h.
void vpAROgre::setPosition | ( | const std::string & | sceneName, |
const vpTranslationVector & | wTo | ||
) |
Change position of a ScneneNode.
sceneName | : Name of the SceneNode to move. |
wTo | : New position of the node (translation between object frame and world frame). |
Definition at line 672 of file vpAROgre.cpp.
References mSceneMgr.
Referenced by setPosition().
void vpAROgre::setPosition | ( | const std::string & | sceneName, |
const vpHomogeneousMatrix & | wMo | ||
) |
Set the position and the orientation of a SceneNode.
sceneName | : Name of the SceneNode to rotate. |
wMo | : The homogeneous matrix representing the rotation and translation to apply. |
Definition at line 730 of file vpAROgre.cpp.
References vpHomogeneousMatrix::extract(), setPosition(), and setRotation().
|
inline |
Set the resource path used to locate the resource.cfg file.
By default, this path is set to VISP_HAVE_OGRE_RESOURCES_PATH defined in vpConfig.h
resourcePath | : The new resource path (must not have a terminate /). |
Definition at line 243 of file vpAROgre.h.
void vpAROgre::setRotation | ( | const std::string & | sceneName, |
const vpRotationMatrix & | wRo | ||
) |
Set the orientation of a SceneNode.
sceneName | : Name of the SceneNode to rotate. |
wRo | : The rotation matrix representing the rotation to apply. |
Definition at line 695 of file vpAROgre.cpp.
References mSceneMgr.
Referenced by setPosition().
void vpAROgre::setScale | ( | const std::string & | sceneName, |
const float | factorx, | ||
const float | factory, | ||
const float | factorz | ||
) |
Scale a SceneNode.
sceneName | : Name of the SceneNode. |
factorx | : Scale factor along the x-axis. |
factory | : Scale factor along the x-axis. |
factorz | : Scale factor along the x-axis. |
Definition at line 759 of file vpAROgre.cpp.
References mSceneMgr.
|
inline |
Enable/Disable the appearance of the config dialog on startup.
showConfigDialog | : if true, shows the dialog window (used to set the display options) |
Definition at line 258 of file vpAROgre.h.
Referenced by vpMbHiddenFaces< vpMbtPolygon >::initOgre().
void vpAROgre::setVisibility | ( | const std::string & | sceneName, |
bool | isVisible | ||
) |
Tell if a SceneNode is shown on the screen or not.
sceneName | : Name of the SceneNode. |
isVisible | : If true we show the node, if false we don't. |
Definition at line 747 of file vpAROgre.cpp.
References mSceneMgr.
|
inline |
Set the name of the window.
n | : Name of the window. |
Definition at line 269 of file vpAROgre.h.
Referenced by vpMbDepthDenseTracker::setOgreVisibilityTest(), vpMbDepthNormalTracker::setOgreVisibilityTest(), vpMbKltTracker::setOgreVisibilityTest(), vpMbEdgeTracker::setOgreVisibilityTest(), vpMbGenericTracker::track(), vpMbDepthDenseTracker::vpMbDepthDenseTracker(), vpMbDepthNormalTracker::vpMbDepthNormalTracker(), vpMbEdgeKltTracker::vpMbEdgeKltTracker(), vpMbEdgeTracker::vpMbEdgeTracker(), and vpMbKltTracker::vpMbKltTracker().
|
inline |
Set the window position in the screen.
vpException::notInitialised | if the window has not been created (using the init() method). |
win_x | : x coordinate of the new top left corner of the window in the screen. |
win_y | : y coordinate of the new top left corner of the window in the screen. |
Definition at line 281 of file vpAROgre.h.
References vpException::notInitialized.
|
protectedvirtual |
Update the texture we see in background with a grey level image.
Definition at line 960 of file vpAROgre.cpp.
References vpImage< Type >::bitmap, mBackgroundHeight, mBackgroundWidth, and mPixelBuffer.
Referenced by renderOneFrame().
Update the texture we see in background with a RGBa image.
Definition at line 980 of file vpAROgre.cpp.
References vpImage< Type >::bitmap, mBackgroundHeight, mBackgroundWidth, and mPixelBuffer.
|
protectedvirtual |
Update Camera parameters from a pose calculation.
Definition at line 1017 of file vpAROgre.cpp.
References mCamera.
Referenced by getRenderingOutput(), and renderOneFrame().
|
protectedvirtual |
Update the projection parameters of the camera.
Definition at line 937 of file vpAROgre.cpp.
References vpCameraParameters::get_px(), vpCameraParameters::get_py(), vpCameraParameters::get_u0(), vpCameraParameters::get_v0(), mBackgroundHeight, mBackgroundWidth, mcam, mCamera, mFarClipping, and mNearClipping.
Referenced by init().
|
inlineprotectedvirtual |
Update the 3D scene
Definition at line 308 of file vpAROgre.h.
Referenced by ~vpAROgre().
|
virtual |
Unattach OIS (Object-oriented Input System library) before window shutdown (very important under Linux).
rw | : RenderWindow to close. |
Definition at line 572 of file vpAROgre.cpp.
References closeOIS(), and mWindow.
Referenced by ~vpAROgre().
|
protected |
Definition at line 370 of file vpAROgre.h.
Referenced by continueRendering(), display(), and ~vpAROgre().
|
protected |
Pointer to the pixel buffer
Definition at line 375 of file vpAROgre.h.
Referenced by createCamera().
|
protected |
Background image
Definition at line 376 of file vpAROgre.h.
Referenced by createCamera(), init(), updateBackgroundTexture(), and updateCameraProjection().
|
protected |
Height of the acquired image
Definition at line 377 of file vpAROgre.h.
Referenced by createCamera(), init(), updateBackgroundTexture(), and updateCameraProjection().
|
protected |
Far Clipping Distance
Definition at line 385 of file vpAROgre.h.
Referenced by setCameraParameters(), and updateCameraProjection().
|
protected |
Application's root
Definition at line 357 of file vpAROgre.h.
Referenced by createCamera(), init(), updateCameraParameters(), and updateCameraProjection().
|
protected |
Near Clipping Distance
Definition at line 384 of file vpAROgre.h.
Referenced by updateCameraProjection().
|
protected |
vpImage to store grabbed image
Definition at line 373 of file vpAROgre.h.
Has the application received a signal to stop(false) or not (true)
Definition at line 372 of file vpAROgre.h.
|
protected |
Path to plugins.cfg
Definition at line 365 of file vpAROgre.h.
Referenced by closeOIS(), and init().
|
protected |
Definition at line 366 of file vpAROgre.h.
Referenced by closeOIS(), customframeStarted(), and init().
|
protected |
|
protected |
if true, shows the dialog window (used to set the display options)
Definition at line 390 of file vpAROgre.h.
Referenced by init().
|
protected |
vpImage to store grabbed image
Definition at line 374 of file vpAROgre.h.
Referenced by createCamera(), getRenderingOutput(), and updateBackgroundTexture().
|
protected |
|
protected |
|
protected |
Name of th Window
Definition at line 356 of file vpAROgre.h.
Referenced by createCamera(), init(), renderOneFrame(), and ~vpAROgre().
|
protected |
Camera
Definition at line 358 of file vpAROgre.h.
Referenced by addRotation(), createCamera(), getPosition(), init(), load(), setPosition(), setRotation(), setScale(), and setVisibility().
|
protected |
|
protected |
Scene manager
Definition at line 359 of file vpAROgre.h.
Referenced by customframeStarted(), display(), getRenderingOutput(), init(), windowClosed(), and ~vpAROgre().
|
protected |
|
protected |
|
protected |
Definition at line 353 of file vpAROgre.h.
Referenced by init().
|
protected |