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
512afe2a
Commit
512afe2a
authored
Jul 13, 2013
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beatification of test_viz
parent
83cb28f1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
94 deletions
+80
-94
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+80
-94
No files found.
modules/viz/test/test_viz3d.cpp
View file @
512afe2a
...
...
@@ -48,6 +48,7 @@
#include <string>
#include <opencv2/viz.hpp>
using
namespace
cv
;
cv
::
Mat
cvcloud_load
()
{
...
...
@@ -67,102 +68,86 @@ cv::Mat cvcloud_load()
TEST
(
Viz_viz3d
,
accuracy
)
{
temp_viz
::
Viz3d
v
(
"abc"
);
//v.spin();
v
.
setBackgroundColor
();
cv
::
Mat
cloud
=
cvcloud_load
();
cv
::
Mat
colors
(
cloud
.
size
(),
CV_8UC3
,
cv
::
Scalar
(
0
,
255
,
0
));
float
angle_x
=
0.0
f
;
float
angle_y
=
0.0
f
;
float
angle_z
=
0.0
f
;
float
pos_x
=
0.0
f
;
float
pos_y
=
0.0
f
;
float
pos_z
=
0.0
f
;
temp_viz
::
Mesh3d
::
Ptr
mesh
=
temp_viz
::
Mesh3d
::
mesh_load
(
"d:/horse.ply"
);
v
.
addPolygonMesh
(
*
mesh
,
"pq"
);
int
col_blue
=
0
;
int
col_green
=
0
;
int
col_red
=
0
;
temp_viz
::
LineWidget
lw
(
cv
::
Point3f
(
0.0
,
0.0
,
0.0
),
cv
::
Point3f
(
4.0
,
4.0
,
4.0
),
temp_viz
::
Color
(
0
,
255
,
0
));
temp_viz
::
PlaneWidget
pw
(
cv
::
Vec4f
(
0.0
,
1.0
,
2.0
,
3.0
),
50.0
);
temp_viz
::
SphereWidget
sw
(
cv
::
Point3f
(
0
,
0
,
0
),
0.5
);
temp_viz
::
ArrowWidget
aw
(
cv
::
Point3f
(
0
,
0
,
0
),
cv
::
Point3f
(
1
,
1
,
1
),
temp_viz
::
Color
(
255
,
0
,
0
));
temp_viz
::
CircleWidget
cw
(
cv
::
Point3f
(
0
,
0
,
0
),
0.5
,
0.01
,
temp_viz
::
Color
(
0
,
255
,
0
));
temp_viz
::
CylinderWidget
cyw
(
cv
::
Point3f
(
0
,
0
,
0
),
cv
::
Point3f
(
-
1
,
-
1
,
-
1
),
0.5
,
30
,
temp_viz
::
Color
(
0
,
255
,
0
));
temp_viz
::
CubeWidget
cuw
(
cv
::
Point3f
(
-
2
,
-
2
,
-
2
),
cv
::
Point3f
(
-
1
,
-
1
,
-
1
));
temp_viz
::
CoordinateSystemWidget
csw
;
temp_viz
::
TextWidget
tw
(
"TEST"
,
cv
::
Point2i
(
100
,
100
),
20
);
temp_viz
::
CloudWidget
pcw
(
cloud
,
colors
);
temp_viz
::
CloudWidget
pcw2
(
cloud
,
temp_viz
::
Color
(
0
,
255
,
255
));
// v.showWidget("line", lw);
// v.showWidget("plane", pw);
v
.
showWidget
(
"sphere"
,
sw
);
v
.
spin
();
//v.showWidget("arrow", aw);
//v.showWidget("circle", cw);
//v.showWidget("cylinder", cyw);
//v.showWidget("cube", cuw);
//v.showWidget("coordinateSystem", csw);
//v.showWidget("coordinateSystem2", temp_viz::CoordinateSystemWidget(2.0), cv::Affine3f(0, 0, 0, cv::Vec3f(2, 0, 0)));
//v.showWidget("text",tw);
//v.showWidget("pcw",pcw);
//v.showWidget("pcw2",pcw2);
// temp_viz::LineWidget lw2 = lw;
// v.showPointCloud("cld",cloud, colors);
cv
::
Mat
normals
(
cloud
.
size
(),
cloud
.
type
(),
cv
::
Scalar
(
0
,
10
,
0
));
//cv::viz::Mesh3d::Ptr mesh = cv::viz::Mesh3d::mesh_load("d:/horse.ply");
const
Vec4d
data
[]
=
{
Vec4d
(
0.0
,
0.0
,
0.0
,
0.0
),
Vec4d
(
1.0
,
1.0
,
1.0
,
1.0
),
cv
::
Vec4d
(
0.0
,
2.0
,
0.0
,
0.0
),
cv
::
Vec4d
(
3.0
,
4.0
,
1.0
,
1.0
)
};
cv
::
Mat
points
(
1
,
sizeof
(
data
)
/
sizeof
(
data
[
0
]),
CV_64FC4
,
(
void
*
)
data
);
points
=
points
.
reshape
(
4
,
2
);
cv
::
viz
::
Viz3d
viz
(
"abc"
);
viz
.
setBackgroundColor
();
Vec3f
angle
=
Vec3f
::
all
(
0
);
Vec3f
pos
=
Vec3f
::
all
(
0
);
//viz.addPolygonMesh(*mesh, "pq");
viz
::
Color
color
=
viz
::
Color
::
black
();
viz
::
LineWidget
lw
(
Point3f
(
0
,
0
,
0
),
Point3f
(
4.
f
,
4.
f
,
4.
f
),
viz
::
Color
::
green
());
viz
::
PlaneWidget
pw
(
Vec4f
(
0.0
,
1.0
,
2.0
,
3.0
),
5.0
);
viz
::
SphereWidget
sw
(
Point3f
(
0
,
0
,
0
),
0.5
);
viz
::
ArrowWidget
aw
(
Point3f
(
0
,
0
,
0
),
Point3f
(
1
,
1
,
1
),
viz
::
Color
::
red
());
viz
::
CircleWidget
cw
(
Point3f
(
0
,
0
,
0
),
0.5
,
0.01
,
viz
::
Color
::
green
());
viz
::
CylinderWidget
cyw
(
Point3f
(
0
,
0
,
0
),
Point3f
(
-
1
,
-
1
,
-
1
),
0.5
,
30
,
viz
::
Color
::
green
());
viz
::
CubeWidget
cuw
(
Point3f
(
-
2
,
-
2
,
-
2
),
Point3f
(
-
1
,
-
1
,
-
1
));
viz
::
CoordinateSystemWidget
csw
;
viz
::
TextWidget
tw
(
"TEST"
,
Point
(
100
,
100
),
20
);
viz
::
CloudWidget
pcw
(
cloud
,
colors
);
viz
::
CloudWidget
pcw2
(
cloud
,
viz
::
Color
::
magenta
());
viz
.
showWidget
(
"line"
,
lw
);
viz
.
showWidget
(
"plane"
,
pw
);
viz
.
showWidget
(
"sphere"
,
sw
);
viz
.
showWidget
(
"arrow"
,
aw
);
viz
.
showWidget
(
"circle"
,
cw
);
viz
.
showWidget
(
"cylinder"
,
cyw
);
viz
.
showWidget
(
"cube"
,
cuw
);
viz
.
showWidget
(
"coordinateSystem"
,
csw
);
viz
.
showWidget
(
"coordinateSystem2"
,
viz
::
CoordinateSystemWidget
(
2.0
),
Affine3f
().
translate
(
Vec3f
(
2
,
0
,
0
)));
viz
.
showWidget
(
"text"
,
tw
);
viz
.
showWidget
(
"pcw"
,
pcw
);
viz
.
showWidget
(
"pcw2"
,
pcw2
);
// viz::LineWidget lw2 = lw;
// v.showPointCloud("cld",cloud, colors);
// v.addPointCloudNormals(cloud, normals, 100, 0.02, "n");
//
temp_
viz::CloudNormalsWidget cnw(cloud, normals);
//viz::CloudNormalsWidget cnw(cloud, normals);
//v.showWidget("n", cnw);
// lw = v.getWidget("n").cast<viz::LineWidget>();
// pw = v.getWidget("n").cast<viz::PlaneWidget>();
// lw = v.getWidget("n").cast<temp_viz::LineWidget>();
// pw = v.getWidget("n").cast<temp_viz::PlaneWidget>();
viz
::
PolyLineWidget
plw
(
points
,
viz
::
Color
::
green
());
viz
.
showWidget
(
"polyline"
,
plw
);
// lw = v.getWidget("polyline").cast<viz::LineWidget>();
cv
::
Mat
points
(
1
,
4
,
CV_64FC4
);
viz
.
spin
(
);
cv
::
Vec4d
*
data
=
points
.
ptr
<
cv
::
Vec4d
>
();
data
[
0
]
=
cv
::
Vec4d
(
0.0
,
0.0
,
0.0
,
0.0
);
data
[
1
]
=
cv
::
Vec4d
(
1.0
,
1.0
,
1.0
,
1.0
);
data
[
2
]
=
cv
::
Vec4d
(
0.0
,
2.0
,
0.0
,
0.0
);
data
[
3
]
=
cv
::
Vec4d
(
3.0
,
4.0
,
1.0
,
1.0
);
points
=
points
.
reshape
(
0
,
2
);
temp_viz
::
PolyLineWidget
plw
(
points
,
temp_viz
::
Color
::
green
());
v
.
showWidget
(
"polyline"
,
plw
);
// lw = v.getWidget("polyline").cast<temp_viz::LineWidget>();
v
.
spin
();
//temp_viz::GridWidget gw(temp_viz::Vec2i(100,100), temp_viz::Vec2d(1,1));
//viz::GridWidget gw(viz::Vec2i(100,100), viz::Vec2d(1,1));
//v.showWidget("grid", gw);
lw
=
v
.
getWidget
(
"grid"
).
cast
<
temp_
viz
::
LineWidget
>
();
lw
=
v
iz
.
getWidget
(
"grid"
).
cast
<
cv
::
viz
::
LineWidget
>
();
//
temp_viz::Text3DWidget t3w("OpenCV", cv::Point3f(0.0, 2.0, 0.0), 1.0, temp_
viz::Color(255,255,0));
//
viz::Text3DWidget t3w("OpenCV", cv::Point3f(0.0, 2.0, 0.0), 1.0,
viz::Color(255,255,0));
//v.showWidget("txt3d", t3w);
// float grid_x_angle = 0.0;
while
(
!
v
.
wasStopped
())
while
(
!
v
iz
.
wasStopped
())
{
// Creating new point cloud with id cloud1
cv
::
Affine3f
cloudPosition
(
angle
_x
,
angle_y
,
angle_z
,
cv
::
Vec3f
(
pos_x
,
pos_y
,
pos_z
)
);
cv
::
Affine3f
cloudPosition2
(
angle
_x
,
angle_y
,
angle_z
,
cv
::
Vec3f
(
pos_x
+
0.2
,
pos_y
+
0.2
,
pos_z
+
0.2
));
cv
::
Affine3f
cloudPosition
(
angle
,
pos
);
cv
::
Affine3f
cloudPosition2
(
angle
,
pos
+
Vec3f
(
0.2
f
,
0.2
f
,
0.2
f
));
lw
.
setColor
(
temp_viz
::
Color
(
col_blue
,
col_green
,
col_red
)
);
lw
.
setColor
(
color
);
// lw.setLineWidth(pos_x * 10);
//plw.setColor(
temp_
viz::Color(col_blue, col_green, col_red));
//plw.setColor(viz::Color(col_blue, col_green, col_red));
sw
.
setPose
(
cloudPosition
);
// pw.setPose(cloudPosition);
...
...
@@ -178,34 +163,35 @@ TEST(Viz_viz3d, accuracy)
// v.setWidgetPose("n",cloudPosition);
// v.setWidgetPose("pcw2", cloudPosition);
//cnw.setColor(temp_viz::Color(col_blue, col_green, col_red));
//pcw2.setColor(temp_viz::Color(col_blue, col_green, col_red));
//gw.updatePose(temp_viz::Affine3f(0.0, 0.1, 0.0, cv::Vec3f(0.0,0.0,0.0)));
angle_x
+=
0.1
f
;
angle_y
-=
0.1
f
;
angle_z
+=
0.1
f
;
pos_x
=
std
::
sin
(
angle_x
);
pos_y
=
std
::
sin
(
angle_y
);
pos_z
=
std
::
sin
(
angle_z
);
col_blue
=
int
(
angle_x
*
10
)
%
256
;
col_green
=
int
(
angle_x
*
20
)
%
256
;
col_red
=
int
(
angle_x
*
30
)
%
256
;
v
.
spinOnce
(
1
,
true
);
//cnw.setColor(viz::Color(col_blue, col_green, col_red));
//pcw2.setColor(viz::Color(col_blue, col_green, col_red));
//gw.updatePose(viz::Affine3f(0.0, 0.1, 0.0, cv::Vec3f(0.0,0.0,0.0)));
angle
[
0
]
+=
0.1
f
;
angle
[
1
]
-=
0.1
f
;
angle
[
2
]
+=
0.1
f
;
pos
[
0
]
=
std
::
sin
(
angle
[
0
]);
pos
[
1
]
=
std
::
sin
(
angle
[
1
]);
pos
[
2
]
=
std
::
sin
(
angle
[
2
]);
color
[
0
]
=
int
(
angle
[
0
]
*
10
)
%
256
;
color
[
1
]
=
int
(
angle
[
0
]
*
20
)
%
256
;
color
[
2
]
=
int
(
angle
[
0
]
*
30
)
%
256
;
viz
.
spinOnce
(
1
,
true
);
}
//
//
//
temp_
viz::ModelCoefficients mc;
// viz::ModelCoefficients mc;
// mc.values.resize(4);
// mc.values[0] = mc.values[1] = mc.values[2] = mc.values[3] = 1;
// v.addPlane(mc);
//
//
//
temp_viz::Mesh3d::Ptr mesh = temp_
viz::mesh_load("horse.ply");
//
viz::Mesh3d::Ptr mesh =
viz::mesh_load("horse.ply");
// v.addPolygonMesh(*mesh, "pq");
//
// v.spinOnce(1000, true);
...
...
@@ -229,7 +215,7 @@ TEST(Viz_viz3d, accuracy)
//
// colors.setTo(cv::Scalar(255, 0, 0));
//
// v.addSphere(cv::Point3f(0, 0, 0), 0.3,
temp_
viz::Color::blue());
// v.addSphere(cv::Point3f(0, 0, 0), 0.3, viz::Color::blue());
//
// cv::Mat cvpoly(1, 5, CV_32FC3);
// cv::Point3f* pdata = cvpoly.ptr<cv::Point3f>();
...
...
@@ -238,7 +224,7 @@ TEST(Viz_viz3d, accuracy)
// pdata[2] = cv::Point3f(3, 1, 2);
// pdata[3] = cv::Point3f(0, 2, 4);
// pdata[4] = cv::Point3f(7, 2, 3);
// v.addPolygon(cvpoly,
temp_
viz::Color::white());
// v.addPolygon(cvpoly, viz::Color::white());
//
// // Updating cloud1
// v.showPointCloud("cloud1", cloud, colors);
...
...
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