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
83cb28f1
Commit
83cb28f1
authored
Jul 13, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp_viz removed
parent
3e41f064
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
535 additions
and
500 deletions
+535
-500
viz.hpp
modules/viz/include/opencv2/viz.hpp
+7
-4
events.hpp
modules/viz/include/opencv2/viz/events.hpp
+75
-72
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+87
-83
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+33
-30
widget_accessor.hpp
modules/viz/include/opencv2/viz/widget_accessor.hpp
+12
-9
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+0
-0
common.cpp
modules/viz/src/common.cpp
+9
-9
common.h
modules/viz/src/common.h
+111
-108
interactor_style.cpp
modules/viz/src/interactor_style.cpp
+31
-26
interactor_style.h
modules/viz/src/interactor_style.h
+5
-2
mesh_load.cpp
modules/viz/src/mesh_load.cpp
+1
-1
precomp.hpp
modules/viz/src/precomp.hpp
+18
-15
simple_widgets.cpp
modules/viz/src/simple_widgets.cpp
+0
-0
types.cpp
modules/viz/src/types.cpp
+13
-13
viz.cpp
modules/viz/src/viz.cpp
+1
-1
viz3d.cpp
modules/viz/src/viz3d.cpp
+18
-18
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+71
-69
viz_main.cpp
modules/viz/src/viz_main.cpp
+0
-0
viz_types.h
modules/viz/src/viz_types.h
+23
-20
widget.cpp
modules/viz/src/widget.cpp
+20
-20
No files found.
modules/viz/include/opencv2/viz.hpp
View file @
83cb28f1
...
...
@@ -53,12 +53,15 @@
#include <opencv2/viz/viz3d.hpp>
namespace
temp_viz
namespace
cv
{
//! takes coordiante frame data and builds transfrom to global coordinate frame
CV_EXPORTS
Affine3f
makeTransformToGlobal
(
const
Vec3f
&
axis_x
,
const
Vec3f
&
axis_y
,
const
Vec3f
&
axis_z
,
const
Vec3f
&
origin
=
Vec3f
::
all
(
0
));
namespace
viz
{
//! takes coordiante frame data and builds transfrom to global coordinate frame
CV_EXPORTS
Affine3f
makeTransformToGlobal
(
const
Vec3f
&
axis_x
,
const
Vec3f
&
axis_y
,
const
Vec3f
&
axis_z
,
const
Vec3f
&
origin
=
Vec3f
::
all
(
0
));
CV_EXPORTS
Affine3f
makeCameraPose
(
const
Vec3f
&
position
,
const
Vec3f
&
focal_point
,
const
Vec3f
&
up_vector
);
CV_EXPORTS
Affine3f
makeCameraPose
(
const
Vec3f
&
position
,
const
Vec3f
&
focal_point
,
const
Vec3f
&
up_vector
);
}
}
...
...
modules/viz/include/opencv2/viz/events.hpp
View file @
83cb28f1
...
...
@@ -3,79 +3,82 @@
#include <string>
#include <opencv2/viz/types.hpp>
namespace
temp_viz
namespace
cv
{
class
KeyboardEvent
namespace
viz
{
public
:
static
const
unsigned
int
Alt
=
1
;
static
const
unsigned
int
Ctrl
=
2
;
static
const
unsigned
int
Shift
=
4
;
/** \brief Constructor
* \param[in] action true for key was pressed, false for released
* \param[in] key_sym the key-name that caused the action
* \param[in] key the key code that caused the action
* \param[in] alt whether the alt key was pressed at the time where this event was triggered
* \param[in] ctrl whether the ctrl was pressed at the time where this event was triggered
* \param[in] shift whether the shift was pressed at the time where this event was triggered
*/
KeyboardEvent
(
bool
action
,
const
std
::
string
&
key_sym
,
unsigned
char
key
,
bool
alt
,
bool
ctrl
,
bool
shift
);
bool
isAltPressed
()
const
;
bool
isCtrlPressed
()
const
;
bool
isShiftPressed
()
const
;
unsigned
char
getKeyCode
()
const
;
const
String
&
getKeySym
()
const
;
bool
keyDown
()
const
;
bool
keyUp
()
const
;
protected
:
bool
action_
;
unsigned
int
modifiers_
;
unsigned
char
key_code_
;
String
key_sym_
;
};
class
MouseEvent
{
public
:
enum
Type
class
KeyboardEvent
{
MouseMove
=
1
,
MouseButtonPress
,
MouseButtonRelease
,
MouseScrollDown
,
MouseScrollUp
,
MouseDblClick
}
;
enum
MouseButton
public
:
static
const
unsigned
int
Alt
=
1
;
static
const
unsigned
int
Ctrl
=
2
;
static
const
unsigned
int
Shift
=
4
;
/** \brief Constructor
* \param[in] action true for key was pressed, false for released
* \param[in] key_sym the key-name that caused the action
* \param[in] key the key code that caused the action
* \param[in] alt whether the alt key was pressed at the time where this event was triggered
* \param[in] ctrl whether the ctrl was pressed at the time where this event was triggered
* \param[in] shift whether the shift was pressed at the time where this event was triggered
*/
KeyboardEvent
(
bool
action
,
const
std
::
string
&
key_sym
,
unsigned
char
key
,
bool
alt
,
bool
ctrl
,
bool
shift
);
bool
isAltPressed
()
const
;
bool
isCtrlPressed
()
const
;
bool
isShiftPressed
()
const
;
unsigned
char
getKeyCode
()
const
;
const
String
&
getKeySym
()
const
;
bool
keyDown
()
const
;
bool
keyUp
()
const
;
protected
:
bool
action_
;
unsigned
int
modifiers_
;
unsigned
char
key_code_
;
String
key_sym_
;
};
class
MouseEvent
{
NoButton
=
0
,
LeftButton
,
MiddleButton
,
RightButton
,
VScroll
/*other buttons, scroll wheels etc. may follow*/
}
;
MouseEvent
(
const
Type
&
type
,
const
MouseButton
&
button
,
const
Point
&
p
,
bool
alt
,
bool
ctrl
,
bool
shift
);
Type
type
;
MouseButton
button
;
Point
pointer
;
unsigned
int
key_state
;
};
public
:
enum
Type
{
MouseMove
=
1
,
MouseButtonPress
,
MouseButtonRelease
,
MouseScrollDown
,
MouseScrollUp
,
MouseDblClick
}
;
enum
MouseButton
{
NoButton
=
0
,
LeftButton
,
MiddleButton
,
RightButton
,
VScroll
/*other buttons, scroll wheels etc. may follow*/
}
;
MouseEvent
(
const
Type
&
type
,
const
MouseButton
&
button
,
const
Point
&
p
,
bool
alt
,
bool
ctrl
,
bool
shift
);
Type
type
;
MouseButton
button
;
Point
pointer
;
unsigned
int
key_state
;
};
}
}
////////////////////////////////////////////////////////////////////
/// Implementation
inline
temp_
viz
::
KeyboardEvent
::
KeyboardEvent
(
bool
_action
,
const
std
::
string
&
_key_sym
,
unsigned
char
key
,
bool
alt
,
bool
ctrl
,
bool
shift
)
inline
cv
::
viz
::
KeyboardEvent
::
KeyboardEvent
(
bool
_action
,
const
std
::
string
&
_key_sym
,
unsigned
char
key
,
bool
alt
,
bool
ctrl
,
bool
shift
)
:
action_
(
_action
),
modifiers_
(
0
),
key_code_
(
key
),
key_sym_
(
_key_sym
)
{
if
(
alt
)
...
...
@@ -88,15 +91,15 @@ inline temp_viz::KeyboardEvent::KeyboardEvent (bool _action, const std::string&
modifiers_
|=
Shift
;
}
inline
bool
temp_
viz
::
KeyboardEvent
::
isAltPressed
()
const
{
return
(
modifiers_
&
Alt
)
!=
0
;
}
inline
bool
temp_
viz
::
KeyboardEvent
::
isCtrlPressed
()
const
{
return
(
modifiers_
&
Ctrl
)
!=
0
;
}
inline
bool
temp_
viz
::
KeyboardEvent
::
isShiftPressed
()
const
{
return
(
modifiers_
&
Shift
)
!=
0
;
}
inline
unsigned
char
temp_
viz
::
KeyboardEvent
::
getKeyCode
()
const
{
return
key_code_
;
}
inline
const
temp_viz
::
String
&
temp_
viz
::
KeyboardEvent
::
getKeySym
()
const
{
return
key_sym_
;
}
inline
bool
temp_
viz
::
KeyboardEvent
::
keyDown
()
const
{
return
action_
;
}
inline
bool
temp_
viz
::
KeyboardEvent
::
keyUp
()
const
{
return
!
action_
;
}
inline
bool
cv
::
viz
::
KeyboardEvent
::
isAltPressed
()
const
{
return
(
modifiers_
&
Alt
)
!=
0
;
}
inline
bool
cv
::
viz
::
KeyboardEvent
::
isCtrlPressed
()
const
{
return
(
modifiers_
&
Ctrl
)
!=
0
;
}
inline
bool
cv
::
viz
::
KeyboardEvent
::
isShiftPressed
()
const
{
return
(
modifiers_
&
Shift
)
!=
0
;
}
inline
unsigned
char
cv
::
viz
::
KeyboardEvent
::
getKeyCode
()
const
{
return
key_code_
;
}
inline
const
cv
::
String
&
cv
::
viz
::
KeyboardEvent
::
getKeySym
()
const
{
return
key_sym_
;
}
inline
bool
cv
::
viz
::
KeyboardEvent
::
keyDown
()
const
{
return
action_
;
}
inline
bool
cv
::
viz
::
KeyboardEvent
::
keyUp
()
const
{
return
!
action_
;
}
inline
temp_
viz
::
MouseEvent
::
MouseEvent
(
const
Type
&
_type
,
const
MouseButton
&
_button
,
const
Point
&
_p
,
bool
alt
,
bool
ctrl
,
bool
shift
)
inline
cv
::
viz
::
MouseEvent
::
MouseEvent
(
const
Type
&
_type
,
const
MouseButton
&
_button
,
const
Point
&
_p
,
bool
alt
,
bool
ctrl
,
bool
shift
)
:
type
(
_type
),
button
(
_button
),
pointer
(
_p
),
key_state
(
0
)
{
if
(
alt
)
...
...
modules/viz/include/opencv2/viz/types.hpp
View file @
83cb28f1
...
...
@@ -5,105 +5,109 @@
#include <opencv2/core.hpp>
#include <opencv2/core/affine.hpp>
namespace
temp_viz
namespace
cv
{
//qt creator hack
typedef
cv
::
Scalar
Scalar
;
typedef
cv
::
Mat
Mat
;
typedef
std
::
string
String
;
typedef
cv
::
Vec3d
Vec3d
;
typedef
cv
::
Vec3f
Vec3f
;
typedef
cv
::
Vec4d
Vec4d
;
typedef
cv
::
Vec4f
Vec4f
;
typedef
cv
::
Vec2d
Vec2d
;
typedef
cv
::
Vec2i
Vec2i
;
typedef
cv
::
Vec3b
Vec3b
;
typedef
cv
::
Matx33d
Matx33d
;
typedef
cv
::
Affine3f
Affine3f
;
typedef
cv
::
Affine3d
Affine3d
;
typedef
cv
::
Point2i
Point2i
;
typedef
cv
::
Point3f
Point3f
;
typedef
cv
::
Point3d
Point3d
;
typedef
cv
::
Matx44d
Matx44d
;
typedef
cv
::
Matx44f
Matx44f
;
typedef
cv
::
Size
Size
;
typedef
cv
::
Point
Point
;
typedef
cv
::
InputArray
InputArray
;
using
cv
::
Point3_
;
using
cv
::
Vec
;
using
cv
::
Mat_
;
using
cv
::
DataDepth
;
using
cv
::
DataType
;
class
CV_EXPORTS
Color
:
public
Scalar
// //qt creator hack
// typedef cv::Scalar Scalar;
// typedef cv::Mat Mat;
// typedef std::string String;
// typedef cv::Vec3d Vec3d;
// typedef cv::Vec3f Vec3f;
// typedef cv::Vec4d Vec4d;
// typedef cv::Vec4f Vec4f;
// typedef cv::Vec2d Vec2d;
// typedef cv::Vec2i Vec2i;
// typedef cv::Vec3b Vec3b;
// typedef cv::Matx33d Matx33d;
// typedef cv::Affine3f Affine3f;
// typedef cv::Affine3d Affine3d;
// typedef cv::Point2i Point2i;
// typedef cv::Point3f Point3f;
// typedef cv::Point3d Point3d;
// typedef cv::Matx44d Matx44d;
// typedef cv::Matx44f Matx44f;
// typedef cv::Size Size;
// typedef cv::Point Point;
// typedef cv::InputArray InputArray;
// using cv::Point3_;
// using cv::Vec;
// using cv::Mat_;
// using cv::DataDepth;
// using cv::DataType;
// using cv::Ptr;
namespace
viz
{
public
:
Color
();
Color
(
double
gray
);
Color
(
double
blue
,
double
green
,
double
red
);
class
CV_EXPORTS
Color
:
public
Scalar
{
public
:
Color
();
Color
(
double
gray
);
Color
(
double
blue
,
double
green
,
double
red
);
Color
(
const
Scalar
&
color
);
Color
(
const
Scalar
&
color
);
static
Color
black
();
static
Color
blue
();
static
Color
green
();
static
Color
cyan
();
static
Color
black
();
static
Color
blue
();
static
Color
green
();
static
Color
cyan
();
static
Color
red
();
static
Color
magenta
();
static
Color
yellow
();
static
Color
white
();
static
Color
red
();
static
Color
magenta
();
static
Color
yellow
();
static
Color
white
();
static
Color
gray
();
};
static
Color
gray
();
};
struct
CV_EXPORTS
Vertices
{
std
::
vector
<
unsigned
int
>
vertices
;
};
struct
CV_EXPORTS
Vertices
{
std
::
vector
<
unsigned
int
>
vertices
;
};
class
CV_EXPORTS
Mesh3d
{
public
:
typedef
Ptr
<
Mesh3d
>
Ptr
;
class
CV_EXPORTS
Mesh3d
{
public
:
typedef
Ptr
<
Mesh3d
>
Ptr
;
Mat
cloud
,
colors
;
std
::
vector
<
Vertices
>
polygons
;
Mat
cloud
,
colors
;
std
::
vector
<
Vertices
>
polygons
;
static
Mesh3d
::
Ptr
mesh_load
(
const
String
&
file
);
static
Mesh3d
::
Ptr
mesh_load
(
const
String
&
file
);
};
};
/////////////////////////////////////////////////////////////////////////////
/// Utility functions
/////////////////////////////////////////////////////////////////////////////
/// Utility functions
inline
Color
vtkcolor
(
const
Color
&
color
)
{
Color
scaled_color
=
color
*
(
1.0
/
255.0
);
std
::
swap
(
scaled_color
[
0
],
scaled_color
[
2
]);
return
scaled_color
;
}
inline
Color
vtkcolor
(
const
Color
&
color
)
{
Color
scaled_color
=
color
*
(
1.0
/
255.0
);
std
::
swap
(
scaled_color
[
0
],
scaled_color
[
2
]);
return
scaled_color
;
}
inline
Vec3d
vtkpoint
(
const
Point3f
&
point
)
{
return
Vec3d
(
point
.
x
,
point
.
y
,
point
.
z
);
}
template
<
typename
_Tp
>
inline
_Tp
normalized
(
const
_Tp
&
v
)
{
return
v
*
1
/
cv
::
norm
(
v
);
}
inline
bool
isNan
(
float
x
)
{
unsigned
int
*
u
=
reinterpret_cast
<
unsigned
int
*>
(
&
x
);
return
((
u
[
0
]
&
0x7f800000
)
==
0x7f800000
)
&&
(
u
[
0
]
&
0x007fffff
);
}
inline
bool
isNan
(
double
x
)
{
unsigned
int
*
u
=
reinterpret_cast
<
unsigned
int
*>
(
&
x
);
return
(
u
[
1
]
&
0x7ff00000
)
==
0x7ff00000
&&
(
u
[
0
]
!=
0
||
(
u
[
1
]
&
0x000fffff
)
!=
0
);
}
inline
Vec3d
vtkpoint
(
const
Point3f
&
point
)
{
return
Vec3d
(
point
.
x
,
point
.
y
,
point
.
z
);
}
template
<
typename
_Tp
>
inline
_Tp
normalized
(
const
_Tp
&
v
)
{
return
v
*
1
/
cv
::
norm
(
v
);
}
inline
bool
isNan
(
float
x
)
{
unsigned
int
*
u
=
reinterpret_cast
<
unsigned
int
*>
(
&
x
);
return
((
u
[
0
]
&
0x7f800000
)
==
0x7f800000
)
&&
(
u
[
0
]
&
0x007fffff
);
}
template
<
typename
_Tp
,
int
cn
>
inline
bool
isNan
(
const
Vec
<
_Tp
,
cn
>&
v
)
{
return
isNan
(
v
.
val
[
0
])
||
isNan
(
v
.
val
[
1
])
||
isNan
(
v
.
val
[
2
]);
}
inline
bool
isNan
(
double
x
)
{
unsigned
int
*
u
=
reinterpret_cast
<
unsigned
int
*>
(
&
x
);
return
(
u
[
1
]
&
0x7ff00000
)
==
0x7ff00000
&&
(
u
[
0
]
!=
0
||
(
u
[
1
]
&
0x000fffff
)
!=
0
);
}
template
<
typename
_Tp
>
inline
bool
isNan
(
const
Point3_
<
_Tp
>&
p
)
{
return
isNan
(
p
.
x
)
||
isNan
(
p
.
y
)
||
isNan
(
p
.
z
);
}
template
<
typename
_Tp
,
int
cn
>
inline
bool
isNan
(
const
Vec
<
_Tp
,
cn
>&
v
)
{
return
isNan
(
v
.
val
[
0
])
||
isNan
(
v
.
val
[
1
])
||
isNan
(
v
.
val
[
2
]);
}
template
<
typename
_Tp
>
inline
bool
isNan
(
const
Point3_
<
_Tp
>&
p
)
{
return
isNan
(
p
.
x
)
||
isNan
(
p
.
y
)
||
isNan
(
p
.
z
);
}
}
}
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
83cb28f1
...
...
@@ -13,48 +13,51 @@
#include <opencv2/viz/widgets.hpp>
#include <opencv2/viz/events.hpp>
namespace
temp_viz
namespace
cv
{
class
CV_EXPORTS
Viz3d
namespace
viz
{
public
:
class
CV_EXPORTS
Viz3d
{
public
:
typedef
cv
::
Ptr
<
Viz3d
>
Ptr
;
typedef
cv
::
Ptr
<
Viz3d
>
Ptr
;
Viz3d
(
const
String
&
window_name
=
String
());
~
Viz3d
();
Viz3d
(
const
String
&
window_name
=
String
());
~
Viz3d
();
void
setBackgroundColor
(
const
Color
&
color
=
Color
::
black
());
void
setBackgroundColor
(
const
Color
&
color
=
Color
::
black
());
bool
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polygon"
);
bool
updatePolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polygon"
);
bool
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polygon"
);
bool
updatePolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polygon"
);
bool
addPolylineFromPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polyline"
);
bool
addPolylineFromPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polyline"
);
bool
addPolygon
(
const
Mat
&
cloud
,
const
Color
&
color
,
const
String
&
id
=
"polygon"
);
bool
addPolygon
(
const
Mat
&
cloud
,
const
Color
&
color
,
const
String
&
id
=
"polygon"
);
void
spin
();
void
spinOnce
(
int
time
=
1
,
bool
force_redraw
=
false
);
void
spin
();
void
spinOnce
(
int
time
=
1
,
bool
force_redraw
=
false
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
bool
wasStopped
()
const
;
void
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
=
Affine3f
::
Identity
());
void
removeWidget
(
const
String
&
id
);
Widget
getWidget
(
const
String
&
id
)
const
;
void
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
private
:
Viz3d
(
const
Viz3d
&
);
Viz3d
&
operator
=
(
const
Viz3d
&
);
bool
wasStopped
()
const
;
struct
VizImpl
;
VizImpl
*
impl_
;
};
void
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
=
Affine3f
::
Identity
());
void
removeWidget
(
const
String
&
id
);
Widget
getWidget
(
const
String
&
id
)
const
;
void
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
private
:
Viz3d
(
const
Viz3d
&
);
Viz3d
&
operator
=
(
const
Viz3d
&
);
struct
VizImpl
;
VizImpl
*
impl_
;
};
}
}
...
...
modules/viz/include/opencv2/viz/widget_accessor.hpp
View file @
83cb28f1
...
...
@@ -4,15 +4,18 @@
#include <vtkSmartPointer.h>
#include <vtkProp.h>
namespace
temp_viz
namespace
cv
{
class
Widget
;
//The class is only that depends on VTK in its interface.
//It is indended for those users who want to develop own widgets system using VTK library API.
struct
CV_EXPORTS
WidgetAccessor
namespace
viz
{
static
vtkSmartPointer
<
vtkProp
>
getProp
(
const
Widget
&
widget
);
static
void
setProp
(
Widget
&
widget
,
vtkSmartPointer
<
vtkProp
>
prop
);
};
class
Widget
;
//The class is only that depends on VTK in its interface.
//It is indended for those users who want to develop own widgets system using VTK library API.
struct
CV_EXPORTS
WidgetAccessor
{
static
vtkSmartPointer
<
vtkProp
>
getProp
(
const
Widget
&
widget
);
static
void
setProp
(
Widget
&
widget
,
vtkSmartPointer
<
vtkProp
>
prop
);
};
}
}
modules/viz/include/opencv2/viz/widgets.hpp
View file @
83cb28f1
This diff is collapsed.
Click to expand it.
modules/viz/src/common.cpp
View file @
83cb28f1
...
...
@@ -5,7 +5,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////
//Eigen::Matrix4d
temp_
viz::vtkToEigen (vtkMatrix4x4* vtk_matrix)
//Eigen::Matrix4d
cv::
viz::vtkToEigen (vtkMatrix4x4* vtk_matrix)
//{
// Eigen::Matrix4d eigen_matrix = Eigen::Matrix4d::Identity ();
// for (int i=0; i < 4; i++)
...
...
@@ -16,7 +16,7 @@
//}
///////////////////////////////////////////////////////////////////////////////////////////////
//Eigen::Vector2i
temp_
viz::worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height)
//Eigen::Vector2i
cv::
viz::worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height)
//{
// // Transform world to clipping coordinates
// Eigen::Vector4d world (view_projection_matrix * world_pt);
...
...
@@ -34,7 +34,7 @@
//}
/////////////////////////////////////////////////////////////////////////////////////////////
//void
temp_
viz::getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24])
//void
cv::
viz::getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24])
//{
// // Set up the normals
// Eigen::Vector4d normals[6];
...
...
@@ -65,7 +65,7 @@
// }
//}
//int
temp_
viz::cullFrustum (double frustum[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb)
//int
cv::
viz::cullFrustum (double frustum[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb)
//{
// int result = PCL_INSIDE_FRUSTUM;
...
...
@@ -104,7 +104,7 @@
//}
//void
//
temp_
viz::getModelViewPosition (Eigen::Matrix4d model_view_matrix, Eigen::Vector3d &position)
//
cv::
viz::getModelViewPosition (Eigen::Matrix4d model_view_matrix, Eigen::Vector3d &position)
//{
// //Compute eye or position from model view matrix
// Eigen::Matrix4d inverse_model_view_matrix = model_view_matrix.inverse();
...
...
@@ -174,7 +174,7 @@ int hull_vertex_table[43][7] = {
/////////////////////////////////////////////////////////////////////////////////////////////
//float
//
temp_
viz::viewScreenArea (
//
cv::
viz::viewScreenArea (
// const Eigen::Vector3d &eye,
// const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb,
// const Eigen::Matrix4d &view_projection_matrix, int width, int height)
...
...
@@ -261,7 +261,7 @@ int hull_vertex_table[43][7] = {
// for (int i = 0; i < num; i++)
// {
// Eigen::Vector4d world_pt = bounding_box[hull_vertex_table[pos][i]];
// Eigen::Vector2i screen_pt =
temp_
viz::worldToView(world_pt, view_projection_matrix, width, height);
// Eigen::Vector2i screen_pt =
cv::
viz::worldToView(world_pt, view_projection_matrix, width, height);
// // cout << "point[" << i << "]: " << screen_pt.x() << " " << screen_pt.y() << endl;
// dst[i] = Eigen::Vector2d(screen_pt.x (), screen_pt.y ());
// }
...
...
@@ -276,7 +276,7 @@ int hull_vertex_table[43][7] = {
//}
/////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
Camera
::
computeViewMatrix
(
Affine3d
&
view_mat
)
const
void
cv
::
viz
::
Camera
::
computeViewMatrix
(
Affine3d
&
view_mat
)
const
{
//constructs view matrix from camera pos, view up, and the point it is looking at
//this code is based off of gluLookAt http://www.opengl.org/wiki/GluLookAt_code
...
...
@@ -297,7 +297,7 @@ void temp_viz::Camera::computeViewMatrix (Affine3d& view_mat) const
}
///////////////////////////////////////////////////////////////////////
void
temp_
viz
::
Camera
::
computeProjectionMatrix
(
Matx44d
&
proj
)
const
void
cv
::
viz
::
Camera
::
computeProjectionMatrix
(
Matx44d
&
proj
)
const
{
double
top
=
clip
[
0
]
*
tan
(
0.5
*
fovy
);
double
left
=
-
(
top
*
window_size
[
0
])
/
window_size
[
1
];
...
...
modules/viz/src/common.h
View file @
83cb28f1
...
...
@@ -3,121 +3,124 @@
#include <opencv2/core/cvdef.h>
#include <opencv2/core.hpp>
#include <opencv2/viz/types.hpp>
//#include <vtkMatrix4x4.h>
namespace
temp_viz
namespace
cv
{
//CV_EXPORTS Eigen::Matrix4d vtkToEigen (vtkMatrix4x4* vtk_matrix);
//CV_EXPORTS Eigen::Vector2i worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
//CV_EXPORTS void getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24]);
namespace
viz
{
//CV_EXPORTS Eigen::Matrix4d vtkToEigen (vtkMatrix4x4* vtk_matrix);
//CV_EXPORTS Eigen::Vector2i worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
//CV_EXPORTS void getViewFrustum (const Eigen::Matrix4d &view_projection_matrix, double planes[24]);
// enum FrustumCull
// {
// PCL_INSIDE_FRUSTUM,
// PCL_INTERSECT_FRUSTUM,
// PCL_OUTSIDE_FRUSTUM
// };
// enum FrustumCull
// {
// PCL_INSIDE_FRUSTUM,
// PCL_INTERSECT_FRUSTUM,
// PCL_OUTSIDE_FRUSTUM
// };
//CV_EXPORTS int cullFrustum (double planes[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb);
//CV_EXPORTS float viewScreenArea (const Eigen::Vector3d &eye, const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
//CV_EXPORTS int cullFrustum (double planes[24], const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb);
//CV_EXPORTS float viewScreenArea (const Eigen::Vector3d &eye, const Eigen::Vector3d &min_bb, const Eigen::Vector3d &max_bb, const Eigen::Matrix4d &view_projection_matrix, int width, int height);
enum
RenderingProperties
{
VIZ_POINT_SIZE
,
VIZ_OPACITY
,
VIZ_LINE_WIDTH
,
VIZ_FONT_SIZE
,
VIZ_COLOR
,
VIZ_REPRESENTATION
,
VIZ_IMMEDIATE_RENDERING
,
VIZ_SHADING
};
enum
RenderingRepresentationProperties
{
REPRESENTATION_POINTS
,
REPRESENTATION_WIREFRAME
,
REPRESENTATION_SURFACE
};
enum
ShadingRepresentationProperties
{
SHADING_FLAT
,
SHADING_GOURAUD
,
SHADING_PHONG
};
enum
RenderingProperties
{
VIZ_POINT_SIZE
,
VIZ_OPACITY
,
VIZ_LINE_WIDTH
,
VIZ_FONT_SIZE
,
VIZ_COLOR
,
VIZ_REPRESENTATION
,
VIZ_IMMEDIATE_RENDERING
,
VIZ_SHADING
};
enum
RenderingRepresentationProperties
{
REPRESENTATION_POINTS
,
REPRESENTATION_WIREFRAME
,
REPRESENTATION_SURFACE
};
class
CV_EXPORTS
Camera
{
public
:
/** Focal point or lookAt. The view direction can be obtained by (focal-pos).normalized () */
Vec3d
focal
;
/** \brief Position of the camera. */
Vec3d
pos
;
/** \brief Up vector of the camera. */
Vec3d
view_up
;
/** \brief Near/far clipping planes depths */
Vec2d
clip
;
/** \brief Field of view angle in y direction (radians). */
double
fovy
;
// the following variables are the actual position and size of the window on the screen and NOT the viewport!
// except for the size, which is the same the viewport is assumed to be centered and same size as the window.
Vec2i
window_size
;
Vec2i
window_pos
;
/** \brief Computes View matrix for Camera (Based on gluLookAt)
* \param[out] view_mat the resultant matrix
*/
void
computeViewMatrix
(
Affine3d
&
view_mat
)
const
;
/** \brief Computes Projection Matrix for Camera
* \param[out] proj the resultant matrix
*/
void
computeProjectionMatrix
(
Matx44d
&
proj
)
const
;
/** \brief converts point to window coordiantes
* \param[in] pt xyz point to be converted
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
*
* This function computes the projection and view matrix every time.
* It is very inefficient to use this for every point in the point cloud!
*/
void
cvtWindowCoordinates
(
const
cv
::
Point3f
&
pt
,
Vec4d
&
window_cord
)
const
enum
ShadingRepresentationProperties
{
Affine3d
view
;
computeViewMatrix
(
view
);
Matx44d
proj
;
computeProjectionMatrix
(
proj
);
cvtWindowCoordinates
(
pt
,
proj
*
view
.
matrix
,
window_cord
);
return
;
}
/** \brief converts point to window coordiantes
* \param[in] pt xyz point to be converted
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
* \param[in] composite_mat composite transformation matrix (proj*view)
*
* Use this function to compute window coordinates with a precomputed
* transformation function. The typical composite matrix will be
* the projection matrix * the view matrix. However, additional
* matrices like a camera disortion matrix can also be added.
*/
void
cvtWindowCoordinates
(
const
Point3f
&
pt
,
const
Matx44d
&
composite_mat
,
Vec4d
&
window_cord
)
const
SHADING_FLAT
,
SHADING_GOURAUD
,
SHADING_PHONG
};
class
CV_EXPORTS
Camera
{
Vec4d
pte
(
pt
.
x
,
pt
.
y
,
pt
.
z
,
1
);
window_cord
=
composite_mat
*
pte
;
window_cord
=
window_cord
/
window_cord
[
3
];
window_cord
[
0
]
=
(
window_cord
[
0
]
+
1
.
0
)
/
2
.
0
*
window_size
[
0
];
window_cord
[
1
]
=
(
window_cord
[
1
]
+
1
.
0
)
/
2
.
0
*
window_size
[
1
];
window_cord
[
2
]
=
(
window_cord
[
2
]
+
1
.
0
)
/
2
.
0
;
}
};
public
:
/** Focal point or lookAt. The view direction can be obtained by (focal-pos).normalized () */
Vec3d
focal
;
/** \brief Position of the camera. */
Vec3d
pos
;
/** \brief Up vector of the camera. */
Vec3d
view_up
;
/** \brief Near/far clipping planes depths */
Vec2d
clip
;
/** \brief Field of view angle in y direction (radians). */
double
fovy
;
// the following variables are the actual position and size of the window on the screen and NOT the viewport!
// except for the size, which is the same the viewport is assumed to be centered and same size as the window.
Vec2i
window_size
;
Vec2i
window_pos
;
/** \brief Computes View matrix for Camera (Based on gluLookAt)
* \param[out] view_mat the resultant matrix
*/
void
computeViewMatrix
(
Affine3d
&
view_mat
)
const
;
/** \brief Computes Projection Matrix for Camera
* \param[out] proj the resultant matrix
*/
void
computeProjectionMatrix
(
Matx44d
&
proj
)
const
;
/** \brief converts point to window coordiantes
* \param[in] pt xyz point to be converted
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
*
* This function computes the projection and view matrix every time.
* It is very inefficient to use this for every point in the point cloud!
*/
void
cvtWindowCoordinates
(
const
cv
::
Point3f
&
pt
,
Vec4d
&
window_cord
)
const
{
Affine3d
view
;
computeViewMatrix
(
view
);
Matx44d
proj
;
computeProjectionMatrix
(
proj
);
cvtWindowCoordinates
(
pt
,
proj
*
view
.
matrix
,
window_cord
);
return
;
}
/** \brief converts point to window coordiantes
* \param[in] pt xyz point to be converted
* \param[out] window_cord vector containing the pts' window X,Y, Z and 1
* \param[in] composite_mat composite transformation matrix (proj*view)
*
* Use this function to compute window coordinates with a precomputed
* transformation function. The typical composite matrix will be
* the projection matrix * the view matrix. However, additional
* matrices like a camera disortion matrix can also be added.
*/
void
cvtWindowCoordinates
(
const
Point3f
&
pt
,
const
Matx44d
&
composite_mat
,
Vec4d
&
window_cord
)
const
{
Vec4d
pte
(
pt
.
x
,
pt
.
y
,
pt
.
z
,
1
);
window_cord
=
composite_mat
*
pte
;
window_cord
=
window_cord
/
window_cord
[
3
];
window_cord
[
0
]
=
(
window_cord
[
0
]
+
1
.
0
)
/
2
.
0
*
window_size
[
0
];
window_cord
[
1
]
=
(
window_cord
[
1
]
+
1
.
0
)
/
2
.
0
*
window_size
[
1
];
window_cord
[
2
]
=
(
window_cord
[
2
]
+
1
.
0
)
/
2
.
0
;
}
};
}
}
modules/viz/src/interactor_style.cpp
View file @
83cb28f1
...
...
@@ -7,9 +7,9 @@
using
namespace
cv
;
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
Initialize
()
void
cv
::
viz
::
InteractorStyle
::
Initialize
()
{
modifier_
=
temp_
viz
::
InteractorStyle
::
KB_MOD_ALT
;
modifier_
=
cv
::
viz
::
InteractorStyle
::
KB_MOD_ALT
;
// Set windows size (width, height) to unknown (-1)
win_size_
=
Vec2i
(
-
1
,
-
1
);
win_pos_
=
Vec2i
(
0
,
0
);
...
...
@@ -33,7 +33,7 @@ void temp_viz::InteractorStyle::Initialize ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
saveScreenshot
(
const
std
::
string
&
file
)
void
cv
::
viz
::
InteractorStyle
::
saveScreenshot
(
const
std
::
string
&
file
)
{
FindPokedRenderer
(
Interactor
->
GetEventPosition
()[
0
],
Interactor
->
GetEventPosition
()[
1
]);
wif_
->
SetInput
(
Interactor
->
GetRenderWindow
());
...
...
@@ -44,29 +44,29 @@ void temp_viz::InteractorStyle::saveScreenshot (const std::string &file)
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
zoomIn
()
void
cv
::
viz
::
InteractorStyle
::
zoomIn
()
{
FindPokedRenderer
(
Interactor
->
GetEventPosition
()[
0
],
Interactor
->
GetEventPosition
()[
1
]);
// Zoom in
StartDolly
();
double
factor
=
10.0
*
0.2
*
.5
;
Dolly
(
pow
(
1.1
,
factor
));
Dolly
(
std
::
pow
(
1.1
,
factor
));
EndDolly
();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
zoomOut
()
void
cv
::
viz
::
InteractorStyle
::
zoomOut
()
{
FindPokedRenderer
(
Interactor
->
GetEventPosition
()[
0
],
Interactor
->
GetEventPosition
()[
1
]);
// Zoom out
StartDolly
();
double
factor
=
10.0
*
-
0.2
*
.5
;
Dolly
(
pow
(
1.1
,
factor
));
Dolly
(
std
::
pow
(
1.1
,
factor
));
EndDolly
();
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnChar
()
void
cv
::
viz
::
InteractorStyle
::
OnChar
()
{
// Make sure we ignore the same events we handle in OnKeyDown to avoid calling things twice
FindPokedRenderer
(
Interactor
->
GetEventPosition
()[
0
],
Interactor
->
GetEventPosition
()[
1
]);
...
...
@@ -133,7 +133,7 @@ void temp_viz::InteractorStyle::OnChar ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
)
void
cv
::
viz
::
InteractorStyle
::
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
// Register the callback function and store the user data
mouseCallback_
=
callback
;
...
...
@@ -141,7 +141,7 @@ void temp_viz::InteractorStyle::registerMouseCallback(void (*callback)(const Mou
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
void
cv
::
viz
::
InteractorStyle
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
// Register the callback function and store the user data
keyboardCallback_
=
callback
;
...
...
@@ -150,7 +150,7 @@ void temp_viz::InteractorStyle::registerKeyboardCallback(void (*callback)(const
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnKeyDown
()
cv
::
viz
::
InteractorStyle
::
OnKeyDown
()
{
if
(
!
init_
)
{
...
...
@@ -507,7 +507,7 @@ temp_viz::InteractorStyle::OnKeyDown ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnKeyUp
()
void
cv
::
viz
::
InteractorStyle
::
OnKeyUp
()
{
KeyboardEvent
event
(
false
,
Interactor
->
GetKeySym
(),
Interactor
->
GetKeyCode
(),
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
// Check if there is a keyboard callback registered
...
...
@@ -518,7 +518,7 @@ void temp_viz::InteractorStyle::OnKeyUp ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnMouseMove
()
void
cv
::
viz
::
InteractorStyle
::
OnMouseMove
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseMove
,
MouseEvent
::
NoButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
...
...
@@ -528,7 +528,7 @@ void temp_viz::InteractorStyle::OnMouseMove ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnLeftButtonDown
()
void
cv
::
viz
::
InteractorStyle
::
OnLeftButtonDown
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
::
Type
type
=
(
Interactor
->
GetRepeatCount
()
==
0
)
?
MouseEvent
::
MouseButtonPress
:
MouseEvent
::
MouseDblClick
;
...
...
@@ -539,7 +539,7 @@ void temp_viz::InteractorStyle::OnLeftButtonDown ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnLeftButtonUp
()
void
cv
::
viz
::
InteractorStyle
::
OnLeftButtonUp
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseButtonRelease
,
MouseEvent
::
LeftButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
...
...
@@ -549,7 +549,7 @@ void temp_viz::InteractorStyle::OnLeftButtonUp ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnMiddleButtonDown
()
void
cv
::
viz
::
InteractorStyle
::
OnMiddleButtonDown
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
...
...
@@ -561,7 +561,7 @@ void temp_viz::InteractorStyle::OnMiddleButtonDown ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnMiddleButtonUp
()
void
cv
::
viz
::
InteractorStyle
::
OnMiddleButtonUp
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseButtonRelease
,
MouseEvent
::
MiddleButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
...
...
@@ -571,7 +571,7 @@ void temp_viz::InteractorStyle::OnMiddleButtonUp ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnRightButtonDown
()
void
cv
::
viz
::
InteractorStyle
::
OnRightButtonDown
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
...
...
@@ -583,7 +583,7 @@ void temp_viz::InteractorStyle::OnRightButtonDown ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnRightButtonUp
()
void
cv
::
viz
::
InteractorStyle
::
OnRightButtonUp
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseButtonRelease
,
MouseEvent
::
RightButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
...
...
@@ -593,7 +593,7 @@ void temp_viz::InteractorStyle::OnRightButtonUp ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnMouseWheelForward
()
void
cv
::
viz
::
InteractorStyle
::
OnMouseWheelForward
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseScrollUp
,
MouseEvent
::
VScroll
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
...
...
@@ -625,7 +625,7 @@ void temp_viz::InteractorStyle::OnMouseWheelForward ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnMouseWheelBackward
()
void
cv
::
viz
::
InteractorStyle
::
OnMouseWheelBackward
()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseScrollDown
,
MouseEvent
::
VScroll
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
...
...
@@ -658,7 +658,7 @@ void temp_viz::InteractorStyle::OnMouseWheelBackward ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
temp_
viz
::
InteractorStyle
::
OnTimer
()
void
cv
::
viz
::
InteractorStyle
::
OnTimer
()
{
if
(
!
init_
)
{
...
...
@@ -676,10 +676,15 @@ void temp_viz::InteractorStyle::OnTimer ()
}
namespace
temp_viz
{
// Standard VTK macro for *New ()
vtkStandardNewMacro
(
InteractorStyle
);
namespace
cv
{
namespace
viz
{
//Standard VTK macro for *New()
vtkStandardNewMacro
(
InteractorStyle
)
}
}
modules/viz/src/interactor_style.h
View file @
83cb28f1
...
...
@@ -3,8 +3,10 @@
#include "viz_types.h"
#include <opencv2/viz/events.hpp>
namespace
temp_viz
namespace
cv
{
namespace
viz
{
/** \brief PCLVisualizerInteractorStyle defines an unique, custom VTK
* based interactory style for PCL Visualizer applications. Besides
* defining the rendering style, we also create a list of custom actions
...
...
@@ -54,7 +56,7 @@ namespace temp_viz
/** \brief Pass a pointer to the actor map
* \param[in] actors the actor map that will be used with this style
*/
inline
void
setCloudActorMap
(
const
cv
::
Ptr
<
CloudActorMap
>&
actors
)
{
actors_
=
actors
;
}
inline
void
setCloudActorMap
(
const
Ptr
<
CloudActorMap
>&
actors
)
{
actors_
=
actors
;
}
/** \brief Pass a set of renderers to the interactor style.
* \param[in] rens the vtkRendererCollection to use
...
...
@@ -152,4 +154,5 @@ namespace temp_viz
/** \brief MouseEvent callback user data */
void
*
mouse_callback_cookie_
;
};
}
}
modules/viz/src/mesh_load.cpp
View file @
83cb28f1
...
...
@@ -6,7 +6,7 @@
#include <vtkPointData.h>
#include <vtkCellArray.h>
temp_viz
::
Mesh3d
::
Ptr
temp_
viz
::
Mesh3d
::
mesh_load
(
const
String
&
file
)
cv
::
viz
::
Mesh3d
::
Ptr
cv
::
viz
::
Mesh3d
::
mesh_load
(
const
String
&
file
)
{
Mesh3d
::
Ptr
mesh
=
new
Mesh3d
();
...
...
modules/viz/src/precomp.hpp
View file @
83cb28f1
...
...
@@ -158,23 +158,26 @@
#include "opencv2/viz/widget_accessor.hpp"
#include <opencv2/calib3d.hpp>
namespace
temp_viz
namespace
cv
{
template
<
typename
_Tp
>
Vec
<
_Tp
,
3
>*
vtkpoints_data
(
vtkSmartPointer
<
vtkPoints
>&
points
);
template
<>
static
inline
Vec3f
*
vtkpoints_data
<
float
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
namespace
viz
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_FLOAT
);
vtkDataArray
*
data
=
points
->
GetData
();
float
*
pointer
=
static_cast
<
vtkFloatArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3f
*>
(
pointer
);
}
template
<
typename
_Tp
>
Vec
<
_Tp
,
3
>*
vtkpoints_data
(
vtkSmartPointer
<
vtkPoints
>&
points
);
template
<>
static
inline
Vec3d
*
vtkpoints_data
<
double
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_DOUBLE
);
vtkDataArray
*
data
=
points
->
GetData
();
double
*
pointer
=
static_cast
<
vtkDoubleArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3d
*>
(
pointer
);
template
<>
static
inline
Vec3f
*
vtkpoints_data
<
float
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_FLOAT
);
vtkDataArray
*
data
=
points
->
GetData
();
float
*
pointer
=
static_cast
<
vtkFloatArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3f
*>
(
pointer
);
}
template
<>
static
inline
Vec3d
*
vtkpoints_data
<
double
>
(
vtkSmartPointer
<
vtkPoints
>&
points
)
{
CV_Assert
(
points
->
GetDataType
()
==
VTK_DOUBLE
);
vtkDataArray
*
data
=
points
->
GetData
();
double
*
pointer
=
static_cast
<
vtkDoubleArray
*>
(
data
)
->
GetPointer
(
0
);
return
reinterpret_cast
<
Vec3d
*>
(
pointer
);
}
}
}
modules/viz/src/simple_widgets.cpp
View file @
83cb28f1
This diff is collapsed.
Click to expand it.
modules/viz/src/types.cpp
View file @
83cb28f1
...
...
@@ -3,20 +3,20 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////
/// cv::viz::Color
temp_
viz
::
Color
::
Color
()
:
Scalar
(
0
,
0
,
0
)
{}
temp_
viz
::
Color
::
Color
(
double
gray
)
:
Scalar
(
gray
,
gray
,
gray
)
{}
temp_
viz
::
Color
::
Color
(
double
blue
,
double
green
,
double
red
)
:
Scalar
(
blue
,
green
,
red
)
{}
temp_
viz
::
Color
::
Color
(
const
Scalar
&
color
)
:
Scalar
(
color
)
{}
cv
::
viz
::
Color
::
Color
()
:
Scalar
(
0
,
0
,
0
)
{}
cv
::
viz
::
Color
::
Color
(
double
gray
)
:
Scalar
(
gray
,
gray
,
gray
)
{}
cv
::
viz
::
Color
::
Color
(
double
blue
,
double
green
,
double
red
)
:
Scalar
(
blue
,
green
,
red
)
{}
cv
::
viz
::
Color
::
Color
(
const
Scalar
&
color
)
:
Scalar
(
color
)
{}
temp_viz
::
Color
temp_
viz
::
Color
::
black
()
{
return
Color
(
0
,
0
,
0
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
green
()
{
return
Color
(
0
,
255
,
0
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
blue
()
{
return
Color
(
255
,
0
,
0
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
cyan
()
{
return
Color
(
255
,
255
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
black
()
{
return
Color
(
0
,
0
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
green
()
{
return
Color
(
0
,
255
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
blue
()
{
return
Color
(
255
,
0
,
0
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
cyan
()
{
return
Color
(
255
,
255
,
0
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
red
()
{
return
Color
(
0
,
0
,
255
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
magenta
()
{
return
Color
(
0
,
255
,
255
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
yellow
()
{
return
Color
(
255
,
0
,
255
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
white
()
{
return
Color
(
255
,
255
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
red
()
{
return
Color
(
0
,
0
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
magenta
()
{
return
Color
(
0
,
255
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
yellow
()
{
return
Color
(
255
,
0
,
255
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
white
()
{
return
Color
(
255
,
255
,
255
);
}
temp_viz
::
Color
temp_
viz
::
Color
::
gray
()
{
return
Color
(
128
,
128
,
128
);
}
cv
::
viz
::
Color
cv
::
viz
::
Color
::
gray
()
{
return
Color
(
128
,
128
,
128
);
}
modules/viz/src/viz.cpp
View file @
83cb28f1
#include "precomp.hpp"
cv
::
Affine3f
temp_
viz
::
makeTransformToGlobal
(
const
Vec3f
&
axis_x
,
const
Vec3f
&
axis_y
,
const
Vec3f
&
axis_z
,
const
Vec3f
&
origin
)
cv
::
Affine3f
cv
::
viz
::
makeTransformToGlobal
(
const
Vec3f
&
axis_x
,
const
Vec3f
&
axis_y
,
const
Vec3f
&
axis_z
,
const
Vec3f
&
origin
)
{
Affine3f
::
Mat3
R
;
R
.
val
[
0
]
=
axis_x
.
val
[
0
];
...
...
modules/viz/src/viz3d.cpp
View file @
83cb28f1
...
...
@@ -2,89 +2,89 @@
#include "viz3d_impl.hpp"
temp_
viz
::
Viz3d
::
Viz3d
(
const
String
&
window_name
)
:
impl_
(
new
VizImpl
(
window_name
))
cv
::
viz
::
Viz3d
::
Viz3d
(
const
String
&
window_name
)
:
impl_
(
new
VizImpl
(
window_name
))
{
}
temp_
viz
::
Viz3d
::~
Viz3d
()
cv
::
viz
::
Viz3d
::~
Viz3d
()
{
delete
impl_
;
}
void
temp_
viz
::
Viz3d
::
setBackgroundColor
(
const
Color
&
color
)
void
cv
::
viz
::
Viz3d
::
setBackgroundColor
(
const
Color
&
color
)
{
impl_
->
setBackgroundColor
(
color
);
}
bool
temp_
viz
::
Viz3d
::
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
bool
cv
::
viz
::
Viz3d
::
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
{
return
impl_
->
addPolygonMesh
(
mesh
,
Mat
(),
id
);
}
bool
temp_
viz
::
Viz3d
::
updatePolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
bool
cv
::
viz
::
Viz3d
::
updatePolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
{
return
impl_
->
updatePolygonMesh
(
mesh
,
Mat
(),
id
);
}
bool
temp_
viz
::
Viz3d
::
addPolylineFromPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
bool
cv
::
viz
::
Viz3d
::
addPolylineFromPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
{
return
impl_
->
addPolylineFromPolygonMesh
(
mesh
,
id
);
}
bool
temp_
viz
::
Viz3d
::
addPolygon
(
const
Mat
&
cloud
,
const
Color
&
color
,
const
String
&
id
)
bool
cv
::
viz
::
Viz3d
::
addPolygon
(
const
Mat
&
cloud
,
const
Color
&
color
,
const
String
&
id
)
{
return
impl_
->
addPolygon
(
cloud
,
color
,
id
);
}
void
temp_
viz
::
Viz3d
::
spin
()
void
cv
::
viz
::
Viz3d
::
spin
()
{
impl_
->
spin
();
}
void
temp_
viz
::
Viz3d
::
spinOnce
(
int
time
,
bool
force_redraw
)
void
cv
::
viz
::
Viz3d
::
spinOnce
(
int
time
,
bool
force_redraw
)
{
impl_
->
spinOnce
(
time
,
force_redraw
);
}
void
temp_
viz
::
Viz3d
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
void
cv
::
viz
::
Viz3d
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
impl_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
void
temp_
viz
::
Viz3d
::
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
)
void
cv
::
viz
::
Viz3d
::
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
impl_
->
registerMouseCallback
(
callback
,
cookie
);
}
bool
temp_
viz
::
Viz3d
::
wasStopped
()
const
{
return
impl_
->
wasStopped
();
}
bool
cv
::
viz
::
Viz3d
::
wasStopped
()
const
{
return
impl_
->
wasStopped
();
}
void
temp_
viz
::
Viz3d
::
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
)
void
cv
::
viz
::
Viz3d
::
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
)
{
impl_
->
showWidget
(
id
,
widget
,
pose
);
}
void
temp_
viz
::
Viz3d
::
removeWidget
(
const
String
&
id
)
void
cv
::
viz
::
Viz3d
::
removeWidget
(
const
String
&
id
)
{
impl_
->
removeWidget
(
id
);
}
temp_viz
::
Widget
temp_
viz
::
Viz3d
::
getWidget
(
const
String
&
id
)
const
cv
::
viz
::
Widget
cv
::
viz
::
Viz3d
::
getWidget
(
const
String
&
id
)
const
{
return
impl_
->
getWidget
(
id
);
}
void
temp_
viz
::
Viz3d
::
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
void
cv
::
viz
::
Viz3d
::
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
setWidgetPose
(
id
,
pose
);
}
void
temp_
viz
::
Viz3d
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
void
cv
::
viz
::
Viz3d
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
updateWidgetPose
(
id
,
pose
);
}
temp_viz
::
Affine3f
temp_
viz
::
Viz3d
::
getWidgetPose
(
const
String
&
id
)
const
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
getWidgetPose
(
const
String
&
id
)
const
{
return
impl_
->
getWidgetPose
(
id
);
}
modules/viz/src/viz3d_impl.hpp
View file @
83cb28f1
...
...
@@ -10,7 +10,7 @@
#include <opencv2/viz/viz3d.hpp>
struct
temp_
viz
::
Viz3d
::
VizImpl
struct
cv
::
viz
::
Viz3d
::
VizImpl
{
public
:
typedef
cv
::
Ptr
<
VizImpl
>
Ptr
;
...
...
@@ -280,91 +280,93 @@ private:
namespace
temp_viz
namespace
cv
{
namespace
viz
{
//void getTransformationMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternionf& orientation, Eigen::Matrix4f &transformation);
//void getTransformationMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternionf& orientation, Eigen::Matrix4f &transformation);
//void convertToVtkMatrix (const Eigen::Matrix4f &m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
void
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
,
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
);
void
convertToCvMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
cv
::
Matx44f
&
m
);
//void convertToVtkMatrix (const Eigen::Matrix4f &m, vtkSmartPointer<vtkMatrix4x4> &vtk_matrix);
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
);
cv
::
Matx44f
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
);
void
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
,
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
);
void
convertToCvMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
cv
::
Matx44f
&
m
);
/** \brief Convert origin and orientation to vtkMatrix4x4
* \param[in] origin the point cloud origin
* \param[in] orientation the point cloud orientation
* \param[out] vtk_matrix the resultant VTK 4x4 matrix
*/
void
convertToVtkMatrix
(
const
Eigen
::
Vector4f
&
origin
,
const
Eigen
::
Quaternion
<
float
>
&
orientation
,
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
);
void
convertToEigenMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
Eigen
::
Matrix4f
&
m
);
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
);
cv
::
Matx44f
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
);
/** \brief Convert origin and orientation to vtkMatrix4x4
* \param[in] origin the point cloud origin
* \param[in] orientation the point cloud orientation
* \param[out] vtk_matrix the resultant VTK 4x4 matrix
*/
void
convertToVtkMatrix
(
const
Eigen
::
Vector4f
&
origin
,
const
Eigen
::
Quaternion
<
float
>
&
orientation
,
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
);
void
convertToEigenMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
Eigen
::
Matrix4f
&
m
);
struct
NanFilter
{
template
<
typename
_Tp
,
typename
_Msk
>
struct
Impl
{
typedef
Vec
<
_Tp
,
3
>
_Out
;
st
atic
_Out
*
copy
(
const
Mat
&
source
,
_Out
*
output
,
const
Mat
&
nan_mask
)
st
ruct
NanFilter
{
CV_Assert
(
DataDepth
<
_Tp
>::
value
==
source
.
depth
()
&&
source
.
size
()
==
nan_mask
.
size
());
CV_Assert
(
nan_mask
.
channels
()
==
3
||
nan_mask
.
channels
()
==
4
);
CV_DbgAssert
(
DataDepth
<
_Msk
>::
value
==
nan_mask
.
depth
());
int
s_chs
=
source
.
channels
();
int
m_chs
=
nan_mask
.
channels
();
for
(
int
y
=
0
;
y
<
source
.
rows
;
++
y
)
template
<
typename
_Tp
,
typename
_Msk
>
struct
Impl
{
const
_Tp
*
srow
=
source
.
ptr
<
_Tp
>
(
y
);
const
_Msk
*
mrow
=
nan_mask
.
ptr
<
_Msk
>
(
y
);
for
(
int
x
=
0
;
x
<
source
.
cols
;
++
x
,
srow
+=
s_chs
,
mrow
+=
m_chs
)
if
(
!
isNan
(
mrow
[
0
])
&&
!
isNan
(
mrow
[
1
])
&&
!
isNan
(
mrow
[
2
]))
*
output
++
=
_Out
(
srow
);
}
return
output
;
}
};
typedef
Vec
<
_Tp
,
3
>
_Out
;
static
_Out
*
copy
(
const
Mat
&
source
,
_Out
*
output
,
const
Mat
&
nan_mask
)
{
CV_Assert
(
DataDepth
<
_Tp
>::
value
==
source
.
depth
()
&&
source
.
size
()
==
nan_mask
.
size
());
CV_Assert
(
nan_mask
.
channels
()
==
3
||
nan_mask
.
channels
()
==
4
);
CV_DbgAssert
(
DataDepth
<
_Msk
>::
value
==
nan_mask
.
depth
());
int
s_chs
=
source
.
channels
();
int
m_chs
=
nan_mask
.
channels
();
for
(
int
y
=
0
;
y
<
source
.
rows
;
++
y
)
{
const
_Tp
*
srow
=
source
.
ptr
<
_Tp
>
(
y
);
const
_Msk
*
mrow
=
nan_mask
.
ptr
<
_Msk
>
(
y
);
for
(
int
x
=
0
;
x
<
source
.
cols
;
++
x
,
srow
+=
s_chs
,
mrow
+=
m_chs
)
if
(
!
isNan
(
mrow
[
0
])
&&
!
isNan
(
mrow
[
1
])
&&
!
isNan
(
mrow
[
2
]))
*
output
++
=
_Out
(
srow
);
}
return
output
;
}
};
template
<
typename
_Tp
>
static
inline
Vec
<
_Tp
,
3
>*
copy
(
const
Mat
&
source
,
Vec
<
_Tp
,
3
>*
output
,
const
Mat
&
nan_mask
)
{
CV_Assert
(
nan_mask
.
depth
()
==
CV_32F
||
nan_mask
.
depth
()
==
CV_64F
);
template
<
typename
_Tp
>
static
inline
Vec
<
_Tp
,
3
>*
copy
(
const
Mat
&
source
,
Vec
<
_Tp
,
3
>*
output
,
const
Mat
&
nan_mask
)
{
CV_Assert
(
nan_mask
.
depth
()
==
CV_32F
||
nan_mask
.
depth
()
==
CV_64F
);
typedef
Vec
<
_Tp
,
3
>*
(
*
copy_func
)(
const
Mat
&
,
Vec
<
_Tp
,
3
>*
,
const
Mat
&
);
const
static
copy_func
table
[
2
]
=
{
&
NanFilter
::
Impl
<
_Tp
,
float
>::
copy
,
&
NanFilter
::
Impl
<
_Tp
,
double
>::
copy
};
typedef
Vec
<
_Tp
,
3
>*
(
*
copy_func
)(
const
Mat
&
,
Vec
<
_Tp
,
3
>*
,
const
Mat
&
);
const
static
copy_func
table
[
2
]
=
{
&
NanFilter
::
Impl
<
_Tp
,
float
>::
copy
,
&
NanFilter
::
Impl
<
_Tp
,
double
>::
copy
};
return
table
[
nan_mask
.
depth
()
-
5
](
source
,
output
,
nan_mask
);
}
};
return
table
[
nan_mask
.
depth
()
-
5
](
source
,
output
,
nan_mask
);
}
};
struct
ApplyAffine
{
const
Affine3f
&
affine_
;
ApplyAffine
(
const
Affine3f
&
affine
)
:
affine_
(
affine
)
{}
struct
ApplyAffine
{
const
Affine3f
&
affine_
;
ApplyAffine
(
const
Affine3f
&
affine
)
:
affine_
(
affine
)
{}
template
<
typename
_Tp
>
Point3_
<
_Tp
>
operator
()(
const
Point3_
<
_Tp
>&
p
)
const
{
return
affine_
*
p
;
}
template
<
typename
_Tp
>
Point3_
<
_Tp
>
operator
()(
const
Point3_
<
_Tp
>&
p
)
const
{
return
affine_
*
p
;
}
template
<
typename
_Tp
>
Vec
<
_Tp
,
3
>
operator
()(
const
Vec
<
_Tp
,
3
>&
v
)
const
{
const
float
*
m
=
affine_
.
matrix
.
val
;
template
<
typename
_Tp
>
Vec
<
_Tp
,
3
>
operator
()(
const
Vec
<
_Tp
,
3
>&
v
)
const
{
const
float
*
m
=
affine_
.
matrix
.
val
;
Vec
<
_Tp
,
3
>
result
;
result
[
0
]
=
(
_Tp
)(
m
[
0
]
*
v
[
0
]
+
m
[
1
]
*
v
[
1
]
+
m
[
2
]
*
v
[
2
]
+
m
[
3
]);
result
[
1
]
=
(
_Tp
)(
m
[
4
]
*
v
[
0
]
+
m
[
5
]
*
v
[
1
]
+
m
[
6
]
*
v
[
2
]
+
m
[
7
]);
result
[
2
]
=
(
_Tp
)(
m
[
8
]
*
v
[
0
]
+
m
[
9
]
*
v
[
1
]
+
m
[
10
]
*
v
[
2
]
+
m
[
11
]);
return
result
;
}
Vec
<
_Tp
,
3
>
result
;
result
[
0
]
=
(
_Tp
)(
m
[
0
]
*
v
[
0
]
+
m
[
1
]
*
v
[
1
]
+
m
[
2
]
*
v
[
2
]
+
m
[
3
]);
result
[
1
]
=
(
_Tp
)(
m
[
4
]
*
v
[
0
]
+
m
[
5
]
*
v
[
1
]
+
m
[
6
]
*
v
[
2
]
+
m
[
7
]);
result
[
2
]
=
(
_Tp
)(
m
[
8
]
*
v
[
0
]
+
m
[
9
]
*
v
[
1
]
+
m
[
10
]
*
v
[
2
]
+
m
[
11
]);
return
result
;
private
:
ApplyAffine
(
const
ApplyAffine
&
);
ApplyAffine
&
operator
=
(
const
ApplyAffine
&
);
};
}
private
:
ApplyAffine
(
const
ApplyAffine
&
);
ApplyAffine
&
operator
=
(
const
ApplyAffine
&
);
};
}
modules/viz/src/viz_main.cpp
View file @
83cb28f1
This diff is collapsed.
Click to expand it.
modules/viz/src/viz_types.h
View file @
83cb28f1
...
...
@@ -2,30 +2,33 @@
#include "precomp.hpp"
namespace
temp_viz
namespace
cv
{
struct
CV_EXPORTS
CloudActor
namespace
viz
{
/** \brief The actor holding the data to render. */
vtkSmartPointer
<
vtkLODActor
>
actor
;
struct
CV_EXPORTS
CloudActor
{
/** \brief The actor holding the data to render. */
vtkSmartPointer
<
vtkLODActor
>
actor
;
/** \brief The viewpoint transformation matrix. */
vtkSmartPointer
<
vtkMatrix4x4
>
viewpoint_transformation_
;
/** \brief The viewpoint transformation matrix. */
vtkSmartPointer
<
vtkMatrix4x4
>
viewpoint_transformation_
;
/** \brief Internal cell array. Used for optimizing updatePointCloud. */
vtkSmartPointer
<
vtkIdTypeArray
>
cells
;
};
// TODO This will be used to contain both cloud and shape actors
struct
CV_EXPORTS
WidgetActor
{
vtkSmartPointer
<
vtkProp
>
actor
;
vtkSmartPointer
<
vtkMatrix4x4
>
viewpoint_transformation_
;
vtkSmartPointer
<
vtkIdTypeArray
>
cells
;
};
/** \brief Internal cell array. Used for optimizing updatePointCloud. */
vtkSmartPointer
<
vtkIdTypeArray
>
cells
;
};
// TODO This will be used to contain both cloud and shape actors
struct
CV_EXPORTS
WidgetActor
{
vtkSmartPointer
<
vtkProp
>
actor
;
vtkSmartPointer
<
vtkMatrix4x4
>
viewpoint_transformation_
;
vtkSmartPointer
<
vtkIdTypeArray
>
cells
;
};
typedef
std
::
map
<
std
::
string
,
CloudActor
>
CloudActorMap
;
typedef
std
::
map
<
std
::
string
,
vtkSmartPointer
<
vtkProp
>
>
ShapeActorMap
;
typedef
std
::
map
<
std
::
string
,
WidgetActor
>
WidgetActorMap
;
typedef
std
::
map
<
std
::
string
,
CloudActor
>
CloudActorMap
;
typedef
std
::
map
<
std
::
string
,
vtkSmartPointer
<
vtkProp
>
>
ShapeActorMap
;
typedef
std
::
map
<
std
::
string
,
WidgetActor
>
WidgetActorMap
;
}
}
modules/viz/src/widget.cpp
View file @
83cb28f1
...
...
@@ -3,7 +3,7 @@
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget implementation
class
temp_
viz
::
Widget
::
Impl
class
cv
::
viz
::
Widget
::
Impl
{
public
:
vtkSmartPointer
<
vtkProp
>
prop
;
...
...
@@ -12,17 +12,17 @@ public:
Impl
()
:
prop
(
0
)
{}
};
temp_
viz
::
Widget
::
Widget
()
:
impl_
(
0
)
cv
::
viz
::
Widget
::
Widget
()
:
impl_
(
0
)
{
create
();
}
temp_
viz
::
Widget
::
Widget
(
const
Widget
&
other
)
:
impl_
(
other
.
impl_
)
cv
::
viz
::
Widget
::
Widget
(
const
Widget
&
other
)
:
impl_
(
other
.
impl_
)
{
if
(
impl_
)
CV_XADD
(
&
impl_
->
ref_counter
,
1
);
}
temp_viz
::
Widget
&
temp_
viz
::
Widget
::
operator
=
(
const
Widget
&
other
)
cv
::
viz
::
Widget
&
cv
::
viz
::
Widget
::
operator
=
(
const
Widget
&
other
)
{
if
(
this
!=
&
other
)
{
...
...
@@ -33,19 +33,19 @@ temp_viz::Widget& temp_viz::Widget::operator=(const Widget &other)
return
*
this
;
}
temp_
viz
::
Widget
::~
Widget
()
cv
::
viz
::
Widget
::~
Widget
()
{
release
();
}
void
temp_
viz
::
Widget
::
create
()
void
cv
::
viz
::
Widget
::
create
()
{
if
(
impl_
)
release
();
impl_
=
new
Impl
();
impl_
->
ref_counter
=
1
;
}
void
temp_
viz
::
Widget
::
release
()
void
cv
::
viz
::
Widget
::
release
()
{
if
(
impl_
&&
CV_XADD
(
&
impl_
->
ref_counter
,
-
1
)
==
1
)
{
...
...
@@ -57,12 +57,12 @@ void temp_viz::Widget::release()
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget accessor implementaion
vtkSmartPointer
<
vtkProp
>
temp_
viz
::
WidgetAccessor
::
getProp
(
const
Widget
&
widget
)
vtkSmartPointer
<
vtkProp
>
cv
::
viz
::
WidgetAccessor
::
getProp
(
const
Widget
&
widget
)
{
return
widget
.
impl_
->
prop
;
}
void
temp_
viz
::
WidgetAccessor
::
setProp
(
Widget
&
widget
,
vtkSmartPointer
<
vtkProp
>
prop
)
void
cv
::
viz
::
WidgetAccessor
::
setProp
(
Widget
&
widget
,
vtkSmartPointer
<
vtkProp
>
prop
)
{
widget
.
impl_
->
prop
=
prop
;
}
...
...
@@ -70,18 +70,18 @@ void temp_viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp>
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget3D implementation
struct
temp_
viz
::
Widget3D
::
MatrixConverter
struct
cv
::
viz
::
Widget3D
::
MatrixConverter
{
static
cv
::
Matx44f
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
)
static
Matx44f
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
)
{
cv
::
Matx44f
m
;
Matx44f
m
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
m
(
i
,
k
)
=
vtk_matrix
->
GetElement
(
i
,
k
);
return
m
;
}
static
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
)
static
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
Matx44f
&
m
)
{
vtkSmartPointer
<
vtkMatrix4x4
>
vtk_matrix
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
for
(
int
i
=
0
;
i
<
4
;
i
++
)
...
...
@@ -91,7 +91,7 @@ struct temp_viz::Widget3D::MatrixConverter
}
};
void
temp_
viz
::
Widget3D
::
setPose
(
const
Affine3f
&
pose
)
void
cv
::
viz
::
Widget3D
::
setPose
(
const
Affine3f
&
pose
)
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
...
...
@@ -101,7 +101,7 @@ void temp_viz::Widget3D::setPose(const Affine3f &pose)
actor
->
Modified
();
}
void
temp_
viz
::
Widget3D
::
updatePose
(
const
Affine3f
&
pose
)
void
cv
::
viz
::
Widget3D
::
updatePose
(
const
Affine3f
&
pose
)
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
...
...
@@ -121,7 +121,7 @@ void temp_viz::Widget3D::updatePose(const Affine3f &pose)
actor
->
Modified
();
}
temp_viz
::
Affine3f
temp_
viz
::
Widget3D
::
getPose
()
const
cv
::
Affine3f
cv
::
viz
::
Widget3D
::
getPose
()
const
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
...
...
@@ -131,7 +131,7 @@ temp_viz::Affine3f temp_viz::Widget3D::getPose() const
return
Affine3f
(
matrix_cv
);
}
void
temp_
viz
::
Widget3D
::
setColor
(
const
Color
&
color
)
void
cv
::
viz
::
Widget3D
::
setColor
(
const
Color
&
color
)
{
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
vtkActor
*
actor
=
vtkActor
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
...
...
@@ -148,7 +148,7 @@ void temp_viz::Widget3D::setColor(const Color &color)
actor
->
Modified
();
}
template
<>
temp_viz
::
Widget3D
temp_viz
::
Widget
::
cast
<
temp_
viz
::
Widget3D
>
()
template
<>
cv
::
viz
::
Widget3D
cv
::
viz
::
Widget
::
cast
<
cv
::
viz
::
Widget3D
>
()
{
vtkProp3D
*
actor
=
vtkProp3D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
...
...
@@ -161,7 +161,7 @@ template<> temp_viz::Widget3D temp_viz::Widget::cast<temp_viz::Widget3D>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget2D implementation
void
temp_
viz
::
Widget2D
::
setColor
(
const
Color
&
color
)
void
cv
::
viz
::
Widget2D
::
setColor
(
const
Color
&
color
)
{
vtkActor2D
*
actor
=
vtkActor2D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
...
...
@@ -170,7 +170,7 @@ void temp_viz::Widget2D::setColor(const Color &color)
actor
->
Modified
();
}
template
<>
temp_viz
::
Widget2D
temp_viz
::
Widget
::
cast
<
temp_
viz
::
Widget2D
>
()
template
<>
cv
::
viz
::
Widget2D
cv
::
viz
::
Widget
::
cast
<
cv
::
viz
::
Widget2D
>
()
{
vtkActor2D
*
actor
=
vtkActor2D
::
SafeDownCast
(
WidgetAccessor
::
getProp
(
*
this
));
CV_Assert
(
actor
);
...
...
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