Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
c4c2e85d
Commit
c4c2e85d
authored
Oct 01, 2018
by
Pavel Rojtberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ovis: add getCompositorTexture for reading custom render targets
parent
ff9d3132
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
0 deletions
+61
-0
ovis.hpp
modules/ovis/include/opencv2/ovis.hpp
+10
-0
ovis.cpp
modules/ovis/src/ovis.cpp
+51
-0
No files found.
modules/ovis/include/opencv2/ovis.hpp
View file @
c4c2e85d
...
...
@@ -161,6 +161,16 @@ public:
*/
CV_WRAP
virtual
void
getScreenshot
(
OutputArray
frame
)
=
0
;
/**
* read back the texture of an active compositor
* @param compname name of the compositor
* @param texname name of the texture inside the compositor
* @param mrtIndex if texture is a MRT, specifies the attachment
* @param out the texture contents
*/
CV_WRAP
virtual
void
getCompositorTexture
(
const
String
&
compname
,
const
String
&
texname
,
OutputArray
out
,
int
mrtIndex
=
0
)
=
0
;
/**
* get the depth for the current frame.
*
...
...
modules/ovis/src/ovis.cpp
View file @
c4c2e85d
...
...
@@ -382,6 +382,57 @@ public:
}
}
void
getCompositorTexture
(
const
String
&
compname
,
const
String
&
texname
,
OutputArray
out
,
int
mrtIndex
)
CV_OVERRIDE
{
CompositorManager
&
cm
=
CompositorManager
::
getSingleton
();
CompositorChain
*
chain
=
cm
.
getCompositorChain
(
frameSrc
->
getViewport
(
0
));
CV_Assert
(
chain
&&
"no active compositors"
);
CompositorInstance
*
inst
=
chain
->
getCompositor
(
compname
);
if
(
!
inst
)
CV_Error_
(
Error
::
StsBadArg
,
(
"no active compositor named: %s"
,
compname
.
c_str
()));
TexturePtr
tex
=
inst
->
getTextureInstance
(
texname
,
mrtIndex
);
if
(
!
tex
)
CV_Error_
(
Error
::
StsBadArg
,
(
"no texture named: %s"
,
texname
.
c_str
()));
PixelFormat
src_type
=
tex
->
getFormat
();
int
dst_type
;
switch
(
src_type
)
{
case
PF_BYTE_RGB
:
dst_type
=
CV_8UC3
;
break
;
case
PF_BYTE_RGBA
:
dst_type
=
CV_8UC4
;
break
;
case
PF_FLOAT32_RGB
:
dst_type
=
CV_32FC3
;
break
;
case
PF_FLOAT32_RGBA
:
dst_type
=
CV_32FC4
;
break
;
case
PF_DEPTH16
:
dst_type
=
CV_16U
;
break
;
default
:
CV_Error
(
Error
::
StsNotImplemented
,
"unsupported texture format"
);
}
out
.
create
(
tex
->
getHeight
(),
tex
->
getWidth
(),
dst_type
);
Mat
mat
=
out
.
getMat
();
PixelBox
pb
(
tex
->
getWidth
(),
tex
->
getHeight
(),
1
,
src_type
,
mat
.
ptr
());
tex
->
getBuffer
()
->
blitToMemory
(
pb
,
pb
);
if
(
CV_MAT_CN
(
dst_type
)
<
3
)
return
;
// convert to OpenCV channel order
cvtColor
(
mat
,
mat
,
CV_MAT_CN
(
dst_type
)
==
3
?
COLOR_RGB2BGR
:
COLOR_RGBA2BGRA
);
}
void
setBackground
(
const
Scalar
&
color
)
CV_OVERRIDE
{
// hide background plane
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment