Skip to content

Commit cd7a6ea

Browse files
committed
ovis: add ENTITY_AABB_WORLD property and implement getEntityProperty
1 parent 31dff1e commit cd7a6ea

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

modules/ovis/include/opencv2/ovis.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ enum EntityProperty
4545
{
4646
ENTITY_MATERIAL,
4747
ENTITY_SCALE,
48+
ENTITY_AABB_WORLD
4849
};
4950

5051
/**
@@ -106,6 +107,14 @@ class CV_EXPORTS_W WindowScene {
106107
/// @overload
107108
CV_WRAP virtual void setEntityProperty(const String& name, int prop, const String& value) = 0;
108109

110+
/**
111+
* get the property of an entity
112+
* @param name entity name
113+
* @param prop @ref EntityProperty
114+
* @param value the value
115+
*/
116+
CV_WRAP virtual void getEntityProperty(const String& name, int prop, OutputArray value) = 0;
117+
109118
/**
110119
* convenience method to visualize a camera position
111120
*

modules/ovis/src/ovis.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,35 @@ class WindowSceneImpl : public WindowScene
563563
node.setScale(value[0], value[1], value[2]);
564564
}
565565

566+
void getEntityProperty(const String& name, int prop, OutputArray value)
567+
{
568+
SceneNode& node = _getSceneNode(sceneMgr, name);
569+
switch(prop)
570+
{
571+
case ENTITY_SCALE:
572+
{
573+
Vector3 s = node.getScale();
574+
Mat_<Real>(1, 3, s.ptr()).copyTo(value);
575+
return;
576+
}
577+
case ENTITY_AABB_WORLD:
578+
{
579+
Entity* ent = dynamic_cast<Entity*>(node.getAttachedObject(name));
580+
CV_Assert(ent && "invalid entity");
581+
AxisAlignedBox aabb = ent->getWorldBoundingBox(true);
582+
Vector3 mn = aabb.getMinimum();
583+
Vector3 mx = aabb.getMaximum();
584+
Mat_<Real> ret(2, 3);
585+
Mat_<Real>(1, 3, mn.ptr()).copyTo(ret.row(0));
586+
Mat_<Real>(1, 3, mx.ptr()).copyTo(ret.row(1));
587+
ret.copyTo(value);
588+
return;
589+
}
590+
default:
591+
CV_Error(Error::StsBadArg, "unsupported property");
592+
}
593+
}
594+
566595
void _createBackground()
567596
{
568597
String name = "_" + sceneMgr->getName() + "_DefaultBackground";

0 commit comments

Comments
 (0)