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
e52c4dbe
Commit
e52c4dbe
authored
Feb 02, 2018
by
Pavel Rojtberg
Committed by
Pavel Rojtberg
Feb 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ovis: replace renderOneFrame by waitKey for consistency with highgui
also set the intrinsic in the AR demo
parent
30567982
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
24 deletions
+33
-24
ovis.hpp
modules/ovis/include/opencv2/ovis.hpp
+7
-4
aruco_ar_demo.py
modules/ovis/samples/aruco_ar_demo.py
+2
-1
ovis_demo.py
modules/ovis/samples/ovis_demo.py
+1
-1
ovis.cpp
modules/ovis/src/ovis.cpp
+23
-18
No files found.
modules/ovis/include/opencv2/ovis.hpp
View file @
e52c4dbe
...
...
@@ -116,7 +116,7 @@ public:
InputArray
rot
=
noArray
(),
bool
invert
=
false
)
=
0
;
/**
* read back
image of last call to @ref renderOneFrame
* read back
the image generated by the last call to @ref waitKey
*/
CV_WRAP
virtual
void
getScreenshot
(
OutputArray
frame
)
=
0
;
...
...
@@ -181,10 +181,13 @@ CV_EXPORTS_W Ptr<WindowScene> createWindow(const String& title, const Size& size
int
flags
=
SCENE_INTERACTIVE
);
/**
* update all windows
* @return true if this functian can be called again (i.e. continue rendering). false otherwise.
* update all windows and wait for keyboard event
*
* @param delay 0 is the special value that means "forever".
* Any positive number returns after sync to blank (typically 16ms).
* @return the code of the pressed key or -1 if no key was pressed
*/
CV_EXPORTS_W
bool
renderOneFrame
(
);
CV_EXPORTS_W
int
waitKey
(
int
delay
=
0
);
/**
* set the property of a material to the given value
...
...
modules/ovis/samples/aruco_ar_demo.py
View file @
e52c4dbe
...
...
@@ -13,6 +13,7 @@ K = cv.getDefaultNewCameraMatrix(np.diag([800, 800, 1]), imsize, True)
cv
.
ovis
.
addResourceLocation
(
"packs/Sinbad.zip"
)
# shipped with Ogre
win
=
cv
.
ovis
.
createWindow
(
"arucoAR"
,
imsize
,
flags
=
0
)
win
.
setCameraIntrinsics
(
K
,
imsize
)
win
.
createEntity
(
"figure"
,
"Sinbad.mesh"
,
(
0
,
0
,
-
5
),
(
-
1.57
,
0
,
0
))
win
.
createLightEntity
(
"sun"
,
(
0
,
0
,
-
100
))
...
...
@@ -21,7 +22,7 @@ cap = cv.VideoCapture(0)
cap
.
set
(
cv
.
CAP_PROP_FRAME_WIDTH
,
imsize
[
0
])
cap
.
set
(
cv
.
CAP_PROP_FRAME_HEIGHT
,
imsize
[
1
])
while
cv
.
ovis
.
renderOneFrame
()
:
while
cv
.
ovis
.
waitKey
(
1
)
!=
27
:
img
=
cap
.
read
()[
1
]
win
.
setBackground
(
img
)
corners
,
ids
=
cv
.
aruco
.
detectMarkers
(
img
,
adict
)[:
2
]
...
...
modules/ovis/samples/ovis_demo.py
View file @
e52c4dbe
...
...
@@ -23,6 +23,6 @@ iwin.createEntity("figure", "Sinbad.mesh", (0, -5, 0))
iwin
.
createLightEntity
(
"sun"
,
(
0
,
0
,
-
100
))
iwin
.
setCameraIntrinsics
(
K
,
imsize
)
while
cv
.
ovis
.
renderOneFrame
()
:
while
cv
.
ovis
.
waitKey
(
1
)
!=
27
:
R
,
t
=
iwin
.
getCameraPose
()
owin
.
setEntityPose
(
"cam"
,
t
,
R
)
modules/ovis/src/ovis.cpp
View file @
e52c4dbe
...
...
@@ -136,17 +136,18 @@ static SceneNode* _getSceneNode(SceneManager* sceneMgr, const String& name)
return
mo
->
getParentSceneNode
();
}
struct
Application
:
public
OgreBites
::
ApplicationContext
struct
Application
:
public
OgreBites
::
ApplicationContext
,
public
OgreBites
::
InputListener
{
Ptr
<
LogManager
>
logMgr
;
Ogre
::
SceneManager
*
sceneMgr
;
Ogre
::
String
title
;
uint32_t
w
;
uint32_t
h
;
int
key_pressed
;
Application
(
const
Ogre
::
String
&
_title
,
const
Size
&
sz
)
:
OgreBites
::
ApplicationContext
(
"ovis"
,
false
),
sceneMgr
(
NULL
),
title
(
_title
),
w
(
sz
.
width
),
h
(
sz
.
height
)
h
(
sz
.
height
)
,
key_pressed
(
-
1
)
{
logMgr
.
reset
(
new
LogManager
());
logMgr
->
createLog
(
"ovis.log"
,
true
,
true
,
true
);
...
...
@@ -158,6 +159,12 @@ struct Application : public OgreBites::ApplicationContext
// empty impl to show cursor
}
bool
keyPressed
(
const
OgreBites
::
KeyboardEvent
&
evt
)
{
key_pressed
=
evt
.
keysym
.
sym
;
return
true
;
}
bool
oneTimeConfig
()
{
Ogre
::
RenderSystem
*
rs
=
getRoot
()
->
getRenderSystemByName
(
RENDERSYSTEM_NAME
);
...
...
@@ -179,7 +186,11 @@ struct Application : public OgreBites::ApplicationContext
miscParams
[
"FSAA"
]
=
"4"
;
miscParams
[
"vsync"
]
=
"true"
;
return
OgreBites
::
ApplicationContext
::
createWindow
(
_name
,
_w
,
_h
,
miscParams
);
OgreBites
::
NativeWindowPair
ret
=
OgreBites
::
ApplicationContext
::
createWindow
(
_name
,
_w
,
_h
,
miscParams
);
addInputListener
(
ret
.
native
,
this
);
// handle input for all windows
return
ret
;
}
void
locateResources
()
...
...
@@ -212,7 +223,7 @@ struct Application : public OgreBites::ApplicationContext
}
};
class
WindowSceneImpl
:
public
WindowScene
,
public
OgreBites
::
InputListener
class
WindowSceneImpl
:
public
WindowScene
{
String
title
;
Root
*
root
;
...
...
@@ -266,8 +277,6 @@ public:
{
app
->
sceneMgr
=
sceneMgr
;
rWin
=
app
->
getRenderWindow
();
app
->
addInputListener
(
this
);
if
(
camman
)
app
->
addInputListener
(
camman
.
get
());
}
...
...
@@ -277,8 +286,6 @@ public:
rWin
=
nwin
.
render
;
if
(
camman
)
app
->
addInputListener
(
nwin
.
native
,
camman
.
get
());
app
->
addInputListener
(
nwin
.
native
,
this
);
}
rWin
->
addViewport
(
cam
);
...
...
@@ -421,14 +428,6 @@ public:
rWin
->
copyContentsToMemory
(
pb
,
pb
);
}
bool
keyPressed
(
const
OgreBites
::
KeyboardEvent
&
evt
)
{
if
(
evt
.
keysym
.
sym
==
SDLK_ESCAPE
)
root
->
queueEndRendering
();
return
true
;
}
void
fixCameraYawAxis
(
bool
useFixed
,
InputArray
_up
)
{
Vector3
up
=
Vector3
::
UNIT_Y
;
...
...
@@ -527,12 +526,18 @@ Ptr<WindowScene> createWindow(const String& title, const Size& size, int flags)
return
makePtr
<
WindowSceneImpl
>
(
_app
,
title
,
size
,
flags
);
}
CV_EXPORTS_W
bool
renderOneFrame
(
)
CV_EXPORTS_W
int
waitKey
(
int
delay
)
{
CV_Assert
(
_app
);
_app
->
key_pressed
=
-
1
;
_app
->
getRoot
()
->
renderOneFrame
();
return
not
_app
->
getRoot
()
->
endRenderingQueued
();
// wait for keypress, using vsync instead of sleep
while
(
!
delay
&&
_app
->
key_pressed
==
-
1
)
_app
->
getRoot
()
->
renderOneFrame
();
return
(
_app
->
key_pressed
!=
-
1
)
?
(
_app
->
key_pressed
&
0xff
)
:
-
1
;
}
void
setMaterialProperty
(
const
String
&
name
,
int
prop
,
const
Scalar
&
val
)
...
...
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