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
d6e2b657
Commit
d6e2b657
authored
Jul 13, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring
parent
512afe2a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
169 additions
and
350 deletions
+169
-350
viz.hpp
modules/viz/include/opencv2/viz.hpp
+23
-0
events.hpp
modules/viz/include/opencv2/viz/events.hpp
+0
-113
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+50
-55
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+15
-19
cloud_widgets.cpp
modules/viz/src/cloud_widgets.cpp
+0
-0
common.cpp
modules/viz/src/common.cpp
+1
-12
interactor_style.cpp
modules/viz/src/interactor_style.cpp
+0
-5
interactor_style.h
modules/viz/src/interactor_style.h
+4
-34
precomp.hpp
modules/viz/src/precomp.hpp
+0
-1
shape_widgets.cpp
modules/viz/src/shape_widgets.cpp
+0
-0
types.cpp
modules/viz/src/types.cpp
+39
-0
viz3d.cpp
modules/viz/src/viz3d.cpp
+15
-58
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+4
-33
viz3d_impl.hpp
modules/viz/src/viz3d_impl.hpp
+18
-20
No files found.
modules/viz/include/opencv2/viz.hpp
View file @
d6e2b657
...
...
@@ -60,7 +60,30 @@ 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
));
//! constructs camera pose from posiont, focal_point and up_vector (see gluLookAt() for more infromation
CV_EXPORTS
Affine3f
makeCameraPose
(
const
Vec3f
&
position
,
const
Vec3f
&
focal_point
,
const
Vec3f
&
up_vector
);
//! checks float value for Nan
inline
bool
isNan
(
float
x
)
{
unsigned
int
*
u
=
reinterpret_cast
<
unsigned
int
*>
(
&
x
);
return
((
u
[
0
]
&
0x7f800000
)
==
0x7f800000
)
&&
(
u
[
0
]
&
0x007fffff
);
}
//! checks double value for Nan
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
);
}
//! checks vectors for Nans
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
]);
}
//! checks point for Nans
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/events.hpp
deleted
100644 → 0
View file @
512afe2a
#pragma once
#include <string>
#include <opencv2/viz/types.hpp>
namespace
cv
{
namespace
viz
{
class
KeyboardEvent
{
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
{
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
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
)
modifiers_
=
Alt
;
if
(
ctrl
)
modifiers_
|=
Ctrl
;
if
(
shift
)
modifiers_
|=
Shift
;
}
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
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
)
key_state
=
KeyboardEvent
::
Alt
;
if
(
ctrl
)
key_state
|=
KeyboardEvent
::
Ctrl
;
if
(
shift
)
key_state
|=
KeyboardEvent
::
Shift
;
}
modules/viz/include/opencv2/viz/types.hpp
View file @
d6e2b657
#pragma once
#include <
vector
>
#include <
string
>
#include <opencv2/core/cvdef.h>
#include <opencv2/core.hpp>
#include <opencv2/core/affine.hpp>
...
...
@@ -8,35 +8,7 @@
namespace
cv
{
typedef
std
::
string
String
;
// //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
{
class
CV_EXPORTS
Color
:
public
Scalar
...
...
@@ -79,35 +51,58 @@ namespace cv
};
/////////////////////////////////////////////////////////////////////////////
/// Utility functions
class
CV_EXPORTS
KeyboardEvent
{
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_
;
};
inline
Color
vtkcolor
(
const
Color
&
color
)
class
CV_EXPORTS
MouseEvent
{
Color
scaled_color
=
color
*
(
1.0
/
255.0
);
std
::
swap
(
scaled_color
[
0
],
scaled_color
[
2
]);
return
scaled_color
;
}
public
:
enum
Type
{
MouseMove
=
1
,
MouseButtonPress
,
MouseButtonRelease
,
MouseScrollDown
,
MouseScrollUp
,
MouseDblClick
}
;
enum
MouseButton
{
NoButton
=
0
,
LeftButton
,
MiddleButton
,
RightButton
,
VScroll
}
;
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
);
}
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
;
};
}
/* namespace viz */
}
/* namespace cv */
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
);
}
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 @
d6e2b657
...
...
@@ -4,14 +4,9 @@
//#error "Viz is in beta state now. Please define macro above to use it"
#endif
#include <opencv2/core/cvdef.h>
#include <opencv2/core.hpp>
#include <string>
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/widgets.hpp>
#include <opencv2/viz/events.hpp>
namespace
cv
{
...
...
@@ -20,28 +15,21 @@ namespace cv
class
CV_EXPORTS
Viz3d
{
public
:
typedef
cv
::
Ptr
<
Viz3d
>
Ptr
;
typedef
void
(
*
KeyboardCallback
)(
const
KeyboardEvent
&
,
void
*
);
typedef
void
(
*
MouseCallback
)(
const
MouseEvent
&
,
void
*
);
Viz3d
(
const
String
&
window_name
=
String
());
~
Viz3d
();
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"
);
//to refactor
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
addPolygon
(
const
Mat
&
cloud
,
const
Color
&
color
,
const
String
&
id
=
"polygon"
);
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
);
bool
wasStopped
()
const
;
void
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
=
Affine3f
::
Identity
());
void
removeWidget
(
const
String
&
id
);
...
...
@@ -50,6 +38,13 @@ namespace cv
void
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
void
spin
();
void
spinOnce
(
int
time
=
1
,
bool
force_redraw
=
false
);
bool
wasStopped
()
const
;
void
registerKeyboardCallback
(
KeyboardCallback
callback
,
void
*
cookie
=
0
);
void
registerMouseCallback
(
MouseCallback
callback
,
void
*
cookie
=
0
);
private
:
Viz3d
(
const
Viz3d
&
);
Viz3d
&
operator
=
(
const
Viz3d
&
);
...
...
@@ -57,8 +52,9 @@ namespace cv
struct
VizImpl
;
VizImpl
*
impl_
;
};
}
}
}
/* namespace viz */
}
/* namespace cv */
modules/viz/src/cloud_widgets.cpp
0 → 100644
View file @
d6e2b657
This diff is collapsed.
Click to expand it.
modules/viz/src/common.cpp
View file @
d6e2b657
#include <common.h>
#include <cstdlib>
#include <opencv2/viz/types.hpp>
#include "viz3d_impl.hpp"
/////////////////////////////////////////////////////////////////////////////////////////////
//Eigen::Matrix4d cv::viz::vtkToEigen (vtkMatrix4x4* vtk_matrix)
//{
// Eigen::Matrix4d eigen_matrix = Eigen::Matrix4d::Identity ();
// for (int i=0; i < 4; i++)
// for (int j=0; j < 4; j++)
// eigen_matrix (i, j) = vtk_matrix->GetElement (i, j);
// return eigen_matrix;
//}
///////////////////////////////////////////////////////////////////////////////////////////////
//Eigen::Vector2i cv::viz::worldToView (const Eigen::Vector4d &world_pt, const Eigen::Matrix4d &view_projection_matrix, int width, int height)
//{
...
...
modules/viz/src/interactor_style.cpp
View file @
d6e2b657
...
...
@@ -222,7 +222,6 @@ cv::viz::InteractorStyle::OnKeyDown ()
" ALT + s, S : turn stereo mode on/off
\n
"
" ALT + f, F : switch between maximized window mode and original size
\n
"
"
\n
"
" SHIFT + left click : select a point
\n
"
<<
std
::
endl
;
break
;
}
...
...
@@ -676,9 +675,6 @@ void cv::viz::InteractorStyle::OnTimer ()
}
namespace
cv
{
namespace
viz
...
...
@@ -687,4 +683,3 @@ namespace cv
vtkStandardNewMacro
(
InteractorStyle
)
}
}
modules/viz/src/interactor_style.h
View file @
d6e2b657
#pragma once
#include "viz_types.h"
#include <opencv2/viz/
event
s.hpp>
#include <opencv2/viz/
type
s.hpp>
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
/** \brief InteractorStyle defines an unique, custom VTK based interactory style Viz applications.
* Besides defining the rendering style, we also create a list of custom actions
* that are triggered on different keys being pressed:
*
* - p, P : switch to a point-based representation
...
...
@@ -28,7 +27,6 @@ namespace cv
* - SHIFT + left click : select a point
*
* \author Radu B. Rusu
* \ingroup visualization
*/
class
InteractorStyle
:
public
vtkInteractorStyleTrackballCamera
{
...
...
@@ -43,41 +41,19 @@ namespace cv
static
InteractorStyle
*
New
();
InteractorStyle
()
{}
virtual
~
InteractorStyle
()
{}
// this macro defines Superclass, the isA functionality and the safe downcast method
vtkTypeMacro
(
InteractorStyle
,
vtkInteractorStyleTrackballCamera
)
;
vtkTypeMacro
(
InteractorStyle
,
vtkInteractorStyleTrackballCamera
)
/** \brief Initialization routine. Must be called before anything else. */
virtual
void
Initialize
();
/** \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
Ptr
<
CloudActorMap
>&
actors
)
{
actors_
=
actors
;
}
/** \brief Pass a set of renderers to the interactor style.
* \param[in] rens the vtkRendererCollection to use
*/
void
setRenderer
(
vtkSmartPointer
<
vtkRenderer
>&
ren
)
{
renderer_
=
ren
;
}
/** \brief Register a callback function for mouse events
* \param[in] ccallback function that will be registered as a callback for a mouse event
* \param[in] cookie for passing user data to callback
*/
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
/** \brief Register a callback function for keyboard events
* \param[in] callback a function that will be registered as a callback for a keyboard event
* \param[in] cookie user data passed to the callback function
*/
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
/** \brief Save the current rendered image to disk, as a PNG screenshot.
* \param[in] file the name of the PNG file
*/
void
saveScreenshot
(
const
std
::
string
&
file
);
/** \brief Change the default keyboard modified from ALT to a different special key.
...
...
@@ -134,24 +110,18 @@ namespace cv
/** \brief Interactor style internal method. Gets called periodically if a timer is set. */
virtual
void
OnTimer
();
void
zoomIn
();
void
zoomOut
();
/** \brief True if we're using red-blue colors for anaglyphic stereo, false if magenta-green. */
bool
stereo_anaglyph_mask_default_
;
/** \brief The keyboard modifier to use. Default: Alt. */
KeyboardModifier
modifier_
;
/** \brief KeyboardEvent callback function pointer*/
void
(
*
keyboardCallback_
)(
const
KeyboardEvent
&
,
void
*
);
/** \brief KeyboardEvent callback user data*/
void
*
keyboard_callback_cookie_
;
/** \brief MouseEvent callback function pointer */
void
(
*
mouseCallback_
)(
const
MouseEvent
&
,
void
*
);
/** \brief MouseEvent callback user data */
void
*
mouse_callback_cookie_
;
};
}
...
...
modules/viz/src/precomp.hpp
View file @
d6e2b657
...
...
@@ -156,7 +156,6 @@
#include <opencv2/core.hpp>
#include <opencv2/viz.hpp>
#include "opencv2/viz/widget_accessor.hpp"
#include <opencv2/calib3d.hpp>
namespace
cv
{
...
...
modules/viz/src/s
impl
e_widgets.cpp
→
modules/viz/src/s
hap
e_widgets.cpp
View file @
d6e2b657
This diff is collapsed.
Click to expand it.
modules/viz/src/types.cpp
View file @
d6e2b657
...
...
@@ -20,3 +20,42 @@ cv::viz::Color cv::viz::Color::white() { return Color(255, 255, 255); }
cv
::
viz
::
Color
cv
::
viz
::
Color
::
gray
()
{
return
Color
(
128
,
128
,
128
);
}
////////////////////////////////////////////////////////////////////
/// cv::viz::KeyboardEvent
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
)
modifiers_
=
Alt
;
if
(
ctrl
)
modifiers_
|=
Ctrl
;
if
(
shift
)
modifiers_
|=
Shift
;
}
bool
cv
::
viz
::
KeyboardEvent
::
isAltPressed
()
const
{
return
(
modifiers_
&
Alt
)
!=
0
;
}
bool
cv
::
viz
::
KeyboardEvent
::
isCtrlPressed
()
const
{
return
(
modifiers_
&
Ctrl
)
!=
0
;
}
bool
cv
::
viz
::
KeyboardEvent
::
isShiftPressed
()
const
{
return
(
modifiers_
&
Shift
)
!=
0
;
}
unsigned
char
cv
::
viz
::
KeyboardEvent
::
getKeyCode
()
const
{
return
key_code_
;
}
const
cv
::
String
&
cv
::
viz
::
KeyboardEvent
::
getKeySym
()
const
{
return
key_sym_
;
}
bool
cv
::
viz
::
KeyboardEvent
::
keyDown
()
const
{
return
action_
;
}
bool
cv
::
viz
::
KeyboardEvent
::
keyUp
()
const
{
return
!
action_
;
}
////////////////////////////////////////////////////////////////////
/// cv::viz::MouseEvent
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
)
key_state
=
KeyboardEvent
::
Alt
;
if
(
ctrl
)
key_state
|=
KeyboardEvent
::
Ctrl
;
if
(
shift
)
key_state
|=
KeyboardEvent
::
Shift
;
}
modules/viz/src/viz3d.cpp
View file @
d6e2b657
...
...
@@ -2,20 +2,10 @@
#include "viz3d_impl.hpp"
cv
::
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
))
{}
cv
::
viz
::
Viz3d
::~
Viz3d
()
{
delete
impl_
;
}
cv
::
viz
::
Viz3d
::~
Viz3d
()
{
delete
impl_
;
}
void
cv
::
viz
::
Viz3d
::
setBackgroundColor
(
const
Color
&
color
)
{
impl_
->
setBackgroundColor
(
color
);
}
void
cv
::
viz
::
Viz3d
::
setBackgroundColor
(
const
Color
&
color
)
{
impl_
->
setBackgroundColor
(
color
);
}
bool
cv
::
viz
::
Viz3d
::
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
{
...
...
@@ -37,54 +27,21 @@ bool cv::viz::Viz3d::addPolygon(const Mat& cloud, const Color& color, const Stri
return
impl_
->
addPolygon
(
cloud
,
color
,
id
);
}
void
cv
::
viz
::
Viz3d
::
spin
()
{
impl_
->
spin
();
}
void
cv
::
viz
::
Viz3d
::
spinOnce
(
int
time
,
bool
force_redraw
)
{
impl_
->
spinOnce
(
time
,
force_redraw
);
}
void
cv
::
viz
::
Viz3d
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
impl_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
void
cv
::
viz
::
Viz3d
::
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
impl_
->
registerMouseCallback
(
callback
,
cookie
);
}
void
cv
::
viz
::
Viz3d
::
spin
()
{
impl_
->
spin
();
}
void
cv
::
viz
::
Viz3d
::
spinOnce
(
int
time
,
bool
force_redraw
)
{
impl_
->
spinOnce
(
time
,
force_redraw
);
}
bool
cv
::
viz
::
Viz3d
::
wasStopped
()
const
{
return
impl_
->
wasStopped
();
}
void
cv
::
viz
::
Viz3d
::
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
)
{
impl_
->
showWidget
(
id
,
widget
,
pose
);
}
void
cv
::
viz
::
Viz3d
::
removeWidget
(
const
String
&
id
)
{
impl_
->
removeWidget
(
id
);
}
void
cv
::
viz
::
Viz3d
::
registerKeyboardCallback
(
KeyboardCallback
callback
,
void
*
cookie
)
{
impl_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
cv
::
viz
::
Widget
cv
::
viz
::
Viz3d
::
getWidget
(
const
String
&
id
)
const
{
return
impl_
->
getWidget
(
id
);
}
void
cv
::
viz
::
Viz3d
::
registerMouseCallback
(
MouseCallback
callback
,
void
*
cookie
)
{
impl_
->
registerMouseCallback
(
callback
,
cookie
);
}
void
cv
::
viz
::
Viz3d
::
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
setWidgetPose
(
id
,
pose
);
}
void
cv
::
viz
::
Viz3d
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
updateWidgetPose
(
id
,
pose
);
}
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
getWidgetPose
(
const
String
&
id
)
const
{
return
impl_
->
getWidgetPose
(
id
);
}
void
cv
::
viz
::
Viz3d
::
showWidget
(
const
String
&
id
,
const
Widget
&
widget
,
const
Affine3f
&
pose
)
{
impl_
->
showWidget
(
id
,
widget
,
pose
);
}
void
cv
::
viz
::
Viz3d
::
removeWidget
(
const
String
&
id
)
{
impl_
->
removeWidget
(
id
);
}
cv
::
viz
::
Widget
cv
::
viz
::
Viz3d
::
getWidget
(
const
String
&
id
)
const
{
return
impl_
->
getWidget
(
id
);
}
void
cv
::
viz
::
Viz3d
::
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
setWidgetPose
(
id
,
pose
);
}
void
cv
::
viz
::
Viz3d
::
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
)
{
impl_
->
updateWidgetPose
(
id
,
pose
);
}
cv
::
Affine3f
cv
::
viz
::
Viz3d
::
getWidgetPose
(
const
String
&
id
)
const
{
return
impl_
->
getWidgetPose
(
id
);
}
modules/viz/src/viz
_main
.cpp
→
modules/viz/src/viz
3d_impl
.cpp
View file @
d6e2b657
#include "precomp.hpp"
#include <opencv2/calib3d.hpp>
#include "viz3d_impl.hpp"
#include <vtkRenderWindowInteractor.h>
...
...
@@ -95,16 +93,11 @@ cv::viz::Viz3d::VizImpl::~VizImpl ()
void
cv
::
viz
::
Viz3d
::
VizImpl
::
saveScreenshot
(
const
std
::
string
&
file
)
{
style_
->
saveScreenshot
(
file
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
style_
->
registerMouseCallback
(
callback
,
cookie
);
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
registerMouseCallback
(
MouseCallback
callback
,
void
*
cookie
)
{
style_
->
registerMouseCallback
(
callback
,
cookie
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
style_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
registerKeyboardCallback
(
KeyboardCallback
callback
,
void
*
cookie
)
{
style_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
Viz3d
::
VizImpl
::
spin
()
...
...
@@ -1018,13 +1011,6 @@ void cv::viz::convertToVtkMatrix (const Eigen::Vector4f &origin, const Eigen::Qu
vtk_matrix
->
SetElement
(
3
,
3
,
1.0
f
);
}
void
cv
::
viz
::
convertToVtkMatrix
(
const
Matx44f
&
m
,
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
vtk_matrix
->
SetElement
(
i
,
k
,
m
(
i
,
k
));
}
vtkSmartPointer
<
vtkMatrix4x4
>
cv
::
viz
::
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
)
{
vtkSmartPointer
<
vtkMatrix4x4
>
vtk_matrix
=
vtkSmartPointer
<
vtkMatrix4x4
>::
New
();
...
...
@@ -1034,14 +1020,6 @@ vtkSmartPointer<vtkMatrix4x4> cv::viz::convertToVtkMatrix (const cv::Matx44f &m)
return
vtk_matrix
;
}
void
cv
::
viz
::
convertToCvMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
cv
::
Matx44f
&
m
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
m
(
i
,
k
)
=
vtk_matrix
->
GetElement
(
i
,
k
);
}
cv
::
Matx44f
cv
::
viz
::
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
)
{
cv
::
Matx44f
m
;
...
...
@@ -1052,13 +1030,6 @@ cv::Matx44f cv::viz::convertToMatx(const vtkSmartPointer<vtkMatrix4x4>& vtk_matr
}
//////////////////////////////////////////////////////////////////////////////////////////////
void
cv
::
viz
::
convertToEigenMatrix
(
const
vtkSmartPointer
<
vtkMatrix4x4
>
&
vtk_matrix
,
Eigen
::
Matrix4f
&
m
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
k
=
0
;
k
<
4
;
k
++
)
m
(
i
,
k
)
=
static_cast
<
float
>
(
vtk_matrix
->
GetElement
(
i
,
k
));
}
void
cv
::
viz
::
Viz3d
::
VizImpl
::
setFullScreen
(
bool
mode
)
{
...
...
modules/viz/src/viz3d_impl.hpp
View file @
d6e2b657
#pragma once
#include <opencv2/core.hpp>
#include <opencv2/viz/events.hpp>
#include <opencv2/viz.hpp>
#include "interactor_style.h"
#include "viz_types.h"
#include "common.h"
#include <opencv2/viz/types.hpp>
#include <opencv2/core/affine.hpp>
#include <opencv2/viz/viz3d.hpp>
struct
cv
::
viz
::
Viz3d
::
VizImpl
{
public
:
typedef
cv
::
Ptr
<
VizImpl
>
Ptr
;
typedef
Viz3d
::
KeyboardCallback
KeyboardCallback
;
typedef
Viz3d
::
MouseCallback
MouseCallback
;
VizImpl
(
const
String
&
name
=
String
()
);
VizImpl
(
const
String
&
name
);
virtual
~
VizImpl
();
void
setFullScreen
(
bool
mode
);
void
setWindowName
(
const
String
&
name
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
KeyboardEvent
&
,
void
*
)
,
void
*
cookie
=
0
);
void
registerMouseCallback
(
void
(
*
callback
)(
const
MouseEvent
&
,
void
*
)
,
void
*
cookie
=
0
);
void
registerKeyboardCallback
(
KeyboardCallback
callback
,
void
*
cookie
=
0
);
void
registerMouseCallback
(
MouseCallback
callback
,
void
*
cookie
=
0
);
void
spin
();
void
spinOnce
(
int
time
=
1
,
bool
force_redraw
=
false
);
...
...
@@ -173,9 +170,7 @@ public:
void
setWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
void
updateWidgetPose
(
const
String
&
id
,
const
Affine3f
&
pose
);
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
void
all_data
();
Affine3f
getWidgetPose
(
const
String
&
id
)
const
;
private
:
vtkSmartPointer
<
vtkRenderWindowInteractor
>
interactor_
;
...
...
@@ -285,12 +280,6 @@ namespace cv
namespace
viz
{
//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
);
vtkSmartPointer
<
vtkMatrix4x4
>
convertToVtkMatrix
(
const
cv
::
Matx44f
&
m
);
cv
::
Matx44f
convertToMatx
(
const
vtkSmartPointer
<
vtkMatrix4x4
>&
vtk_matrix
);
...
...
@@ -300,8 +289,6 @@ namespace cv
* \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
{
...
...
@@ -366,6 +353,17 @@ namespace cv
ApplyAffine
(
const
ApplyAffine
&
);
ApplyAffine
&
operator
=
(
const
ApplyAffine
&
);
};
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
);
}
}
}
...
...
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