ViSP  2.6.2

#include <vpAROgre.h>

+ Inheritance diagram for vpAROgre:

Public Member Functions

 vpAROgre (const vpCameraParameters &cam=vpCameraParameters(), unsigned int width=640, unsigned int height=480, const char *resourcePath=VISP_HAVE_OGRE_RESOURCES_PATH, const char *pluginsPath=VISP_HAVE_OGRE_PLUGINS_PATH)
 
virtual void init (vpImage< unsigned char > &I, bool bufferedKeys=false)
 
virtual void init (vpImage< vpRGBa > &I, bool bufferedKeys=false)
 
virtual ~vpAROgre (void)
 
virtual bool customframeStarted (const Ogre::FrameEvent &evt)
 
virtual bool customframeEnded (const Ogre::FrameEvent &evt)
 
virtual bool keyPressed (const OIS::KeyEvent &)
 
virtual bool keyReleased (const OIS::KeyEvent &)
 
virtual void windowClosed (Ogre::RenderWindow *rw)
 
virtual void display (const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMw)
 
virtual void display (const vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMw)
 
void setCameraParameters (const vpCameraParameters &cameraP)
 
void load (const std::string &name, const std::string &model)
 
void setPosition (const std::string &name, const vpTranslationVector &wTo)
 
void setPosition (const std::string &name, const vpHomogeneousMatrix &wMo)
 
vpTranslationVector getPosition (const std::string &name) const
 
void setRotation (const std::string &name, const vpRotationMatrix &wRo)
 
void addRotation (const std::string &name, const vpRotationMatrix &wRo)
 
void setVisibility (const std::string &name, bool isVisible)
 
void setScale (const std::string &name, const float factorx, const float factory, const float factorz)
 
bool continueRendering (void)
 
void getRenderingOutput (vpImage< vpRGBa > &I, vpHomogeneousMatrix &cMo)
 
void setImageWidth (const unsigned int width)
 
void setImageHeight (const unsigned int height)
 
void setShowConfigDialog (const bool showConfigDialog)
 
void setResourcePath (const char *resourcePath)
 
void setPluginsPath (const char *pluginsPath)
 
void addResource (const std::string &resourceLocation)
 
void setWindowPosition (const unsigned int win_x, const unsigned int win_y)
 

Protected Member Functions

virtual void init (bool bufferedKeys=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 updateCameraProjection (void)
 
virtual void updateBackgroundTexture (const vpImage< unsigned char > &I)
 
virtual void updateBackgroundTexture (const vpImage< vpRGBa > &I)
 
virtual void updateCameraParameters (const vpHomogeneousMatrix &cMo)
 

Protected Attributes

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< vpRGBamImageRGBA
 
vpImage< unsigned char > mImage
 
Ogre::HardwarePixelBufferSharedPtr mPixelBuffer
 
Ogre::Rectangle2D * mBackground
 
unsigned int mHeight
 
unsigned int mWidth
 
vpCameraParameters mcam
 
bool mshowConfigDialog
 
std::list< std::string > mOptionnalResourceLocation
 

Detailed Description

Implementation of an augmented reality viewer.

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.

Examples:
AROgre.cpp, AROgreBasic.cpp, HelloWorldOgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 90 of file vpAROgre.h.

Constructor & Destructor Documentation

vpAROgre::vpAROgre ( const vpCameraParameters cam = vpCameraParameters(),
unsigned int  width = 640,
unsigned int  height = 480,
const char *  resourcePath = VISP_HAVE_OGRE_RESOURCES_PATH,
const char *  pluginsPath = VISP_HAVE_OGRE_PLUGINS_PATH 
)

Constructor.

Parameters
cam: Camera parameters.
width: Width of the grabbed image.
height: Height of the grabbed image.
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.
Examples:
HelloWorldOgreAdvanced.cpp.

Definition at line 75 of file vpAROgre.cpp.

References keepOn, mcam, mHeight, mOptionnalResourceLocation, mPluginsPath, mResourcePath, mshowConfigDialog, and mWidth.

vpAROgre::~vpAROgre ( void  )
virtual

Destructor.

Definition at line 344 of file vpAROgre.cpp.

References closeOIS(), destroyScene(), mRoot, mWindow, and windowClosed().

Member Function Documentation

void vpAROgre::addResource ( const std::string &  resourceLocation)
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.

Warning
To be effective, this method must be called before the init() one.
Parameters
resourceLocation: The resource location (it may be a folder or a zip file).

Definition at line 233 of file vpAROgre.h.

void vpAROgre::addRotation ( const std::string &  name,
const vpRotationMatrix wRo 
)

Add a rotation to a SceneNode.

Parameters
name: Name of the SceneNode to rotate.
wRo: The rotation matrix representing the rotation to apply.

Definition at line 582 of file vpAROgre.cpp.

References mSceneMgr.

void vpAROgre::closeOIS ( void  )
protectedvirtual

Close the OIS based input manager.

Warning
This method is only to call if OIS is installed and detected during ViSP configuration stage.

Definition at line 786 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.

Returns
True if nothing stopped the rendering loop.

Definition at line 509 of file vpAROgre.cpp.

References keepOn.

void vpAROgre::createCamera ( void  )
protectedvirtual

Create the Ogre camera.

Definition at line 645 of file vpAROgre.cpp.

References mCamera, and mSceneMgr.

Referenced by init().

virtual void vpAROgre::createScene ( void  )
inlineprotectedvirtual

Build the 3D scene Override this to show what you want

Examples:
AROgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 264 of file vpAROgre.h.

Referenced by init().

bool vpAROgre::customframeEnded ( const Ogre::FrameEvent &  evt)
virtual

Function telling what to do after each frame.

Parameters
evt: Frame event to process.
Returns
True if everything went well.
Examples:
AROgre.cpp, and HelloWorldOgreAdvanced.cpp.

Definition at line 442 of file vpAROgre.cpp.

bool vpAROgre::customframeStarted ( const Ogre::FrameEvent &  evt)
virtual

Function telling what to do before each frame. This method is called before every frame rendered by Ogre.

Parameters
evt: Frame event to process
Returns
True if everything went well

Definition at line 422 of file vpAROgre.cpp.

References mKeyboard, and mWindow.

virtual bool vpAROgre::destroyScene ( void  )
inlineprotectedvirtual

Clean up the 3D scene.

Returns
Always true.

Definition at line 287 of file vpAROgre.h.

Referenced by ~vpAROgre().

void vpAROgre::display ( const vpImage< unsigned char > &  I,
const vpHomogeneousMatrix cMw 
)
virtual

Display a frame.

Parameters
I: Grey level image to show in background.
cMw: Camera pose as an homogeneous matrix.

Definition at line 465 of file vpAROgre.cpp.

References keepOn, mRoot, mWindow, updateBackgroundTexture(), and updateCameraParameters().

void vpAROgre::display ( const vpImage< vpRGBa > &  I,
const vpHomogeneousMatrix cMw 
)
virtual

Display a frame.

Parameters
I: RGBa image to show in background.
cMw: Camera pose as an homogeneous matrix.

Definition at line 488 of file vpAROgre.cpp.

References keepOn, mRoot, mWindow, updateBackgroundTexture(), and updateCameraParameters().

vpTranslationVector vpAROgre::getPosition ( const std::string &  name) const

Get position of a SceneNode.

Parameters
name: Name of the SceneNode in the scene graph.
Returns
The position of the node.

Definition at line 553 of file vpAROgre.cpp.

References mSceneMgr.

void vpAROgre::getRenderingOutput ( vpImage< vpRGBa > &  I,
vpHomogeneousMatrix cMo 
)

Get the result of the rendering loop.

Parameters
I: The image on which to copy the result of the rendering loop.
cMo: The desired camera pose.

Definition at line 898 of file vpAROgre.cpp.

References vpImage< Type >::bitmap, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), mPixelBuffer, mWindow, vpImage< Type >::resize(), and updateCameraParameters().

void vpAROgre::init ( vpImage< unsigned char > &  I,
bool  bufferedKeys = false 
)
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.

Parameters
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.
Exceptions
vpException::ioError: If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible.
Examples:
AROgreBasic.cpp, and HelloWorldOgre.cpp.

Definition at line 125 of file vpAROgre.cpp.

Referenced by init().

void vpAROgre::init ( vpImage< vpRGBa > &  I,
bool  bufferedKeys = false 
)
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.

Parameters
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.
Exceptions
vpException::ioError: If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible.

Definition at line 166 of file vpAROgre.cpp.

References init().

void vpAROgre::init ( bool  bufferedKeys = false)
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.

Parameters
bufferedKeys: If true, use of buffered input for the keyboard (see Ogre documentation). Note that this parameter is only useful if OIS is used.
Exceptions
vpException::ioError: If the required plugins.cfg / plugins_d.cfg or resources.cfg files are not accessible.

Definition at line 203 of file vpAROgre.cpp.

References vpIoTools::checkFilename(), createCamera(), createScene(), vpException::ioError, mCamera, mInputManager, mKeyboard, mOptionnalResourceLocation, mPluginsPath, mResourcePath, mRoot, mSceneMgr, mshowConfigDialog, mWindow, and updateCameraProjection().

virtual bool vpAROgre::keyPressed ( const OIS::KeyEvent &  )
inlinevirtual

Default event handler

Definition at line 125 of file vpAROgre.h.

virtual bool vpAROgre::keyReleased ( const OIS::KeyEvent &  )
inlinevirtual

Default event handler

Definition at line 129 of file vpAROgre.h.

void vpAROgre::load ( const std::string &  name,
const std::string &  model 
)

Load a mesh in the 3D world.

Parameters
name: Name of the Entity and SceneNode to create.
model: 3D model to load.

Definition at line 527 of file vpAROgre.cpp.

References mSceneMgr.

virtual bool vpAROgre::processInputEvent ( const Ogre::FrameEvent &  )
inlineprotectedvirtual

Check for keyboard, mouse and joystick inputs.

Returns
Always true.
Examples:
AROgre.cpp.

Definition at line 280 of file vpAROgre.h.

void vpAROgre::setCameraParameters ( const vpCameraParameters cameraP)

Set the camera intrinsic parameters

Definition at line 517 of file vpAROgre.cpp.

References mcam.

void vpAROgre::setImageHeight ( const unsigned int  height)
inline

Set the height of the grabbed image.

Warning
To be effective, this method must be called before the init() one.
Parameters
height: Height of the grabbed image.

Definition at line 180 of file vpAROgre.h.

void vpAROgre::setImageWidth ( const unsigned int  width)
inline

Set the width of the grabbed image.

Warning
To be effective, this method must be called before the init() one.
Parameters
width: Width of the grabbed image.

Definition at line 169 of file vpAROgre.h.

void vpAROgre::setPluginsPath ( const char *  pluginsPath)
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

Warning
To be effective, this method must be called before the init() one.
Parameters
pluginsPath: The new plugins path (must not have a terminate /).

Definition at line 218 of file vpAROgre.h.

void vpAROgre::setPosition ( const std::string &  name,
const vpTranslationVector wTo 
)

Change position of a ScneneNode.

Parameters
name: Name of the SceneNode to move.
wTo: New position of the node (translation between object frame and world frame).

Definition at line 540 of file vpAROgre.cpp.

References mSceneMgr.

Referenced by setPosition().

void vpAROgre::setPosition ( const std::string &  name,
const vpHomogeneousMatrix wMo 
)

Set the position and the orientation of a SceneNode.

Parameters
name: Name of the SceneNode to rotate.
wMo: The homogeneous matrix representing the rotation and translation to apply.

Definition at line 604 of file vpAROgre.cpp.

References vpHomogeneousMatrix::extract(), setPosition(), and setRotation().

void vpAROgre::setResourcePath ( const char *  resourcePath)
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

Warning
To be effective, this method must be called before the init() one.
Parameters
resourcePath: The new resource path (must not have a terminate /).

Definition at line 205 of file vpAROgre.h.

void vpAROgre::setRotation ( const std::string &  name,
const vpRotationMatrix wRo 
)

Set the orientation of a SceneNode.

Parameters
name: Name of the SceneNode to rotate.
wRo: The rotation matrix representing the rotation to apply.

Definition at line 564 of file vpAROgre.cpp.

References mSceneMgr.

Referenced by setPosition().

void vpAROgre::setScale ( const std::string &  name,
const float  factorx,
const float  factory,
const float  factorz 
)

Scale a SceneNode.

Parameters
name: 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 634 of file vpAROgre.cpp.

References mSceneMgr.

void vpAROgre::setShowConfigDialog ( const bool  showConfigDialog)
inline

Enable/Disable the apparition of the config dialog on startup.

Warning
To be effective, this method must be called before the init() one.
Parameters
showConfigDialog: if true, shows the dialog window (used to set the display options)

Definition at line 192 of file vpAROgre.h.

void vpAROgre::setVisibility ( const std::string &  name,
bool  isVisible 
)

Tell if a SceneNode is shown on the screen or not.

Parameters
name: Name of the SceneNode.
isVisible: If true we show the node, if false we don't.

Definition at line 622 of file vpAROgre.cpp.

References mSceneMgr.

void vpAROgre::setWindowPosition ( const unsigned int  win_x,
const unsigned int  win_y 
)
inline

Set the window position in the screen.

Exceptions
vpException::notInitialisedif the window has not been created (using the init() method).
Parameters
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 248 of file vpAROgre.h.

References vpException::notInitialized.

void vpAROgre::updateBackgroundTexture ( const vpImage< unsigned char > &  I)
protectedvirtual

Update the texture we see in background with a grey level image.

Definition at line 824 of file vpAROgre.cpp.

References vpImage< Type >::bitmap, mHeight, mPixelBuffer, and mWidth.

Referenced by display().

void vpAROgre::updateBackgroundTexture ( const vpImage< vpRGBa > &  I)
protectedvirtual

Update the texture we see in background with a RGBa image.

Definition at line 843 of file vpAROgre.cpp.

References vpImage< Type >::bitmap, mHeight, mPixelBuffer, and mWidth.

void vpAROgre::updateCameraParameters ( const vpHomogeneousMatrix cMw)
protectedvirtual

Update Camera parameters from a pose calculation.

Definition at line 879 of file vpAROgre.cpp.

References mCamera.

Referenced by display(), and getRenderingOutput().

void vpAROgre::updateCameraProjection ( void  )
protectedvirtual

Update the projection parameters of the camera.

Definition at line 802 of file vpAROgre.cpp.

References vpCameraParameters::get_px(), vpCameraParameters::get_py(), vpCameraParameters::get_u0(), vpCameraParameters::get_v0(), mcam, mCamera, mHeight, and mWidth.

Referenced by init().

virtual bool vpAROgre::updateScene ( const Ogre::FrameEvent &  )
inlineprotectedvirtual

Update the 3D scene

Returns
Always true.

Definition at line 273 of file vpAROgre.h.

void vpAROgre::windowClosed ( Ogre::RenderWindow *  rw)
virtual

Unattach OIS (Object-oriented Input System library) before window shutdown (very important under Linux).

Warning
This method is only available if OIS is installed and detected during ViSP configuration stage.
Parameters
rw: RenderWindow to close.

Definition at line 454 of file vpAROgre.cpp.

References closeOIS(), and mWindow.

Referenced by ~vpAROgre().

Member Data Documentation

bool vpAROgre::keepOn
protected

Definition at line 326 of file vpAROgre.h.

Referenced by continueRendering(), display(), and vpAROgre().

Ogre::Rectangle2D* vpAROgre::mBackground
protected

Pointer to the pixel buffer

Definition at line 330 of file vpAROgre.h.

vpCameraParameters vpAROgre::mcam
protected

Width of the acquired image

Definition at line 335 of file vpAROgre.h.

Referenced by setCameraParameters(), updateCameraProjection(), and vpAROgre().

Ogre::Camera* vpAROgre::mCamera
protected

Application's root

Definition at line 313 of file vpAROgre.h.

Referenced by createCamera(), init(), updateCameraParameters(), and updateCameraProjection().

unsigned int vpAROgre::mHeight
protected

Background image

Definition at line 331 of file vpAROgre.h.

Referenced by updateBackgroundTexture(), updateCameraProjection(), and vpAROgre().

vpImage<unsigned char> vpAROgre::mImage
protected

vpImage to store grabbed image

Definition at line 328 of file vpAROgre.h.

vpImage<vpRGBa> vpAROgre::mImageRGBA
protected

Has the application received a signal to stop(false) or not (true)

Definition at line 327 of file vpAROgre.h.

OIS::InputManager* vpAROgre::mInputManager
protected

Path to plugins.cfg

Definition at line 321 of file vpAROgre.h.

Referenced by closeOIS(), and init().

OIS::Keyboard* vpAROgre::mKeyboard
protected

Definition at line 322 of file vpAROgre.h.

Referenced by closeOIS(), customframeStarted(), and init().

std::list<std::string> vpAROgre::mOptionnalResourceLocation
protected

if true, shows the dialog window (used to set the display options)

Definition at line 339 of file vpAROgre.h.

Referenced by init(), and vpAROgre().

Ogre::HardwarePixelBufferSharedPtr vpAROgre::mPixelBuffer
protected

vpImage to store grabbed image

Definition at line 329 of file vpAROgre.h.

Referenced by getRenderingOutput(), and updateBackgroundTexture().

Ogre::String vpAROgre::mPluginsPath
protected

Path to resources.cfg

Definition at line 317 of file vpAROgre.h.

Referenced by init(), and vpAROgre().

Ogre::String vpAROgre::mResourcePath
protected

Display window

Definition at line 316 of file vpAROgre.h.

Referenced by init(), and vpAROgre().

Ogre::Root* vpAROgre::mRoot
protected

Definition at line 312 of file vpAROgre.h.

Referenced by display(), init(), and ~vpAROgre().

Ogre::SceneManager* vpAROgre::mSceneMgr
protected
bool vpAROgre::mshowConfigDialog
protected

The intrinsic camera parameters

Definition at line 337 of file vpAROgre.h.

Referenced by init(), and vpAROgre().

unsigned int vpAROgre::mWidth
protected

Height of the acquired image

Definition at line 332 of file vpAROgre.h.

Referenced by updateBackgroundTexture(), updateCameraProjection(), and vpAROgre().

Ogre::RenderWindow* vpAROgre::mWindow
protected

Scene manager

Definition at line 315 of file vpAROgre.h.

Referenced by customframeStarted(), display(), getRenderingOutput(), init(), windowClosed(), and ~vpAROgre().