#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/ar/vpAROgre.h>
#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpImage.h>
#include <visp3/sensor/vp1394TwoGrabber.h>
#include <visp3/sensor/vpV4l2Grabber.h>
#if (VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)
#include <opencv2/highgui/highgui.hpp>
#elif (VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO)
#include <opencv2/videoio/videoio.hpp>
#endif
#ifdef ENABLE_VISP_NAMESPACE
#endif
#if defined(VISP_HAVE_OGRE)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
class vpAROgreAdvanced :
public vpAROgre
{
private:
Ogre::AnimationState *mAnimationState;
public:
unsigned int height = 480)
{
mAnimationState = nullptr;
}
protected:
void createScene()
{
mSceneMgr->setAmbientLight(Ogre::ColourValue((float)0.6, (float)0.6, (float)0.6));
Ogre::Light *light = mSceneMgr->createLight();
light->setDiffuseColour(1.0, 1.0, 1.0);
light->setSpecularColour(1.0, 1.0, 1.0);
#if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0))
#else
Ogre::SceneNode *spotLightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
spotLightNode->attachObject(light);
spotLightNode->setPosition(Ogre::Vector3(-5, -5, 10));
#endif
light->setType(Ogre::Light::LT_POINT);
light->setAttenuation((Ogre::Real)100, (Ogre::Real)1.0, (Ogre::Real)0.045, (Ogre::Real)0.0075);
light->setCastShadows(true);
Ogre::Entity *robot = mSceneMgr->createEntity("Robot", "robot.mesh");
Ogre::SceneNode *RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot");
RobotNode->attachObject(robot);
RobotNode->scale((Ogre::Real)0.001, (Ogre::Real)0.001, (Ogre::Real)0.001);
RobotNode->pitch(Ogre::Degree(180));
RobotNode->yaw(Ogre::Degree(-90));
robot->setCastShadows(true);
mSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
mAnimationState = robot->getAnimationState("Idle");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
}
bool customframeEnded(const Ogre::FrameEvent &evt)
{
mAnimationState->addTime(evt.timeSinceLastFrame);
return true;
}
};
#endif
#endif
int main()
{
try {
#if defined(VISP_HAVE_OGRE)
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394) || \
((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI)) || \
((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
#if defined(VISP_HAVE_V4L2)
#elif defined(VISP_HAVE_DC1394)
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
cv::VideoCapture grabber(0);
if (!grabber.isOpened()) {
std::cout << "Failed to open the camera" << std::endl;
return EXIT_FAILURE;
}
cv::Mat frame;
grabber >> frame;
#endif
double px = 565;
double py = 565;
cMo[2][3] = 0.5;
ogre.init(I);
while (ogre.continueRendering()) {
#if defined(VISP_HAVE_V4L2) || defined(VISP_HAVE_DC1394)
#elif ((VISP_HAVE_OPENCV_VERSION < 0x030000) && defined(HAVE_OPENCV_HIGHGUI))|| ((VISP_HAVE_OPENCV_VERSION >= 0x030000) && defined(HAVE_OPENCV_VIDEOIO))
grabber >> frame;
#endif
ogre.display(I, cMo);
}
#else
std::cout << "You need an available framegrabber to run this example" << std::endl;
#endif
#else
std::cout << "You need Ogre3D to run this example" << std::endl;
#endif
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
catch (...) {
std::cout << "Catch an exception " << std::endl;
return EXIT_FAILURE;
}
}
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.
void setPosition(const std::string &sceneName, const vpTranslationVector &wTo)
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)
unsigned int getWidth() const
unsigned int getHeight() const
Class that is a wrapper over the Video4Linux2 (V4L2) driver.
void open(vpImage< unsigned char > &I)
void acquire(vpImage< unsigned char > &I)