Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
b131faa8
Commit
b131faa8
authored
Dec 13, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
export scene to vrml and obj formats
parent
b2cd526e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
+37
-5
interactor_style.cpp
modules/viz/src/interactor_style.cpp
+34
-5
interactor_style.hpp
modules/viz/src/interactor_style.hpp
+1
-0
precomp.hpp
modules/viz/src/precomp.hpp
+2
-0
No files found.
modules/viz/src/interactor_style.cpp
View file @
b131faa8
...
...
@@ -87,6 +87,29 @@ void cv::viz::InteractorStyle::saveScreenshot(const String &file)
snapshot_writer
->
SetInputConnection
(
wif
->
GetOutputPort
());
snapshot_writer
->
SetFileName
(
file
.
c_str
());
snapshot_writer
->
Write
();
cout
<<
"Screenshot successfully captured ("
<<
file
.
c_str
()
<<
")"
<<
endl
;
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
InteractorStyle
::
exportScene
(
const
String
&
file
)
{
vtkSmartPointer
<
vtkExporter
>
exporter
;
if
(
file
.
size
()
>
5
&&
file
.
substr
(
file
.
size
()
-
5
)
==
".vrml"
)
{
exporter
=
vtkSmartPointer
<
vtkVRMLExporter
>::
New
();
vtkVRMLExporter
::
SafeDownCast
(
exporter
)
->
SetFileName
(
file
.
c_str
());
}
else
{
exporter
=
vtkSmartPointer
<
vtkOBJExporter
>::
New
();
vtkOBJExporter
::
SafeDownCast
(
exporter
)
->
SetFilePrefix
(
file
.
c_str
());
}
exporter
->
SetInput
(
Interactor
->
GetRenderWindow
());
exporter
->
Write
();
cout
<<
"Scene successfully exported ("
<<
file
.
c_str
()
<<
")"
<<
endl
;
}
//////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -224,6 +247,8 @@ void cv::viz::InteractorStyle::OnKeyDown()
" s, S : switch to a surface-based representation (where available)
\n
"
"
\n
"
" j, J : take a .PNG snapshot of the current window view
\n
"
" k, K : export scene to Wavefront .obj format
\n
"
" ALT + k, K : export scene to VRML format
\n
"
" c, C : display current camera/window parameters
\n
"
" f, F : fly to point mode, hold the key and move mouse where to fly
\n
"
"
\n
"
...
...
@@ -255,15 +280,19 @@ void cv::viz::InteractorStyle::OnKeyDown()
}
break
;
}
// Save a PNG snapshot with the current screen
// Save a PNG snapshot
case
'j'
:
case
'J'
:
saveScreenshot
(
cv
::
format
(
"screenshot-%d.png"
,
(
unsigned
int
)
time
(
0
)));
break
;
// Export scene as in obj or vrml format
case
'k'
:
case
'K'
:
{
unsigned
int
t
=
static_cast
<
unsigned
int
>
(
time
(
0
));
String
png_file
=
cv
::
format
(
"screenshot-%d.png"
,
t
);
saveScreenshot
(
png_file
);
cout
<<
"Screenshot ("
<<
png_file
.
c_str
()
<<
") successfully captured."
<<
endl
;
String
format
=
alt
?
"scene-%d.vrml"
:
"scene-%d"
;
exportScene
(
cv
::
format
(
format
.
c_str
(),
(
unsigned
int
)
time
(
0
)));
break
;
}
// display current camera settings/parameters
case
'c'
:
case
'C'
:
{
...
...
modules/viz/src/interactor_style.hpp
View file @
b131faa8
...
...
@@ -67,6 +67,7 @@ namespace cv
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
saveScreenshot
(
const
String
&
file
);
void
exportScene
(
const
String
&
file
);
private
:
/** \brief Set to true after initialization is complete. */
...
...
modules/viz/src/precomp.hpp
View file @
b131faa8
...
...
@@ -122,6 +122,8 @@
#include <vtkPLYReader.h>
#include <vtkOBJReader.h>
#include <vtkSTLReader.h>
#include <vtkOBJExporter.h>
#include <vtkVRMLExporter.h>
#if !defined(_WIN32) || defined(__CYGWIN__)
# include <unistd.h>
/* unlink */
...
...
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