42#include <visp3/core/vpConfig.h>
52#include <visp3/ar/vpAROgre.h>
53#include <visp3/core/vpCameraParameters.h>
54#include <visp3/core/vpHomogeneousMatrix.h>
55#include <visp3/core/vpImage.h>
56#include <visp3/sensor/vp1394TwoGrabber.h>
57#include <visp3/sensor/vpV4l2Grabber.h>
59#if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)
60#include <opencv2/highgui/highgui.hpp>
61#elif defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)
62#include <opencv2/videoio/videoio.hpp>
65#ifdef ENABLE_VISP_NAMESPACE
69#if defined(VISP_HAVE_OGRE)
71#ifndef DOXYGEN_SHOULD_SKIP_THIS
73class vpAROgreAdvanced :
public vpAROgre
77 Ogre::AnimationState *mAnimationState;
80 vpAROgreAdvanced(
const vpCameraParameters &cam = vpCameraParameters(),
unsigned int width = 640,
81 unsigned int height = 480)
84 mAnimationState =
nullptr;
90 mSceneMgr->setAmbientLight(Ogre::ColourValue(
static_cast<float>(0.6),
static_cast<float>(0.6),
static_cast<float>(0.6)));
91 Ogre::Light *light = mSceneMgr->createLight();
92 light->setDiffuseColour(1.0, 1.0, 1.0);
93 light->setSpecularColour(1.0, 1.0, 1.0);
95#if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0))
96 light->setPosition(-5, -5, 10);
98 Ogre::SceneNode *spotLightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
99 spotLightNode->attachObject(light);
100 spotLightNode->setPosition(Ogre::Vector3(-5, -5, 10));
102 light->setType(Ogre::Light::LT_POINT);
103 light->setAttenuation((Ogre::Real)100, (Ogre::Real)1.0, (Ogre::Real)0.045, (Ogre::Real)0.0075);
105 light->setCastShadows(
true);
108 Ogre::Entity *robot = mSceneMgr->createEntity(
"Robot",
"robot.mesh");
110 Ogre::SceneNode *RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(
"Robot");
113 RobotNode->attachObject(robot);
114 RobotNode->scale((Ogre::Real)0.001, (Ogre::Real)0.001, (Ogre::Real)0.001);
115 RobotNode->pitch(Ogre::Degree(180));
116 RobotNode->yaw(Ogre::Degree(-90));
117 robot->setCastShadows(
true);
118 mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
122 mAnimationState = robot->getAnimationState(
"Idle");
124 mAnimationState->setLoop(
true);
126 mAnimationState->setEnabled(
true);
133 mAnimationState->addTime(evt.timeSinceLastFrame);
144#if defined(VISP_HAVE_OGRE)
145#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || defined(VISP_HAVE_OPENCV) && \
146 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
147 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
156#if defined(VISP_HAVE_V4L2)
164#elif defined(VISP_HAVE_DC1394)
172#elif defined(VISP_HAVE_OPENCV) && \
173 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
174 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
176 cv::VideoCapture grabber(0);
177 if (!grabber.isOpened()) {
178 std::cout <<
"Failed to open the camera" << std::endl;
189 double u0 = I.getWidth() / 2;
190 double v0 = I.getHeight() / 2;
197 vpAROgreAdvanced ogre(cam, I.getWidth(), I.getHeight());
202 while (ogre.continueRendering()) {
204#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394)
206#elif defined(VISP_HAVE_OPENCV) && \
207 (((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
208 ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)))
216 ogre.display(I, cMo);
219 std::cout <<
"You need an available framegrabber to run this example" << std::endl;
222 std::cout <<
"You need Ogre3D to run this example" << std::endl;
227 std::cout <<
"Catch an exception: " <<
e << std::endl;
231 std::cout <<
"Catch an exception " << std::endl;
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void acquire(vpImage< unsigned char > &I)
void open(vpImage< unsigned char > &I)
Implementation of an augmented reality viewer using Ogre3D 3rd party.
virtual bool customframeEnded(const Ogre::FrameEvent &evt)
virtual void createScene(void)
Generic class defining intrinsic camera parameters.
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
Definition of the vpImage class member functions.
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
void open(vpImage< unsigned char > &I)
void acquire(vpImage< unsigned char > &I)