Loading modules/ovis/include/opencv2/ovis.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ enum MaterialProperty MATERIAL_LINE_WIDTH, MATERIAL_OPACITY, MATERIAL_EMISSIVE, MATERIAL_DIFFUSE, MATERIAL_TEXTURE0, MATERIAL_TEXTURE = MATERIAL_TEXTURE0, MATERIAL_TEXTURE1, Loading modules/ovis/src/ovis.cpp +16 −19 Original line number Diff line number Diff line Loading @@ -171,6 +171,14 @@ static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name) return *mo->getParentSceneNode(); } static ColourValue convertColor(const Scalar& val) { // BGR 0..255 (uchar) to RGB 0..1 ColourValue ret = ColourValue(val[2], val[1], val[0]) / 255; ret.saturate(); return ret; } struct Application : public OgreBites::ApplicationContext, public OgreBites::InputListener { Ptr<LogManager> logMgr; Loading Loading @@ -335,11 +343,7 @@ public: { camman.reset(new OgreBites::CameraMan(camNode)); camman->setStyle(OgreBites::CS_ORBIT); #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5) camman->setFixedYaw(false); #else camNode->setFixedYawAxis(true, Vector3::NEGATIVE_UNIT_Y); // OpenCV +Y in Ogre CS #endif } if (!app->sceneMgr) Loading Loading @@ -512,10 +516,7 @@ public: { // hide background plane bgplane->setVisible(false); // BGRA as uchar ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255; rWin->getViewport(0)->setBackgroundColour(_color); rWin->getViewport(0)->setBackgroundColour(convertColor(color)); } void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE Loading Loading @@ -579,7 +580,6 @@ public: const Scalar& specularColour) CV_OVERRIDE { Light* light = sceneMgr->createLight(name); light->setDirection(Vector3::NEGATIVE_UNIT_Z); // convert to BGR light->setDiffuseColour(ColourValue(diffuseColour[2], diffuseColour[1], diffuseColour[0])); light->setSpecularColour(ColourValue(specularColour[2], specularColour[1], specularColour[0])); Loading Loading @@ -838,9 +838,7 @@ public: void fixCameraYawAxis(bool useFixed, InputArray _up) CV_OVERRIDE { #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5) if(camman) camman->setFixedYaw(useFixed); #endif Vector3 up = Vector3::NEGATIVE_UNIT_Y; if (!_up.empty()) Loading Loading @@ -977,8 +975,8 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) CV_Assert(mat); Pass* rpass = mat->getTechniques()[0]->getPasses()[0]; ColourValue col; ColourValue col; switch (prop) { case MATERIAL_POINT_SIZE: Loading @@ -991,17 +989,16 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) rpass->setSceneBlending(SBT_TRANSPARENT_ALPHA); rpass->setDepthWriteEnabled(false); break; case MATERIAL_DIFFUSE: col = convertColor(val); col.a = rpass->getDiffuse().a; rpass->setDiffuse(col); break; case MATERIAL_EMISSIVE: col = ColourValue(val[2], val[1], val[0]) / 255; // BGR as uchar col.saturate(); rpass->setEmissive(col); rpass->setEmissive(convertColor(val)); break; case MATERIAL_LINE_WIDTH: #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 2) rpass->setLineWidth(val[0]); #else CV_Error(Error::StsError, "needs OGRE 1.11.2+ for this"); #endif break; default: CV_Error(Error::StsBadArg, "invalid or non Scalar property"); Loading Loading
modules/ovis/include/opencv2/ovis.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ enum MaterialProperty MATERIAL_LINE_WIDTH, MATERIAL_OPACITY, MATERIAL_EMISSIVE, MATERIAL_DIFFUSE, MATERIAL_TEXTURE0, MATERIAL_TEXTURE = MATERIAL_TEXTURE0, MATERIAL_TEXTURE1, Loading
modules/ovis/src/ovis.cpp +16 −19 Original line number Diff line number Diff line Loading @@ -171,6 +171,14 @@ static SceneNode& _getSceneNode(SceneManager* sceneMgr, const String& name) return *mo->getParentSceneNode(); } static ColourValue convertColor(const Scalar& val) { // BGR 0..255 (uchar) to RGB 0..1 ColourValue ret = ColourValue(val[2], val[1], val[0]) / 255; ret.saturate(); return ret; } struct Application : public OgreBites::ApplicationContext, public OgreBites::InputListener { Ptr<LogManager> logMgr; Loading Loading @@ -335,11 +343,7 @@ public: { camman.reset(new OgreBites::CameraMan(camNode)); camman->setStyle(OgreBites::CS_ORBIT); #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5) camman->setFixedYaw(false); #else camNode->setFixedYawAxis(true, Vector3::NEGATIVE_UNIT_Y); // OpenCV +Y in Ogre CS #endif } if (!app->sceneMgr) Loading Loading @@ -512,10 +516,7 @@ public: { // hide background plane bgplane->setVisible(false); // BGRA as uchar ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255; rWin->getViewport(0)->setBackgroundColour(_color); rWin->getViewport(0)->setBackgroundColour(convertColor(color)); } void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE Loading Loading @@ -579,7 +580,6 @@ public: const Scalar& specularColour) CV_OVERRIDE { Light* light = sceneMgr->createLight(name); light->setDirection(Vector3::NEGATIVE_UNIT_Z); // convert to BGR light->setDiffuseColour(ColourValue(diffuseColour[2], diffuseColour[1], diffuseColour[0])); light->setSpecularColour(ColourValue(specularColour[2], specularColour[1], specularColour[0])); Loading Loading @@ -838,9 +838,7 @@ public: void fixCameraYawAxis(bool useFixed, InputArray _up) CV_OVERRIDE { #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5) if(camman) camman->setFixedYaw(useFixed); #endif Vector3 up = Vector3::NEGATIVE_UNIT_Y; if (!_up.empty()) Loading Loading @@ -977,8 +975,8 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) CV_Assert(mat); Pass* rpass = mat->getTechniques()[0]->getPasses()[0]; ColourValue col; ColourValue col; switch (prop) { case MATERIAL_POINT_SIZE: Loading @@ -991,17 +989,16 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) rpass->setSceneBlending(SBT_TRANSPARENT_ALPHA); rpass->setDepthWriteEnabled(false); break; case MATERIAL_DIFFUSE: col = convertColor(val); col.a = rpass->getDiffuse().a; rpass->setDiffuse(col); break; case MATERIAL_EMISSIVE: col = ColourValue(val[2], val[1], val[0]) / 255; // BGR as uchar col.saturate(); rpass->setEmissive(col); rpass->setEmissive(convertColor(val)); break; case MATERIAL_LINE_WIDTH: #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 2) rpass->setLineWidth(val[0]); #else CV_Error(Error::StsError, "needs OGRE 1.11.2+ for this"); #endif break; default: CV_Error(Error::StsBadArg, "invalid or non Scalar property"); Loading