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
9a4f415f
Commit
9a4f415f
authored
Mar 05, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1572 from paroj:ovisup
parents
91d108f3
7d1aca38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
ovis.hpp
modules/ovis/include/opencv2/ovis.hpp
+7
-0
ovis.cpp
modules/ovis/src/ovis.cpp
+34
-2
No files found.
modules/ovis/include/opencv2/ovis.hpp
View file @
9a4f415f
...
...
@@ -130,6 +130,13 @@ public:
*/
CV_WRAP
virtual
void
getScreenshot
(
OutputArray
frame
)
=
0
;
/**
* get the depth for the current frame.
*
* return the per pixel distance to the camera in world units
*/
CV_WRAP
virtual
void
getDepth
(
OutputArray
depth
)
=
0
;
/**
* convenience method to force the "up" axis to stay fixed
*
...
...
modules/ovis/src/ovis.cpp
View file @
9a4f415f
...
...
@@ -240,10 +240,10 @@ class WindowSceneImpl : public WindowScene
Ptr
<
Rectangle2D
>
bgplane
;
Ogre
::
RenderTarget
*
frameSrc
;
Ogre
::
RenderTarget
*
depthRTT
;
public
:
WindowSceneImpl
(
Ptr
<
Application
>
app
,
const
String
&
_title
,
const
Size
&
sz
,
int
flags
)
:
title
(
_title
),
root
(
app
->
getRoot
())
:
title
(
_title
),
root
(
app
->
getRoot
())
,
depthRTT
(
NULL
)
{
if
(
!
app
->
sceneMgr
)
{
...
...
@@ -470,6 +470,38 @@ public:
cvtColor
(
out
,
out
,
dst_type
==
CV_8UC3
?
COLOR_RGB2BGR
:
COLOR_RGBA2BGRA
);
}
void
getDepth
(
OutputArray
depth
)
{
Camera
*
cam
=
sceneMgr
->
getCamera
(
title
);
if
(
!
depthRTT
)
{
// render into an offscreen texture
// currently this draws everything twice as OGRE lacks depth texture attachments
TexturePtr
tex
=
TextureManager
::
getSingleton
().
createManual
(
title
+
"_Depth"
,
RESOURCEGROUP_NAME
,
TEX_TYPE_2D
,
frameSrc
->
getWidth
(),
frameSrc
->
getHeight
(),
0
,
PF_DEPTH
,
TU_RENDERTARGET
);
depthRTT
=
tex
->
getBuffer
()
->
getRenderTarget
();
depthRTT
->
addViewport
(
cam
);
depthRTT
->
setAutoUpdated
(
false
);
// only update when requested
}
Mat
tmp
(
depthRTT
->
getHeight
(),
depthRTT
->
getWidth
(),
CV_16U
);
PixelBox
pb
(
depthRTT
->
getWidth
(),
depthRTT
->
getHeight
(),
1
,
PF_DEPTH
,
tmp
.
ptr
());
depthRTT
->
update
(
false
);
depthRTT
->
copyContentsToMemory
(
pb
,
pb
);
// convert to NDC
double
alpha
=
2.0
/
std
::
numeric_limits
<
uint16
>::
max
();
tmp
.
convertTo
(
depth
,
CV_64F
,
alpha
,
-
1
);
// convert to linear
float
n
=
cam
->
getNearClipDistance
();
float
f
=
cam
->
getFarClipDistance
();
Mat
ndc
=
depth
.
getMat
();
ndc
=
-
ndc
*
(
f
-
n
)
+
(
f
+
n
);
ndc
=
(
2
*
f
*
n
)
/
ndc
;
}
void
fixCameraYawAxis
(
bool
useFixed
,
InputArray
_up
)
{
Vector3
up
=
Vector3
::
UNIT_Y
;
...
...
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