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
c0cc5512
Commit
c0cc5512
authored
Jan 11, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored circle
parent
dac27c99
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
28 deletions
+58
-28
widget.rst
modules/viz/doc/widget.rst
+21
-6
widgets.hpp
modules/viz/include/opencv2/viz/widgets.hpp
+5
-1
precomp.hpp
modules/viz/src/precomp.hpp
+6
-0
shapes.cpp
modules/viz/src/shapes.cpp
+23
-20
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+3
-1
No files found.
modules/viz/doc/widget.rst
View file @
c0cc5512
...
...
@@ -349,23 +349,38 @@ viz::WCircle
This 3D Widget defines a circle. ::
class CV_EXPORTS WCircle : public Widget3D
class CV_EXPORTS WCircle : public Widget3D
{
public:
WCircle(const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white());
//! creates default planar circle centred at origin with plane normal along z-axis
WCircle(double radius, double thickness = 0.01, const Color &color = Color::white());
//! creates repositioned circle
WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
};
viz::WCircle::WCircle
-------------------------------
Constructs
a WCircle.
Constructs
default planar circle centred at origin with plane normal along z-axis
.. ocv:function:: WCircle(
const Point3f& pt, double radius, double thickness = 0.01, const Color &color = Color::white())
.. ocv:function:: WCircle(
double radius, double thickness = 0.01, const Color &color = Color::white());
:param pt: Center of the circle.
:param radius: Radius of the circle.
:param radius: Radius of the circle.
:param thickness: Thickness of the circle.
:param color: :ocv:class:`Color` of the circle.
viz::WCircle::WCircle
-------------------------------
Constructs repositioned planar circle.
.. ocv:function:: WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
:param radius: Radius of the circle.
:param center: Center of the circle.
:param normal: Normal of the plane in which the circle lies.
:param thickness: Thickness of the circle.
:param color: :ocv:class:`Color` of the circle.
viz::WCylinder
--------------
.. ocv:class:: WCylinder
...
...
modules/viz/include/opencv2/viz/widgets.hpp
View file @
c0cc5512
...
...
@@ -164,7 +164,11 @@ namespace cv
class
CV_EXPORTS
WCircle
:
public
Widget3D
{
public
:
WCircle
(
const
Point3d
&
pt
,
double
radius
,
double
thickness
=
0.01
,
const
Color
&
color
=
Color
::
white
());
//! creates default circle centred at origin with normal along z-axis
WCircle
(
double
radius
,
double
thickness
=
0.01
,
const
Color
&
color
=
Color
::
white
());
//! creates repositioned circle
WCircle
(
double
radius
,
const
Point3d
&
center
,
const
Vec3d
&
normal
,
double
thickness
=
0.01
,
const
Color
&
color
=
Color
::
white
());
};
class
CV_EXPORTS
WCylinder
:
public
Widget3D
...
...
modules/viz/src/precomp.hpp
View file @
c0cc5512
...
...
@@ -209,6 +209,12 @@ namespace cv
return
scaled_color
;
}
inline
Vec3d
get_random_vec
(
double
from
=
-
10.0
,
double
to
=
10.0
)
{
RNG
&
rng
=
theRNG
();
return
Vec3d
(
rng
.
uniform
(
from
,
to
),
rng
.
uniform
(
from
,
to
),
rng
.
uniform
(
from
,
to
));
}
struct
VtkUtils
{
template
<
class
Filter
>
...
...
modules/viz/src/shapes.cpp
View file @
c0cc5512
...
...
@@ -182,18 +182,17 @@ cv::viz::WArrow::WArrow(const Point3d& pt1, const Point3d& pt2, double thickness
arrow_source
->
SetTipRadius
(
thickness
*
3.0
);
arrow_source
->
SetTipLength
(
thickness
*
10.0
);
RNG
rng
=
theRNG
();
Vec3d
arbitrary
(
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
));
Vec3d
startPoint
(
pt1
.
x
,
pt1
.
y
,
pt1
.
z
),
endPoint
(
pt2
.
x
,
pt2
.
y
,
pt2
.
z
);
Vec3d
arbitrary
=
get_random_vec
();
Vec3d
start_point
(
pt1
.
x
,
pt1
.
y
,
pt1
.
z
),
end_point
(
pt2
.
x
,
pt2
.
y
,
pt2
.
z
);
double
length
=
norm
(
end
Point
-
startP
oint
);
double
length
=
norm
(
end
_point
-
start_p
oint
);
Vec3d
xvec
=
normalized
(
end
Point
-
startP
oint
);
Vec3d
xvec
=
normalized
(
end
_point
-
start_p
oint
);
Vec3d
zvec
=
normalized
(
xvec
.
cross
(
arbitrary
));
Vec3d
yvec
=
zvec
.
cross
(
xvec
);
Matx33d
R
=
makeTransformToGlobal
(
xvec
,
yvec
,
zvec
).
rotation
();
Affine3d
transform_with_scale
(
R
*
length
,
start
P
oint
);
Affine3d
transform_with_scale
(
R
*
length
,
start
_p
oint
);
vtkSmartPointer
<
vtkPolyData
>
polydata
=
VtkUtils
::
TransformPolydata
(
arrow_source
->
GetOutputPort
(),
transform_with_scale
);
...
...
@@ -216,32 +215,36 @@ template<> cv::viz::WArrow cv::viz::Widget::cast<cv::viz::WArrow>()
///////////////////////////////////////////////////////////////////////////////////////////////
/// circle widget implementation
cv
::
viz
::
WCircle
::
WCircle
(
const
Point3d
&
pt
,
double
radius
,
double
thickness
,
const
Color
&
color
)
cv
::
viz
::
WCircle
::
WCircle
(
double
radius
,
double
thickness
,
const
Color
&
color
)
{
vtkSmartPointer
<
vtkDiskSource
>
disk
=
vtkSmartPointer
<
vtkDiskSource
>::
New
();
// Maybe the resolution should be lower e.g. 50 or 25
disk
->
SetCircumferentialResolution
(
50
);
disk
->
SetCircumferentialResolution
(
30
);
disk
->
SetInnerRadius
(
radius
-
thickness
);
disk
->
SetOuterRadius
(
radius
+
thickness
);
// Set the circle origin
vtkSmartPointer
<
vtkTransform
>
t
=
vtkSmartPointer
<
vtkTransform
>::
New
();
t
->
Identity
();
t
->
Translate
(
pt
.
x
,
pt
.
y
,
pt
.
z
);
vtkSmartPointer
<
vtkTransformPolyDataFilter
>
tf
=
vtkSmartPointer
<
vtkTransformPolyDataFilter
>::
New
();
tf
->
SetTransform
(
t
);
tf
->
SetInputConnection
(
disk
->
GetOutputPort
());
tf
->
Update
();
disk
->
Update
();
vtkSmartPointer
<
vtkPolyDataMapper
>
mapper
=
vtkSmartPointer
<
vtkPolyDataMapper
>::
New
();
VtkUtils
::
SetInputData
(
mapper
,
tf
->
GetOutput
());
VtkUtils
::
SetInputData
(
mapper
,
disk
->
GetOutput
());
vtkSmartPointer
<
vtkActor
>
actor
=
vtkSmartPointer
<
vtkActor
>::
New
();
actor
->
GetProperty
()
->
LightingOff
();
actor
->
SetMapper
(
mapper
);
WidgetAccessor
::
setProp
(
*
this
,
actor
);
setColor
(
color
);
}
cv
::
viz
::
WCircle
::
WCircle
(
double
radius
,
const
Point3d
&
center
,
const
Vec3d
&
normal
,
double
thickness
,
const
Color
&
color
)
{
Vec3d
arbitrary
=
get_random_vec
();
Vec3d
zvec
=
normalized
(
normal
);
Vec3d
xvec
=
normalized
(
zvec
.
cross
(
arbitrary
));
Vec3d
yvec
=
zvec
.
cross
(
xvec
);
WCircle
circle
(
radius
,
thickness
,
color
);
circle
.
applyTransform
(
makeTransformToGlobal
(
xvec
,
yvec
,
zvec
,
center
));
*
this
=
circle
;
}
template
<>
cv
::
viz
::
WCircle
cv
::
viz
::
Widget
::
cast
<
cv
::
viz
::
WCircle
>
()
...
...
modules/viz/test/tests_simple.cpp
View file @
c0cc5512
...
...
@@ -293,7 +293,9 @@ TEST(Viz, show_simple_widgets)
Viz3d
viz
(
"show_simple_widgets"
);
viz
.
showWidget
(
"coos"
,
WCoordinateSystem
());
viz
.
showWidget
(
"cube"
,
WCube
());
viz
.
showWidget
(
"arr3"
,
WArrow
(
Vec3d
::
all
(
-
0.5
),
Vec3d
::
all
(
0.5
),
0.009
,
Color
::
raspberry
()));
viz
.
showWidget
(
"arro"
,
WArrow
(
Vec3d
::
all
(
-
0.5
),
Vec3d
::
all
(
0.5
),
0.009
,
Color
::
raspberry
()));
viz
.
showWidget
(
"cir1"
,
WCircle
(
0.5
,
0.01
,
Color
::
bluberry
()));
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
.
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