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
d11d07aa
Commit
d11d07aa
authored
Jun 07, 2013
by
ozantonkal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
showPointCloud initial implementation together with test
parent
ace0933b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
66 deletions
+84
-66
viz3d.hpp
modules/viz/include/opencv2/viz/viz3d.hpp
+2
-9
viz3d_impl.hpp
modules/viz/src/q/viz3d_impl.hpp
+8
-2
viz3d.cpp
modules/viz/src/viz3d.cpp
+2
-7
viz3d_impl.cpp
modules/viz/src/viz3d_impl.cpp
+0
-0
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+72
-48
No files found.
modules/viz/include/opencv2/viz/viz3d.hpp
View file @
d11d07aa
...
...
@@ -26,22 +26,15 @@ namespace temp_viz
void
setBackgroundColor
(
const
Color
&
color
=
Color
::
black
());
void
addCoordinateSystem
(
double
scale
,
const
Affine3f
&
t
,
const
String
&
id
=
"coordinate"
);
void
addPointCloud
(
const
Mat
&
cloud
,
const
Mat
&
colors
,
const
String
&
id
=
"cloud"
,
const
Mat
&
mask
=
Mat
());
void
showPointCloud
(
const
std
::
string
&
id
,
cv
::
InputArray
cloud
,
cv
::
InputArray
colors
,
const
cv
::
Affine3f
&
pose
=
cv
::
Affine3f
::
Identity
());
bool
addPointCloudNormals
(
const
Mat
&
cloud
,
const
Mat
&
normals
,
int
level
=
100
,
float
scale
=
0.02
f
,
const
String
&
id
=
"cloud"
);
bool
addPlane
(
const
ModelCoefficients
&
coefficients
,
const
String
&
id
=
"plane"
);
bool
addPlane
(
const
ModelCoefficients
&
coefficients
,
double
x
,
double
y
,
double
z
,
const
String
&
id
=
"plane"
);
bool
removeCoordinateSystem
(
const
String
&
id
=
"coordinate"
);
bool
updatePointCloud
(
const
Mat
&
cloud
,
const
Mat
&
colors
,
const
String
&
id
=
"cloud"
,
const
Mat
&
mask
=
Mat
());
bool
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polygon"
);
bool
updatePolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
=
"polygon"
);
...
...
modules/viz/src/q/viz3d_impl.hpp
View file @
d11d07aa
...
...
@@ -96,8 +96,14 @@ public:
bool
addText3D
(
const
std
::
string
&
text
,
const
cv
::
Point3f
&
position
,
const
Color
&
color
,
double
textScale
=
1.0
,
const
std
::
string
&
id
=
""
);
bool
addPointCloudNormals
(
const
cv
::
Mat
&
cloud
,
const
cv
::
Mat
&
normals
,
int
level
=
100
,
float
scale
=
0.02
f
,
const
std
::
string
&
id
=
"cloud"
);
void
addPointCloud
(
const
cv
::
Mat
&
cloud
,
const
cv
::
Mat
&
colors
,
const
std
::
string
&
id
=
"cloud"
,
const
cv
::
Mat
&
mask
=
cv
::
Mat
());
bool
updatePointCloud
(
const
cv
::
Mat
&
cloud
,
const
cv
::
Mat
&
colors
,
const
std
::
string
&
id
=
"cloud"
,
const
cv
::
Mat
&
mask
=
cv
::
Mat
());
/** \brief If the id exists, updates the point cloud; otherwise, adds a new point cloud to the scene
* \param[in] id a variable to identify the point cloud
* \param[in] cloud cloud input in x,y,z coordinates
* \param[in] colors color input in the same order of the points or single uniform color
* \param[in] pose transform to be applied on the point cloud
*/
void
showPointCloud
(
const
std
::
string
&
id
,
cv
::
InputArray
cloud
,
cv
::
InputArray
colors
,
const
cv
::
Affine3f
&
pose
=
cv
::
Affine3f
::
Identity
());
bool
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
cv
::
Mat
&
mask
,
const
std
::
string
&
id
=
"polygon"
);
bool
updatePolygonMesh
(
const
Mesh3d
&
mesh
,
const
cv
::
Mat
&
mask
,
const
std
::
string
&
id
=
"polygon"
);
...
...
modules/viz/src/viz3d.cpp
View file @
d11d07aa
...
...
@@ -23,9 +23,9 @@ void temp_viz::Viz3d::addCoordinateSystem(double scale, const Affine3f& t, const
impl_
->
addCoordinateSystem
(
scale
,
t
,
id
);
}
void
temp_viz
::
Viz3d
::
addPointCloud
(
const
Mat
&
cloud
,
const
Mat
&
colors
,
const
String
&
id
,
const
Mat
&
mask
)
void
temp_viz
::
Viz3d
::
showPointCloud
(
const
std
::
string
&
id
,
cv
::
InputArray
cloud
,
cv
::
InputArray
colors
,
const
cv
::
Affine3f
&
pose
)
{
impl_
->
addPointCloud
(
cloud
,
colors
,
id
,
mask
);
impl_
->
showPointCloud
(
id
,
cloud
,
colors
,
pose
);
}
bool
temp_viz
::
Viz3d
::
addPointCloudNormals
(
const
Mat
&
cloud
,
const
Mat
&
normals
,
int
level
,
float
scale
,
const
String
&
id
)
...
...
@@ -33,11 +33,6 @@ bool temp_viz::Viz3d::addPointCloudNormals (const Mat &cloud, const Mat& normals
return
impl_
->
addPointCloudNormals
(
cloud
,
normals
,
level
,
scale
,
id
);
}
bool
temp_viz
::
Viz3d
::
updatePointCloud
(
const
Mat
&
cloud
,
const
Mat
&
colors
,
const
String
&
id
,
const
Mat
&
mask
)
{
return
impl_
->
updatePointCloud
(
cloud
,
colors
,
id
,
mask
);
}
bool
temp_viz
::
Viz3d
::
addPolygonMesh
(
const
Mesh3d
&
mesh
,
const
String
&
id
)
{
return
impl_
->
addPolygonMesh
(
mesh
,
Mat
(),
id
);
...
...
modules/viz/src/viz3d_impl.cpp
View file @
d11d07aa
This diff is collapsed.
Click to expand it.
modules/viz/test/test_viz3d.cpp
View file @
d11d07aa
...
...
@@ -78,56 +78,80 @@ TEST(Viz_viz3d, accuracy)
cv
::
Mat
cloud
=
cvcloud_load
();
cv
::
Mat
colors
(
cloud
.
size
(),
CV_8UC3
,
cv
::
Scalar
(
0
,
255
,
0
));
v
.
addPointCloud
(
cloud
,
colors
);
cv
::
Mat
normals
(
cloud
.
size
(),
CV_32FC3
,
cv
::
Scalar
(
0
,
10
,
0
));
v
.
addPointCloudNormals
(
cloud
,
normals
,
100
,
0.02
,
"n"
);
temp_viz
::
ModelCoefficients
mc
;
mc
.
values
.
resize
(
4
);
mc
.
values
[
0
]
=
mc
.
values
[
1
]
=
mc
.
values
[
2
]
=
mc
.
values
[
3
]
=
1
;
v
.
addPlane
(
mc
);
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
::
mesh_load
(
"d:/horse.ply"
);
v
.
addPolygonMesh
(
*
mesh
,
"pq"
);
v
.
spinOnce
(
1000
,
true
);
v
.
removeCoordinateSystem
();
for
(
int
i
=
0
;
i
<
mesh
->
cloud
.
cols
;
++
i
)
mesh
->
cloud
.
ptr
<
cv
::
Point3f
>
()[
i
]
+=
cv
::
Point3f
(
1
,
1
,
1
);
v
.
updatePolygonMesh
(
*
mesh
,
"pq"
);
for
(
int
i
=
0
;
i
<
mesh
->
cloud
.
cols
;
++
i
)
mesh
->
cloud
.
ptr
<
cv
::
Point3f
>
()[
i
]
-=
cv
::
Point3f
(
2
,
2
,
2
);
v
.
addPolylineFromPolygonMesh
(
*
mesh
);
v
.
addText
(
"===Abd sadfljsadlk"
,
100
,
100
,
cv
::
Scalar
(
255
,
0
,
0
),
15
);
for
(
int
i
=
0
;
i
<
cloud
.
cols
;
++
i
)
cloud
.
ptr
<
cv
::
Point3f
>
()[
i
].
x
*=
2
;
colors
.
setTo
(
cv
::
Scalar
(
255
,
0
,
0
));
v
.
addSphere
(
cv
::
Point3f
(
0
,
0
,
0
),
0.3
,
temp_viz
::
Color
::
blue
());
cv
::
Mat
cvpoly
(
1
,
5
,
CV_32FC3
);
cv
::
Point3f
*
pdata
=
cvpoly
.
ptr
<
cv
::
Point3f
>
();
pdata
[
0
]
=
cv
::
Point3f
(
0
,
0
,
0
);
pdata
[
1
]
=
cv
::
Point3f
(
0
,
1
,
1
);
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
.
updatePointCloud
(
cloud
,
colors
);
v
.
spin
();
while
(
1
)
{
// Creating new point cloud with id cloud1
cv
::
Affine3f
cloudPosition
(
angle_x
,
angle_y
,
angle_z
,
cv
::
Vec3f
(
pos_x
,
pos_y
,
pos_z
));
v
.
showPointCloud
(
"cloud1"
,
cloud
,
colors
,
cloudPosition
);
angle_x
+=
0.1
;
angle_y
-=
0.1
;
angle_z
+=
0.1
;
pos_x
=
std
::
sin
(
angle_x
);
pos_y
=
std
::
sin
(
angle_x
);
pos_z
=
std
::
sin
(
angle_x
);
v
.
spinOnce
(
1
,
true
);
}
// cv::Mat normals(cloud.size(), CV_32FC3, cv::Scalar(0, 10, 0));
//
// v.addPointCloudNormals(cloud, normals, 100, 0.02, "n");
//
//
// temp_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");
// v.addPolygonMesh(*mesh, "pq");
//
// v.spinOnce(1000, true);
//
// v.removeCoordinateSystem();
//
// for(int i = 0; i < mesh->cloud.cols; ++i)
// mesh->cloud.ptr<cv::Point3f>()[i] += cv::Point3f(1, 1, 1);
//
// v.updatePolygonMesh(*mesh, "pq");
//
//
// for(int i = 0; i < mesh->cloud.cols; ++i)
// mesh->cloud.ptr<cv::Point3f>()[i] -= cv::Point3f(2, 2, 2);
// v.addPolylineFromPolygonMesh(*mesh);
//
//
// v.addText("===Abd sadfljsadlk", 100, 100, cv::Scalar(255, 0, 0), 15);
// for(int i = 0; i < cloud.cols; ++i)
// cloud.ptr<cv::Point3f>()[i].x *=2;
//
// colors.setTo(cv::Scalar(255, 0, 0));
//
// v.addSphere(cv::Point3f(0, 0, 0), 0.3, temp_viz::Color::blue());
//
// cv::Mat cvpoly(1, 5, CV_32FC3);
// cv::Point3f* pdata = cvpoly.ptr<cv::Point3f>();
// pdata[0] = cv::Point3f(0, 0, 0);
// pdata[1] = cv::Point3f(0, 1, 1);
// 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());
//
// // Updating cloud1
// v.showPointCloud("cloud1", cloud, colors);
// v.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