ovis: update camera drawing to new Ogre API

pull/2694/head
Pavel Rojtberg 5 years ago
parent 3ceb414a86
commit 1222d63e93
  1. 5
      modules/ovis/include/opencv2/ovis.hpp
  2. 24
      modules/ovis/src/ovis.cpp

@ -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

@ -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<Camera*>(node.getAttachedObject(name));
if(cam)
{
CV_Assert(subEntityIdx == -1 && "Camera Entities do not have SubEntities");
cam->setMaterial(mat);
return;
}
Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
CV_Assert(ent && "invalid entity");

Loading…
Cancel
Save