Merge pull request #2694 from paroj:ovisup

pull/2696/head
Alexander Alekhin 5 years ago
commit 00fad37aab
  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 * 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 name entity name
* @param K intrinsic matrix * @param K intrinsic matrix
* @param imsize image size * @param imsize image size
* @param zFar far plane in camera coordinates * @param zFar far plane in camera coordinates
* @param rot @ref Rodrigues vector or 3x3 rotation matrix * @param rot @ref Rodrigues vector or 3x3 rotation matrix
* @param tvec translation * @param tvec translation
* @param color line color
* @return the extents of the Frustum at far plane, where the top left corner denotes the principal * @return the extents of the Frustum at far plane, where the top left corner denotes the principal
* point offset * point offset
*/ */
CV_WRAP virtual Rect2d createCameraEntity(const String& name, InputArray K, const Size& imsize, CV_WRAP virtual Rect2d createCameraEntity(const String& name, InputArray K, const Size& imsize,
float zFar, InputArray tvec = noArray(), 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 * creates a point light in the scene

@ -547,14 +547,9 @@ public:
} }
Rect2d createCameraEntity(const String& name, InputArray K, const Size& imsize, float zFar, 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); Camera* cam = sceneMgr->createCamera(name);
cam->setMaterial(mat);
cam->setVisible(true); cam->setVisible(true);
cam->setDebugDisplayEnabled(true); cam->setDebugDisplayEnabled(true);
@ -563,6 +558,15 @@ public:
_setCameraIntrinsics(cam, K, imsize); _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; Quaternion q;
Vector3 t; Vector3 t;
_convertRT(rot, tvec, q, t); _convertRT(rot, tvec, q, t);
@ -698,14 +702,6 @@ public:
MaterialPtr mat = MaterialManager::getSingleton().getByName(value, RESOURCEGROUP_NAME); MaterialPtr mat = MaterialManager::getSingleton().getByName(value, RESOURCEGROUP_NAME);
CV_Assert(mat && "material not found"); 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)); Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
CV_Assert(ent && "invalid entity"); CV_Assert(ent && "invalid entity");

Loading…
Cancel
Save