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
3038ffb8
Commit
3038ffb8
authored
Aug 25, 2013
by
ozantonkal
Committed by
Ozan Tonkal
Sep 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setDesiredUpdateRate implementation in Viz3d
parent
ed0162ad
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
102 deletions
+130
-102
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+3
-0
viz3d.cpp
modules/viz/src/viz3d.cpp
+4
-0
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+121
-100
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+2
-2
No files found.
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
3038ffb8
...
...
@@ -60,6 +60,9 @@ namespace cv
void
setRenderingProperty
(
int
property
,
double
value
,
const
String
&
id
);
double
getRenderingProperty
(
int
property
,
const
String
&
id
);
void
setDesiredUpdateRate
(
double
time
);
double
getDesiredUpdateRate
();
void
setRepresentationToSurface
();
void
setRepresentationToWireframe
();
void
setRepresentationToPoints
();
...
...
modules/viz/src/viz3d.cpp
View file @
3038ffb8
...
...
@@ -80,6 +80,9 @@ void cv::viz::Viz3d::setBackgroundColor(const Color& color) { impl_->setBackgrou
void
cv
::
viz
::
Viz3d
::
setRenderingProperty
(
int
property
,
double
value
,
const
String
&
id
)
{
getWidget
(
id
).
setRenderingProperty
(
property
,
value
);
}
double
cv
::
viz
::
Viz3d
::
getRenderingProperty
(
int
property
,
const
String
&
id
)
{
return
getWidget
(
id
).
getRenderingProperty
(
property
);
}
void
cv
::
viz
::
Viz3d
::
setDesiredUpdateRate
(
double
time
)
{
impl_
->
setDesiredUpdateRate
(
time
);
}
double
cv
::
viz
::
Viz3d
::
getDesiredUpdateRate
()
{
return
impl_
->
getDesiredUpdateRate
();
}
void
cv
::
viz
::
Viz3d
::
setRepresentationToSurface
()
{
impl_
->
setRepresentationToSurface
();
}
void
cv
::
viz
::
Viz3d
::
setRepresentationToWireframe
()
{
impl_
->
setRepresentationToWireframe
();
}
void
cv
::
viz
::
Viz3d
::
setRepresentationToPoints
()
{
impl_
->
setRepresentationToPoints
();
}
\ No newline at end of file
modules/viz/src/viz3d_impl.cpp
View file @
3038ffb8
...
...
@@ -84,6 +84,127 @@ cv::viz::Viz3d::VizImpl::~VizImpl ()
if
(
renderer_
)
renderer_
->
Clear
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
if
(
exists
)
{
// Remove it if it exists and add it again
removeActorFromRenderer
(
wam_itr
->
second
);
}
// Get the actor and set the user matrix
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
widget
));
if
(
actor
)
{
// If the actor is 3D, apply pose
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
convertToVtkMatrix
(
pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
// If the actor is a vtkFollower, then it should always face the camera
vtkFollower
*
follower
=
vtkFollower
::
SafeDownCast
(
actor
);
if
(
follower
)
{
follower
->
SetCamera
(
renderer_
->
GetActiveCamera
());
}
renderer_
->
AddActor
(
WidgetAccessor
::
getProp
(
widget
));
(
*
widget_actor_map_
)[
id
]
=
WidgetAccessor
::
getProp
(
widget
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
removeWidget
(
const
String
&
id
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
CV_Assert
(
removeActorFromRenderer
(
wam_itr
->
second
));
widget_actor_map_
->
erase
(
wam_itr
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
cv
::
viz
::
Widget
cv
::
viz
::
Viz3d
::
VizImpl
::
getWidget
(
const
String
&
id
)
const
{
WidgetActorMap
::
const_iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
Widget
widget
;
WidgetAccessor
::
setProp
(
widget
,
wam_itr
->
second
);
return
widget
;
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
wam_itr
->
second
);
CV_Assert
(
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
convertToVtkMatrix
(
pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
wam_itr
->
second
);
CV_Assert
(
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
if
(
!
matrix
)
{
setWidgetPose
(
id
,
pose
);
return
;
}
Matx44f
matrix_cv
=
convertToMatx
(
matrix
);
Affine3f
updated_pose
=
pose
*
Affine3f
(
matrix_cv
);
matrix
=
convertToVtkMatrix
(
updated_pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
/////////////////////////////////////////////////////////////////////////////////////////////
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
VizImpl
::
getWidgetPose
(
const
String
&
id
)
const
{
WidgetActorMap
::
const_iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
wam_itr
->
second
);
CV_Assert
(
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
Matx44f
matrix_cv
=
convertToMatx
(
matrix
);
return
Affine3f
(
matrix_cv
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setDesiredUpdateRate
(
double
time
)
{
if
(
interactor_
)
interactor_
->
SetDesiredUpdateRate
(
time
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
double
cv
::
viz
::
Viz3d
::
VizImpl
::
getDesiredUpdateRate
()
{
if
(
interactor_
)
return
interactor_
->
GetDesiredUpdateRate
();
return
0.0
;
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
saveScreenshot
(
const
std
::
string
&
file
)
{
style_
->
saveScreenshot
(
file
);
}
...
...
@@ -492,103 +613,3 @@ cv::String cv::viz::Viz3d::VizImpl::getWindowName() const
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setWindowPosition
(
int
x
,
int
y
)
{
window_
->
SetPosition
(
x
,
y
);
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setWindowSize
(
int
xw
,
int
yw
)
{
window_
->
SetSize
(
xw
,
yw
);
}
cv
::
Size
cv
::
viz
::
Viz3d
::
VizImpl
::
getWindowSize
()
const
{
return
Size
(
window_
->
GetSize
()[
0
],
window_
->
GetSize
()[
1
]);
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
if
(
exists
)
{
// Remove it if it exists and add it again
removeActorFromRenderer
(
wam_itr
->
second
);
}
// Get the actor and set the user matrix
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
widget
));
if
(
actor
)
{
// If the actor is 3D, apply pose
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
convertToVtkMatrix
(
pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
// If the actor is a vtkFollower, then it should always face the camera
vtkFollower
*
follower
=
vtkFollower
::
SafeDownCast
(
actor
);
if
(
follower
)
{
follower
->
SetCamera
(
renderer_
->
GetActiveCamera
());
}
renderer_
->
AddActor
(
WidgetAccessor
::
getProp
(
widget
));
(
*
widget_actor_map_
)[
id
]
=
WidgetAccessor
::
getProp
(
widget
);
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
removeWidget
(
const
String
&
id
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
CV_Assert
(
removeActorFromRenderer
(
wam_itr
->
second
));
widget_actor_map_
->
erase
(
wam_itr
);
}
cv
::
viz
::
Widget
cv
::
viz
::
Viz3d
::
VizImpl
::
getWidget
(
const
String
&
id
)
const
{
WidgetActorMap
::
const_iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
Widget
widget
;
WidgetAccessor
::
setProp
(
widget
,
wam_itr
->
second
);
return
widget
;
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
wam_itr
->
second
);
CV_Assert
(
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
convertToVtkMatrix
(
pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
WidgetActorMap
::
iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
wam_itr
->
second
);
CV_Assert
(
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
if
(
!
matrix
)
{
setWidgetPose
(
id
,
pose
);
return
;
}
Matx44f
matrix_cv
=
convertToMatx
(
matrix
);
Affine3f
updated_pose
=
pose
*
Affine3f
(
matrix_cv
);
matrix
=
convertToVtkMatrix
(
updated_pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
VizImpl
::
getWidgetPose
(
const
String
&
id
)
const
{
WidgetActorMap
::
const_iterator
wam_itr
=
widget_actor_map_
->
find
(
id
);
bool
exists
=
wam_itr
!=
widget_actor_map_
->
end
();
CV_Assert
(
exists
);
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
wam_itr
->
second
);
CV_Assert
(
actor
);
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
Matx44f
matrix_cv
=
convertToMatx
(
matrix
);
return
Affine3f
(
matrix_cv
);
}
modules/viz/src/viz3d_impl.hpp
View file @
3038ffb8
...
...
@@ -26,8 +26,8 @@ public:
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
void
set
RenderingProperty
(
int
property
,
double
value
,
const
String
&
id
);
double
get
RenderingProperty
(
int
property
,
const
String
&
id
);
void
set
DesiredUpdateRate
(
double
time
);
double
get
DesiredUpdateRate
(
);
/** \brief Returns true when the user tried to close the window */
bool
wasStopped
()
const
{
if
(
interactor_
!=
NULL
)
return
(
stopped_
);
else
return
true
;
}
...
...
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