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
54c7dfab
Commit
54c7dfab
authored
Jul 03, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial base widget implementation
parent
e0b7e637
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
3 deletions
+166
-3
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+18
-0
widget_accessor.hpp
modules/viz/include/opencv2/viz/widget_accessor.hpp
+13
-0
types.cpp
modules/viz/src/types.cpp
+135
-2
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+0
-1
No files found.
modules/viz/include/opencv2/viz/types.hpp
View file @
54c7dfab
...
...
@@ -113,4 +113,22 @@ namespace temp_viz
template
<
typename
_Tp
>
inline
bool
isNan
(
const
Point3_
<
_Tp
>&
p
)
{
return
isNan
(
p
.
x
)
||
isNan
(
p
.
y
)
||
isNan
(
p
.
z
);
}
class
Widget
{
public
:
Widget
();
Widget
(
const
String
&
id
);
Widget
(
const
Widget
&
other
);
void
setId
(
const
String
&
id
);
void
setColor
(
const
Color
&
color
);
void
setPose
(
const
Affine3f
&
pose
);
void
updatePose
(
const
Affine3f
&
pose
);
Affine3f
getPose
()
const
;
private
:
class
Impl
;
cv
::
Ptr
<
Impl
>
impl_
;
friend
struct
WidgetAccessor
;
};
}
modules/viz/include/opencv2/viz/widget_accessor.hpp
0 → 100644
View file @
54c7dfab
#pragma once
#include "precomp.hpp"
#include "types.hpp"
namespace
temp_viz
{
struct
WidgetAccessor
{
static
CV_EXPORTS
vtkSmartPointer
<
vtkActor
>
getActor
(
const
Widget
&
widget
);
};
}
\ No newline at end of file
modules/viz/src/types.cpp
View file @
54c7dfab
#include <opencv2/viz/types.hpp>
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// cv::Color
...
...
@@ -22,3 +20,138 @@ temp_viz::Color temp_viz::Color::white() { return Color(255, 255, 255); }
temp_viz
::
Color
temp_viz
::
Color
::
gray
()
{
return
Color
(
128
,
128
,
128
);
}
class
temp_viz
::
Widget
::
Impl
{
public
:
String
id
;
vtkSmartPointer
<
vtkActor
>
actor
;
Impl
()
{
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
}
vtkSmartPointer
<
vtkActor
>
getActor
()
{
return
actor
;
}
void
setId
(
const
String
&
id
)
{
this
->
id
=
id
;
}
const
temp_viz
::
String
&
getString
()
const
{
return
id
;
}
void
setColor
(
const
Color
&
color
)
{
Color
c
=
vtkcolor
(
color
);
actor
->
GetMapper
()
->
ScalarVisibilityOff
();
actor
->
GetProperty
()
->
SetColor
(
c
.
val
);
actor
->
GetProperty
()
->
SetEdgeColor
(
c
.
val
);
actor
->
GetProperty
()
->
SetAmbient
(
0.8
);
actor
->
GetProperty
()
->
SetDiffuse
(
0.8
);
actor
->
GetProperty
()
->
SetSpecular
(
0.8
);
actor
->
GetProperty
()
->
SetLighting
(
0
);
actor
->
Modified
();
}
void
setPose
(
const
Affine3f
&
pose
)
{
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
convertToVtkMatrix
(
pose
.
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
void
updatePose
(
const
Affine3f
&
pose
)
{
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
Matx44f
matrix_cv
;
convertToCvMatrix
(
matrix
,
matrix_cv
);
matrix
=
convertToVtkMatrix
((
pose
*
Affine3f
(
matrix_cv
)).
matrix
);
actor
->
SetUserMatrix
(
matrix
);
actor
->
Modified
();
}
Affine3f
getPose
()
const
{
vtkSmartPointer
<
vtkMatrix4x4
>
matrix
=
actor
->
GetUserMatrix
();
Matx44f
matrix_cv
;
convertToCvMatrix
(
matrix
,
matrix_cv
);
return
Affine3f
(
matrix_cv
);
}
protected
:
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
)
const
{
vtkSmartPointer
<
vtkMatrix4x4
>
vtk_matrix
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
vtk_matrix
->
SetElement
(
i
,
k
,
m
(
i
,
k
));
return
vtk_matrix
;
}
void
convertToCvMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
cv
::
Matx44f
&
m
)
const
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
m
(
i
,
k
)
=
vtk_matrix
->
GetElement
(
i
,
k
);
}
};
temp_viz
::
Widget
::
Widget
()
{
impl_
=
new
Impl
();
impl_
->
setId
(
"id"
);
}
temp_viz
::
Widget
::
Widget
(
const
String
&
id
)
{
impl_
=
new
Impl
();
impl_
->
setId
(
"id"
);
}
temp_viz
::
Widget
::
Widget
(
const
Widget
&
other
)
{
impl_
=
other
.
impl_
;
}
void
temp_viz
::
Widget
::
setId
(
const
String
&
id
)
{
impl_
->
setId
(
id
);
}
void
temp_viz
::
Widget
::
setColor
(
const
Color
&
color
)
{
impl_
->
setColor
(
color
);
}
void
temp_viz
::
Widget
::
setPose
(
const
Affine3f
&
pose
)
{
impl_
->
setPose
(
pose
);
}
void
temp_viz
::
Widget
::
updatePose
(
const
Affine3f
&
pose
)
{
impl_
->
updatePose
(
pose
);
}
temp_viz
::
Affine3f
temp_viz
::
Widget
::
getPose
()
const
{
return
impl_
->
getPose
();
}
// TODO Check if HAVE_VTK
#include "opencv2/viz/widget_accessor.hpp"
vtkSmartPointer
<
vtkActor
>
temp_viz
::
WidgetAccessor
::
getActor
(
const
temp_viz
::
Widget
&
widget
)
{
return
widget
.
impl_
->
actor
;
}
modules/viz/test/test_viz3d.cpp
View file @
54c7dfab
...
...
@@ -50,7 +50,6 @@
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/mesh_load.hpp>
cv
::
Mat
cvcloud_load
()
{
cv
::
Mat
cloud
(
1
,
20000
,
CV_32FC3
);
...
...
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