Skip to content

Commit 4f3c9fc

Browse files
committed
ovis: add setCompositors method
enables an ordered chain of full-screen post processing effects
1 parent 25a01dc commit 4f3c9fc

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

modules/ovis/include/opencv2/ovis.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ class CV_EXPORTS_W WindowScene {
6262
/// @overload
6363
CV_WRAP_AS(setBackgroundColor) virtual void setBackground(const Scalar& color) = 0;
6464

65+
/**
66+
* enable an ordered chain of full-screen post processing effects
67+
*
68+
* this way you can add distortion or SSAO effects.
69+
* The effects themselves must be defined inside Ogre .compositor scripts.
70+
* @see addResourceLocation
71+
* @param names compositor names that will be applied in order of appearance
72+
*/
73+
CV_WRAP virtual void setCompositors(const std::vector<String>& names) = 0;
74+
6575
/**
6676
* place an entity of an mesh in the scene
6777
*

modules/ovis/src/ovis.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <OgreApplicationContext.h>
88
#include <OgreCameraMan.h>
99
#include <OgreRectangle2D.h>
10+
#include <OgreCompositorManager.h>
1011

1112
#include <opencv2/calib3d.hpp>
1213

@@ -339,6 +340,23 @@ class WindowSceneImpl : public WindowScene
339340
bgplane->setVisible(true);
340341
}
341342

343+
void setCompositors(const std::vector<String>& names)
344+
{
345+
Viewport* vp = frameSrc->getViewport(0);
346+
CompositorManager& cm = CompositorManager::getSingleton();
347+
348+
cm.removeCompositorChain(vp); // remove previous configuration
349+
350+
for(size_t i = 0; i < names.size(); i++)
351+
{
352+
if (!cm.addCompositor(vp, names[i])) {
353+
LogManager::getSingleton().logError("Failed to add compositor: " + names[i]);
354+
continue;
355+
}
356+
cm.setCompositorEnabled(vp, names[i], true);
357+
}
358+
}
359+
342360
void setBackground(const Scalar& color)
343361
{
344362
// hide background plane

0 commit comments

Comments
 (0)