From 1222d63e930f9ddfeb9836651c3777b7b0069fbd Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 3 Oct 2020 01:47:30 +0200 Subject: [PATCH] ovis: update camera drawing to new Ogre API --- modules/ovis/include/opencv2/ovis.hpp | 5 +++-- modules/ovis/src/ovis.cpp | 24 ++++++++++-------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/ovis/include/opencv2/ovis.hpp b/modules/ovis/include/opencv2/ovis.hpp index aeff53fae..c471b09e6 100644 --- a/modules/ovis/include/opencv2/ovis.hpp +++ b/modules/ovis/include/opencv2/ovis.hpp @@ -146,19 +146,20 @@ public: /** * convenience method to visualize a camera position * - * the entity uses a material with the same name that can be used to change the line color. * @param name entity name * @param K intrinsic matrix * @param imsize image size * @param zFar far plane in camera coordinates * @param rot @ref Rodrigues vector or 3x3 rotation matrix * @param tvec translation + * @param color line color * @return the extents of the Frustum at far plane, where the top left corner denotes the principal * point offset */ CV_WRAP virtual Rect2d createCameraEntity(const String& name, InputArray K, const Size& imsize, float zFar, InputArray tvec = noArray(), - InputArray rot = noArray()) = 0; + InputArray rot = noArray(), + const Scalar& color = Scalar::all(1)) = 0; /** * creates a point light in the scene diff --git a/modules/ovis/src/ovis.cpp b/modules/ovis/src/ovis.cpp index b5fb01ec4..1ad8bad2c 100644 --- a/modules/ovis/src/ovis.cpp +++ b/modules/ovis/src/ovis.cpp @@ -547,14 +547,9 @@ public: } Rect2d createCameraEntity(const String& name, InputArray K, const Size& imsize, float zFar, - InputArray tvec, InputArray rot) CV_OVERRIDE + InputArray tvec, InputArray rot, const Scalar& color) CV_OVERRIDE { - MaterialPtr mat = MaterialManager::getSingleton().create(name, RESOURCEGROUP_NAME); - Pass* rpass = mat->getTechniques()[0]->getPasses()[0]; - rpass->setEmissive(ColourValue::White); - Camera* cam = sceneMgr->createCamera(name); - cam->setMaterial(mat); cam->setVisible(true); cam->setDebugDisplayEnabled(true); @@ -563,6 +558,15 @@ public: _setCameraIntrinsics(cam, K, imsize); +#if OGRE_VERSION < ((1 << 16) | (12 << 8) | 9) + MaterialPtr mat = MaterialManager::getSingleton().create(name, RESOURCEGROUP_NAME); + Pass* rpass = mat->getTechniques()[0]->getPasses()[0]; + rpass->setEmissive(convertColor(color)); + cam->setMaterial(mat); +#else + cam->setDebugColour(convertColor(color)); +#endif + Quaternion q; Vector3 t; _convertRT(rot, tvec, q, t); @@ -698,14 +702,6 @@ public: MaterialPtr mat = MaterialManager::getSingleton().getByName(value, RESOURCEGROUP_NAME); CV_Assert(mat && "material not found"); - Camera* cam = dynamic_cast(node.getAttachedObject(name)); - if(cam) - { - CV_Assert(subEntityIdx == -1 && "Camera Entities do not have SubEntities"); - cam->setMaterial(mat); - return; - } - Entity* ent = dynamic_cast(node.getAttachedObject(name)); CV_Assert(ent && "invalid entity");