Skip to content

Commit 0bb0989

Browse files
committed
ovis: drop SCENE_RENDER_FLOAT which is replaced by getCompositorTexture
the latter allows explicitly specifying channel nr/ format. Also we no longer have to manually manage an extra rendertarget any more.
1 parent c4c2e85 commit 0bb0989

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

modules/ovis/include/opencv2/ovis.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ enum SceneSettings
2424
SCENE_INTERACTIVE = 2,
2525
/// draw coordinate system crosses for debugging
2626
SCENE_SHOW_CS_CROSS = 4,
27-
/// @ref WindowScene::getScreenshot returns images as CV_32FC4 instead of CV_8UC3
28-
SCENE_RENDER_FLOAT = 8,
2927
/// Apply anti-aliasing. The first window determines the setting for all windows.
30-
SCENE_AA = 16
28+
SCENE_AA = 8
3129
};
3230

3331
enum MaterialProperty

modules/ovis/src/ovis.cpp

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ class WindowSceneImpl : public WindowScene
264264
Ptr<OgreBites::CameraMan> camman;
265265
Ptr<Rectangle2D> bgplane;
266266

267-
Ogre::RenderTarget* frameSrc;
268267
Ogre::RenderTarget* depthRTT;
269268
public:
270269
WindowSceneImpl(Ptr<Application> app, const String& _title, const Size& sz, int flags)
@@ -324,18 +323,6 @@ class WindowSceneImpl : public WindowScene
324323
}
325324

326325
rWin->addViewport(cam);
327-
frameSrc = rWin;
328-
329-
if (flags & SCENE_RENDER_FLOAT)
330-
{
331-
// also render into an offscreen texture
332-
// currently this draws everything twice, but we spare the float->byte conversion for display
333-
TexturePtr tex = TextureManager::getSingleton().createManual(
334-
title + "_rt", RESOURCEGROUP_NAME, TEX_TYPE_2D, sz.width, sz.height, 0, PF_FLOAT32_RGBA,
335-
TU_RENDERTARGET);
336-
frameSrc = tex->getBuffer()->getRenderTarget();
337-
frameSrc->addViewport(cam);
338-
}
339326
}
340327

341328
void setBackground(InputArray image) CV_OVERRIDE
@@ -361,9 +348,9 @@ class WindowSceneImpl : public WindowScene
361348
{
362349
CompositorManager& cm = CompositorManager::getSingleton();
363350
// this should be applied to all owned render targets
364-
Ogre::RenderTarget* targets[] = {frameSrc, rWin, depthRTT};
351+
Ogre::RenderTarget* targets[] = {rWin, depthRTT};
365352

366-
for(int j = (frameSrc == rWin); j < 3; j++) // skip frameSrc if it is the same as rWin
353+
for(int j = 0; j < 2; j++)
367354
{
368355
Ogre::RenderTarget* tgt = targets[j];
369356
if(!tgt) continue;
@@ -386,7 +373,7 @@ class WindowSceneImpl : public WindowScene
386373
int mrtIndex) CV_OVERRIDE
387374
{
388375
CompositorManager& cm = CompositorManager::getSingleton();
389-
CompositorChain* chain = cm.getCompositorChain(frameSrc->getViewport(0));
376+
CompositorChain* chain = cm.getCompositorChain(rWin->getViewport(0));
390377
CV_Assert(chain && "no active compositors");
391378

392379
CompositorInstance* inst = chain->getCompositor(compname);
@@ -441,8 +428,6 @@ class WindowSceneImpl : public WindowScene
441428
// BGRA as uchar
442429
ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255;
443430
rWin->getViewport(0)->setBackgroundColour(_color);
444-
if(frameSrc != rWin)
445-
frameSrc->getViewport(0)->setBackgroundColour(_color);
446431
}
447432

448433
void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE
@@ -594,17 +579,14 @@ class WindowSceneImpl : public WindowScene
594579

595580
void getScreenshot(OutputArray frame) CV_OVERRIDE
596581
{
597-
PixelFormat src_type = frameSrc->suggestPixelFormat();
598-
int dst_type = src_type == PF_BYTE_RGB ? CV_8UC3 : CV_32FC4;
599-
600-
frame.create(frameSrc->getHeight(), frameSrc->getWidth(), dst_type);
582+
frame.create(rWin->getHeight(), rWin->getWidth(), CV_8UC3);
601583

602584
Mat out = frame.getMat();
603-
PixelBox pb(frameSrc->getWidth(), frameSrc->getHeight(), 1, src_type, out.ptr());
604-
frameSrc->copyContentsToMemory(pb, pb);
585+
PixelBox pb(rWin->getWidth(), rWin->getHeight(), 1, PF_BYTE_RGB, out.ptr());
586+
rWin->copyContentsToMemory(pb, pb);
605587

606588
// convert to OpenCV channel order
607-
cvtColor(out, out, dst_type == CV_8UC3 ? COLOR_RGB2BGR : COLOR_RGBA2BGRA);
589+
cvtColor(out, out, COLOR_RGB2BGR);
608590
}
609591

610592
void getDepth(OutputArray depth) CV_OVERRIDE
@@ -615,8 +597,8 @@ class WindowSceneImpl : public WindowScene
615597
// render into an offscreen texture
616598
// currently this draws everything twice as OGRE lacks depth texture attachments
617599
TexturePtr tex = TextureManager::getSingleton().createManual(
618-
title + "_Depth", RESOURCEGROUP_NAME, TEX_TYPE_2D, frameSrc->getWidth(),
619-
frameSrc->getHeight(), 0, PF_DEPTH, TU_RENDERTARGET);
600+
title + "_Depth", RESOURCEGROUP_NAME, TEX_TYPE_2D, rWin->getWidth(),
601+
rWin->getHeight(), 0, PF_DEPTH, TU_RENDERTARGET);
620602
depthRTT = tex->getBuffer()->getRenderTarget();
621603
depthRTT->addViewport(cam);
622604
depthRTT->setAutoUpdated(false); // only update when requested

0 commit comments

Comments
 (0)