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
bb891f05
Commit
bb891f05
authored
Jan 11, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added cone implementation
parent
08f50314
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
0 deletions
+94
-0
widget.rst
modules/viz/doc/widget.rst
+40
-0
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+11
-0
precomp.hpp
modules/viz/src/precomp.hpp
+1
-0
shapes.cpp
modules/viz/src/shapes.cpp
+40
-0
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+2
-0
No files found.
modules/viz/doc/widget.rst
View file @
bb891f05
...
...
@@ -381,6 +381,46 @@ Constructs repositioned planar circle.
:param thickness: Thickness of the circle.
:param color: :ocv:class:`Color` of the circle.
viz::WCone
-----------------
.. ocv:class:: WCone
This 3D Widget defines a cone. ::
class CV_EXPORTS WCone : public Widget3D
{
public:
//! create default cone, oriented along x-axis with center of its base located at origin
WCone(double lenght, double radius, int resolution = 6.0, const Color &color = Color::white());
//! creates repositioned cone
WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
};
viz::WCone::WCone
-------------------------------
Constructs default cone oriented along x-axis with center of its base located at origin
.. ocv:function:: WCone(double length, double radius, int resolution = 6.0, const Color &color = Color::white());
:param length: Length of the cone.
:param radius: Radius of the cone.
:param resolution: Resolution of the cone.
:param color: :ocv:class:`Color` of the cone.
viz::WCone::WCone
-------------------------------
Constructs repositioned planar cone.
.. ocv:function:: WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
:param radius: Radius of the cone.
:param center: Center of the cone base.
:param tip: Tip of the cone.
:param resolution: Resolution of the cone.
:param color: :ocv:class:`Color` of the cone.
viz::WCylinder
--------------
.. ocv:class:: WCylinder
...
...
modules/viz/include/opencv2/viz/widgets.hpp
View file @
bb891f05
...
...
@@ -171,6 +171,16 @@ namespace cv
WCircle
(
double
radius
,
const
Point3d
&
center
,
const
Vec3d
&
normal
,
double
thickness
=
0.01
,
const
Color
&
color
=
Color
::
white
());
};
class
CV_EXPORTS
WCone
:
public
Widget3D
{
public
:
//! create default cone, oriented along x-axis with center of its base located at origin
WCone
(
double
length
,
double
radius
,
int
resolution
=
6.0
,
const
Color
&
color
=
Color
::
white
());
//! creates repositioned cone
WCone
(
double
radius
,
const
Point3d
&
center
,
const
Point3d
&
tip
,
int
resolution
=
6.0
,
const
Color
&
color
=
Color
::
white
());
};
class
CV_EXPORTS
WCylinder
:
public
Widget3D
{
public
:
...
...
@@ -341,6 +351,7 @@ namespace cv
template
<>
CV_EXPORTS
WCylinder
Widget
::
cast
<
WCylinder
>
();
template
<>
CV_EXPORTS
WArrow
Widget
::
cast
<
WArrow
>
();
template
<>
CV_EXPORTS
WCircle
Widget
::
cast
<
WCircle
>
();
template
<>
CV_EXPORTS
WCone
Widget
::
cast
<
WCone
>
();
template
<>
CV_EXPORTS
WCube
Widget
::
cast
<
WCube
>
();
template
<>
CV_EXPORTS
WCoordinateSystem
Widget
::
cast
<
WCoordinateSystem
>
();
template
<>
CV_EXPORTS
WPolyLine
Widget
::
cast
<
WPolyLine
>
();
...
...
modules/viz/src/precomp.hpp
View file @
bb891f05
...
...
@@ -127,6 +127,7 @@
#include <vtkTensorGlyph.h>
#include <vtkImageAlgorithm.h>
#include <vtkTransformFilter.h>
#include <vtkConeSource.h>
#include <vtkStreamingDemandDrivenPipeline.h>
#if !defined(_WIN32) || defined(__CYGWIN__)
...
...
modules/viz/src/shapes.cpp
View file @
bb891f05
...
...
@@ -253,6 +253,46 @@ template<> cv::viz::WCircle cv::viz::Widget::cast<cv::viz::WCircle>()
return
static_cast
<
WCircle
&>
(
widget
);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// WCone widget implementation
cv
::
viz
::
WCone
::
WCone
(
double
length
,
double
radius
,
int
resolution
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkConeSource
>
cone_source
=
vtkSmartPointer
<
vtkConeSource
>::
New
();
cone_source
->
SetCenter
(
length
*
0.5
,
0.0
,
0.0
);
cone_source
->
SetHeight
(
length
);
cone_source
->
SetRadius
(
radius
);
cone_source
->
SetResolution
(
resolution
);
cone_source
->
Update
();
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
VtkUtils
::
SetInputData
(
mapper
,
cone_source
->
GetOutput
());
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
SetMapper
(
mapper
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
setColor
(
color
);
}
cv
::
viz
::
WCone
::
WCone
(
double
radius
,
const
Point3d
&
center
,
const
Point3d
&
tip
,
int
resolution
,
const
Color
&
color
)
{
Vec3d
arbitrary
=
get_random_vec
();
Vec3d
xvec
=
normalized
(
Vec3d
(
tip
-
center
));
Vec3d
zvec
=
normalized
(
xvec
.
cross
(
arbitrary
));
Vec3d
yvec
=
zvec
.
cross
(
xvec
);
WCone
circle
(
norm
(
tip
-
center
),
radius
,
resolution
,
color
);
circle
.
applyTransform
(
makeTransformToGlobal
(
xvec
,
yvec
,
zvec
,
center
));
*
this
=
circle
;
}
template
<>
cv
::
viz
::
WCone
cv
::
viz
::
Widget
::
cast
<
cv
::
viz
::
WCone
>
()
{
Widget3D
widget
=
this
->
cast
<
Widget3D
>
();
return
static_cast
<
WCone
&>
(
widget
);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// cylinder widget implementation
...
...
modules/viz/test/tests_simple.cpp
View file @
bb891f05
...
...
@@ -299,6 +299,8 @@ TEST(Viz, show_simple_widgets)
viz
.
showWidget
(
"cir2"
,
WCircle
(
0.5
,
Point3d
(
0.5
,
0.0
,
0.0
),
Vec3d
(
1.0
,
0.0
,
0.0
),
0.01
,
Color
::
apricot
()));
viz
.
showWidget
(
"cyl0"
,
WCylinder
(
Vec3d
(
-
0.5
,
0.5
,
-
0.5
),
Vec3d
(
0.5
,
0.5
,
-
0.5
),
0.125
,
30
,
Color
::
brown
()));
viz
.
showWidget
(
"con0"
,
WCone
(
0.25
,
0.125
,
6
,
Color
::
azure
()));
viz
.
showWidget
(
"con1"
,
WCone
(
0.125
,
Point3d
(
0.5
,
-
0.5
,
0.5
),
Point3d
(
0.5
,
-
1.0
,
0.5
),
6
,
Color
::
turquoise
()));
viz
.
spin
();
}
...
...
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