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
58025c57
Commit
58025c57
authored
May 31, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from ozantonkal/removing_boost_dependency
Removing boost dependency
parents
ddcfab31
6603cc44
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
102 additions
and
93 deletions
+102
-93
CMakeLists.txt
modules/viz/CMakeLists.txt
+0
-19
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+4
-0
interactor_style.cpp
modules/viz/src/interactor_style.cpp
+49
-20
precomp.hpp
modules/viz/src/precomp.hpp
+2
-2
interactor_style.h
modules/viz/src/q/interactor_style.h
+20
-15
viz3d_impl.hpp
modules/viz/src/q/viz3d_impl.hpp
+10
-33
viz3d.cpp
modules/viz/src/viz3d.cpp
+11
-0
viz_main.cpp
modules/viz/src/viz_main.cpp
+6
-4
No files found.
modules/viz/CMakeLists.txt
View file @
58025c57
...
...
@@ -36,26 +36,7 @@ macro(find_vtk)
endif
()
endmacro
()
macro
(
find_boost
)
# Disable the config mode of find_package(Boost)
set
(
Boost_NO_BOOST_CMAKE ON
)
set
(
Boost_USE_STATIC_LIBS ON
)
find_package
(
Boost 1.49.0 REQUIRED COMPONENTS system thread
)
if
(
Boost_FOUND
)
set
(
HAVE_BOOST ON
)
# Obtain diagnostic information about Boost's automatic linking outputted during compilation time.
add_definitions
(
${
Boost_LIB_DIAGNOSTIC_DEFINITIONS
}
)
include_directories
(
SYSTEM
${
Boost_INCLUDE_DIRS
}
)
link_directories
(
${
Boost_LIBRARY_DIRS
}
)
message
(
STATUS
"Boost found (include:
${
Boost_INCLUDE_DIRS
}
)"
)
endif
()
endmacro
()
find_vtk
()
find_boost
()
find_package
(
OpenGL
)
...
...
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
58025c57
...
...
@@ -10,6 +10,7 @@
#include <string>
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/events.hpp>
namespace
temp_viz
{
...
...
@@ -57,6 +58,9 @@ namespace temp_viz
void
spin
();
void
spinOnce
(
int
time
=
1
,
bool
force_redraw
=
false
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
cv
::
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
registerMouseCallback
(
void
(
*
callback
)(
const
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
private
:
Viz3d
(
const
Viz3d
&
);
...
...
modules/viz/src/interactor_style.cpp
View file @
58025c57
...
...
@@ -35,6 +35,14 @@ void temp_viz::InteractorStyle::Initialize ()
init_
=
true
;
stereo_anaglyph_mask_default_
=
true
;
// Initialize the keyboard event callback as none
keyboardCallback_
=
0
;
keyboard_callback_cookie_
=
0
;
// Initialize the mouse event callback as none
mouseCallback_
=
0
;
mouse_callback_cookie_
=
0
;
}
//////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -138,15 +146,19 @@ void temp_viz::InteractorStyle::OnChar ()
}
//////////////////////////////////////////////////////////////////////////////////////////////
boost
::
signals2
::
connection
temp_viz
::
InteractorStyle
::
registerMouseCallback
(
boost
::
function
<
void
(
const
cv
::
MouseEvent
&
)
>
callback
)
void
temp_viz
::
InteractorStyle
::
registerMouseCallback
(
void
(
*
callback
)(
const
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
return
(
mouse_signal_
.
connect
(
callback
));
// Register the callback function and store the user data
mouseCallback_
=
callback
;
mouse_callback_cookie_
=
cookie
;
}
//////////////////////////////////////////////////////////////////////////////////////////////
boost
::
signals2
::
connection
temp_viz
::
InteractorStyle
::
registerKeyboardCallback
(
boost
::
function
<
void
(
const
cv
::
KeyboardEvent
&
)
>
callback
)
void
temp_viz
::
InteractorStyle
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
cv
::
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
return
(
keyboard_signal_
.
connect
(
callback
));
// Register the callback function and store the user data
keyboardCallback_
=
callback
;
keyboard_callback_cookie_
=
cookie
;
}
//////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -508,7 +520,9 @@ temp_viz::InteractorStyle::OnKeyDown ()
}
KeyboardEvent
event
(
true
,
Interactor
->
GetKeySym
(),
Interactor
->
GetKeyCode
(),
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
keyboard_signal_
(
event
);
// Check if there is a keyboard callback registered
if
(
keyboardCallback_
)
keyboardCallback_
(
event
,
keyboard_callback_cookie_
);
renderer_
->
Render
();
Interactor
->
Render
();
...
...
@@ -518,7 +532,10 @@ temp_viz::InteractorStyle::OnKeyDown ()
void
temp_viz
::
InteractorStyle
::
OnKeyUp
()
{
KeyboardEvent
event
(
false
,
Interactor
->
GetKeySym
(),
Interactor
->
GetKeyCode
(),
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
keyboard_signal_
(
event
);
// Check if there is a keyboard callback registered
if
(
keyboardCallback_
)
keyboardCallback_
(
event
,
keyboard_callback_cookie_
);
Superclass
::
OnKeyUp
();
}
...
...
@@ -527,7 +544,8 @@ void temp_viz::InteractorStyle::OnMouseMove ()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseMove
,
MouseEvent
::
NoButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnMouseMove
();
}
...
...
@@ -537,7 +555,8 @@ void temp_viz::InteractorStyle::OnLeftButtonDown ()
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
::
Type
type
=
(
Interactor
->
GetRepeatCount
()
==
0
)
?
MouseEvent
::
MouseButtonPress
:
MouseEvent
::
MouseDblClick
;
MouseEvent
event
(
type
,
MouseEvent
::
LeftButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnLeftButtonDown
();
}
...
...
@@ -546,7 +565,8 @@ void temp_viz::InteractorStyle::OnLeftButtonUp ()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseButtonRelease
,
MouseEvent
::
LeftButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnLeftButtonUp
();
}
...
...
@@ -557,7 +577,8 @@ void temp_viz::InteractorStyle::OnMiddleButtonDown ()
MouseEvent
::
Type
type
=
(
Interactor
->
GetRepeatCount
()
==
0
)
?
MouseEvent
::
MouseButtonPress
:
MouseEvent
::
MouseDblClick
;
MouseEvent
event
(
type
,
MouseEvent
::
MiddleButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnMiddleButtonDown
();
}
...
...
@@ -566,7 +587,8 @@ void temp_viz::InteractorStyle::OnMiddleButtonUp ()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseButtonRelease
,
MouseEvent
::
MiddleButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnMiddleButtonUp
();
}
...
...
@@ -577,7 +599,8 @@ void temp_viz::InteractorStyle::OnRightButtonDown ()
MouseEvent
::
Type
type
=
(
Interactor
->
GetRepeatCount
()
==
0
)
?
MouseEvent
::
MouseButtonPress
:
MouseEvent
::
MouseDblClick
;
MouseEvent
event
(
type
,
MouseEvent
::
RightButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnRightButtonDown
();
}
...
...
@@ -586,7 +609,8 @@ void temp_viz::InteractorStyle::OnRightButtonUp ()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseButtonRelease
,
MouseEvent
::
RightButton
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
Superclass
::
OnRightButtonUp
();
}
...
...
@@ -595,9 +619,11 @@ void temp_viz::InteractorStyle::OnMouseWheelForward ()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseScrollUp
,
MouseEvent
::
VScroll
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
Interactor
->
GetRepeatCount
())
mouse_signal_
(
event
);
// If a mouse callback registered, call it!
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
if
(
Interactor
->
GetRepeatCount
()
&&
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
if
(
Interactor
->
GetAltKey
())
{
...
...
@@ -625,10 +651,13 @@ void temp_viz::InteractorStyle::OnMouseWheelBackward ()
{
Vec2i
p
(
Interactor
->
GetEventPosition
());
MouseEvent
event
(
MouseEvent
::
MouseScrollDown
,
MouseEvent
::
VScroll
,
p
,
Interactor
->
GetAltKey
(),
Interactor
->
GetControlKey
(),
Interactor
->
GetShiftKey
());
mouse_signal_
(
event
);
if
(
Interactor
->
GetRepeatCount
())
mouse_signal_
(
event
);
// If a mouse callback registered, call it!
if
(
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
if
(
Interactor
->
GetRepeatCount
()
&&
mouseCallback_
)
mouseCallback_
(
event
,
mouse_callback_cookie_
);
if
(
Interactor
->
GetAltKey
())
{
// zoom
...
...
modules/viz/src/precomp.hpp
View file @
58025c57
...
...
@@ -4,11 +4,11 @@
#include <map>
#include <vector>
/*
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/signals2.hpp>
#include <boost/thread.hpp>
#include <boost/thread.hpp>
*/
#include <Eigen/Geometry>
...
...
modules/viz/src/q/interactor_style.h
View file @
58025c57
...
...
@@ -56,25 +56,23 @@ namespace temp_viz
*/
inline
void
setCloudActorMap
(
const
cv
::
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] cb a boost
function that will be registered as a callback for a mouse event
* \return a connection object that allows to disconnect the callback function.
*/
boost
::
signals2
::
connection
registerMouseCallback
(
boost
::
function
<
void
(
const
cv
::
MouseEvent
&
)
>
cb
);
/** \brief Register a callback
boost::
function for keyboard events
* \param[in] c
b a boost
function that will be registered as a callback for a keyboard event
* \
return a connection object that allows to disconnect the callback function.
* \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
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
/** \brief Register a callback function for keyboard events
* \param[in] c
allback a
function that will be registered as a callback for a keyboard event
* \
param[in] cookie user data passed to the callback function
*/
boost
::
signals2
::
connection
registerKeyboardCallback
(
boost
::
function
<
void
(
const
cv
::
KeyboardEvent
&
)
>
cb
);
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
cv
::
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
*/
...
...
@@ -113,9 +111,6 @@ namespace temp_viz
/** \brief Internal window to image filter. Needed by \a snapshot_writer_. */
vtkSmartPointer
<
vtkWindowToImageFilter
>
wif_
;
boost
::
signals2
::
signal
<
void
(
const
cv
::
MouseEvent
&
)
>
mouse_signal_
;
boost
::
signals2
::
signal
<
void
(
const
cv
::
KeyboardEvent
&
)
>
keyboard_signal_
;
/** \brief Interactor style internal method. Gets called whenever a key is pressed. */
virtual
void
OnChar
();
...
...
@@ -146,5 +141,15 @@ namespace temp_viz
/** \brief The keyboard modifier to use. Default: Alt. */
KeyboardModifier
modifier_
;
/** \brief KeyboardEvent callback function pointer*/
void
(
*
keyboardCallback_
)(
const
cv
::
KeyboardEvent
&
,
void
*
);
/** \brief KeyboardEvent callback user data*/
void
*
keyboard_callback_cookie_
;
/** \brief MouseEvent callback function pointer */
void
(
*
mouseCallback_
)(
const
cv
::
MouseEvent
&
,
void
*
);
/** \brief MouseEvent callback user data */
void
*
mouse_callback_cookie_
;
};
}
modules/viz/src/q/viz3d_impl.hpp
View file @
58025c57
...
...
@@ -22,40 +22,18 @@ public:
virtual
~
VizImpl
();
void
setFullScreen
(
bool
mode
);
void
setWindowName
(
const
std
::
string
&
name
);
/** \brief Register a callback boost::function for keyboard events
* \param[in] cb a boost function that will be registered as a callback for a keyboard event
* \return a connection object that allows to disconnect the callback function.
*/
boost
::
signals2
::
connection
registerKeyboardCallback
(
boost
::
function
<
void
(
const
cv
::
KeyboardEvent
&
)
>
cb
);
inline
boost
::
signals2
::
connection
registerKeyboardCallback
(
void
(
*
callback
)
(
const
cv
::
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
NULL
)
{
return
(
registerKeyboardCallback
(
boost
::
bind
(
callback
,
_1
,
cookie
)));
}
/** \brief Register a callback function for keyboard events
* \param[in] callback the member function that will be registered as a callback for a keyboard event
* \param[in] instance instance to the class that implements the callback function
* \param[in] cookie user data that is passed to the callback
* \return a connection object that allows to disconnect the callback function.
*/
template
<
typename
T
>
inline
boost
::
signals2
::
connection
registerKeyboardCallback
(
void
(
T
::*
callback
)
(
const
cv
::
KeyboardEvent
&
,
void
*
),
T
&
instance
,
void
*
cookie
=
NULL
)
{
return
(
registerKeyboardCallback
(
boost
::
bind
(
callback
,
boost
::
ref
(
instance
),
_1
,
cookie
)));
}
/** \brief Register a callback function for keyboard input
* \param[in] callback function that will be registered as a callback for a keyboard event
* \param[in] cookie for passing user data to callback
*/
void
registerKeyboardCallback
(
void
(
*
callback
)(
const
cv
::
KeyboardEvent
&
,
void
*
),
void
*
cookie
=
0
);
/** \brief Register a callback function for mouse events
* \param[in] c
b a boost
function that will be registered as a callback for a mouse event
* \
return a connection object that allows to disconnect the callback function.
* \param[in] c
callback
function that will be registered as a callback for a mouse event
* \
param[in] cookie for passing user data to callback
*/
boost
::
signals2
::
connection
registerMouseCallback
(
boost
::
function
<
void
(
const
cv
::
MouseEvent
&
)
>
cb
);
inline
boost
::
signals2
::
connection
registerMouseCallback
(
void
(
*
callback
)
(
const
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
=
NULL
)
{
return
(
registerMouseCallback
(
boost
::
bind
(
callback
,
_1
,
cookie
)));
}
/** \brief Register a callback function for mouse events
* \param[in] callback the member function that will be registered as a callback for a mouse event
* \param[in] instance instance to the class that implements the callback function
* \param[in] cookie user data that is passed to the callback
* \return a connection object that allows to disconnect the callback function.
*/
template
<
typename
T
>
inline
boost
::
signals2
::
connection
registerMouseCallback
(
void
(
T
::*
callback
)
(
const
cv
::
MouseEvent
&
,
void
*
),
T
&
instance
,
void
*
cookie
=
NULL
)
{
return
(
registerMouseCallback
(
boost
::
bind
(
callback
,
boost
::
ref
(
instance
),
_1
,
cookie
)));
}
void
registerMouseCallback
(
void
(
*
callback
)(
const
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
=
0
);
void
spin
();
void
spinOnce
(
int
time
=
1
,
bool
force_redraw
=
false
);
...
...
@@ -446,7 +424,6 @@ private:
void
allocVtkPolyData
(
vtkSmartPointer
<
vtkAppendPolyData
>
&
polydata
);
void
allocVtkPolyData
(
vtkSmartPointer
<
vtkPolyData
>
&
polydata
);
void
allocVtkUnstructuredGrid
(
vtkSmartPointer
<
vtkUnstructuredGrid
>
&
polydata
);
};
//void getTransformationMatrix (const Eigen::Vector4f &origin, const Eigen::Quaternionf& orientation, Eigen::Matrix4f &transformation);
...
...
modules/viz/src/viz3d.cpp
View file @
58025c57
...
...
@@ -92,3 +92,13 @@ bool temp_viz::Viz3d::removeCoordinateSystem (const String &id)
{
return
impl_
->
removeCoordinateSystem
(
id
);
}
void
temp_viz
::
Viz3d
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
cv
::
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
impl_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
void
temp_viz
::
Viz3d
::
registerMouseCallback
(
void
(
*
callback
)(
const
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
impl_
->
registerMouseCallback
(
callback
,
cookie
);
}
\ No newline at end of file
modules/viz/src/viz_main.cpp
View file @
58025c57
...
...
@@ -95,15 +95,17 @@ temp_viz::Viz3d::VizImpl::~VizImpl ()
void
temp_viz
::
Viz3d
::
VizImpl
::
saveScreenshot
(
const
std
::
string
&
file
)
{
style_
->
saveScreenshot
(
file
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
boost
::
signals2
::
connection
temp_viz
::
Viz3d
::
VizImpl
::
registerKeyboardCallback
(
boost
::
function
<
void
(
const
cv
::
KeyboardEvent
&
)
>
callback
)
void
temp_viz
::
Viz3d
::
VizImpl
::
registerMouseCallback
(
void
(
*
callback
)(
const
cv
::
MouseEvent
&
,
void
*
),
void
*
cookie
)
{
return
(
style_
->
registerKeyboardCallback
(
callback
));
// Register the callback function in the interactor style
style_
->
registerMouseCallback
(
callback
,
cookie
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
boost
::
signals2
::
connection
temp_viz
::
Viz3d
::
VizImpl
::
registerMouseCallback
(
boost
::
function
<
void
(
const
cv
::
MouseEvent
&
)
>
callback
)
void
temp_viz
::
Viz3d
::
VizImpl
::
registerKeyboardCallback
(
void
(
*
callback
)(
const
cv
::
KeyboardEvent
&
,
void
*
),
void
*
cookie
)
{
return
(
style_
->
registerMouseCallback
(
callback
));
// Register the callback function in the interactor style
style_
->
registerKeyboardCallback
(
callback
,
cookie
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
...
...
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