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
ffad7b69
Commit
ffad7b69
authored
Jan 13, 2014
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test for textured mesh
parent
8d327fa4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
38 deletions
+38
-38
viz.hpp
modules/viz/include/opencv2/viz.hpp
+1
-2
types.hpp
modules/viz/include/opencv2/viz/types.hpp
+1
-1
types.cpp
modules/viz/src/types.cpp
+0
-20
test_viz3d.cpp
modules/viz/test/test_viz3d.cpp
+0
-15
tests_simple.cpp
modules/viz/test/tests_simple.cpp
+36
-0
No files found.
modules/viz/include/opencv2/viz.hpp
View file @
ffad7b69
...
...
@@ -99,8 +99,7 @@ namespace cv
CV_EXPORTS
Mat
readCloud
(
const
String
&
file
,
OutputArray
colors
=
noArray
(),
OutputArray
normals
=
noArray
());
///////////////////////////////////////////////////////////////////////////////////////////////
/// Reads mesh. Only ply format is supported now. The function tries to read texture from png-file,
/// and in case of faulure, just leaves the texture field empty.
/// Reads mesh. Only ply format is supported now and no texture load support
CV_EXPORTS
Mesh
readMesh
(
const
String
&
file
);
...
...
modules/viz/include/opencv2/viz/types.hpp
View file @
ffad7b69
...
...
@@ -115,7 +115,7 @@ namespace cv
Mat
texture
,
tcoords
;
//! Loads mesh from a given ply file
//! Loads mesh from a given ply file
(no texture load support for now)
static
Mesh
load
(
const
String
&
file
);
};
...
...
modules/viz/src/types.cpp
View file @
ffad7b69
...
...
@@ -73,7 +73,6 @@ cv::viz::Mesh cv::viz::Mesh::load(const String& file)
sink
->
Write
();
// Now handle the polygons
vtkSmartPointer
<
vtkCellArray
>
polygons
=
polydata
->
GetPolys
();
mesh
.
polygons
.
create
(
1
,
polygons
->
GetSize
(),
CV_32SC1
);
int
*
poly_ptr
=
mesh
.
polygons
.
ptr
<
int
>
();
...
...
@@ -87,25 +86,6 @@ cv::viz::Mesh cv::viz::Mesh::load(const String& file)
*
poly_ptr
++
=
(
int
)
cell_points
[
i
];
}
String
::
size_type
pos
=
file
.
find_last_of
(
'.'
);
String
png
=
(
pos
==
String
::
npos
)
?
file
:
file
.
substr
(
0
,
pos
+
1
)
+
"png"
;
vtkSmartPointer
<
vtkPNGReader
>
png_reader
=
vtkSmartPointer
<
vtkPNGReader
>::
New
();
if
(
png_reader
->
CanReadFile
(
png
.
c_str
()))
{
png_reader
->
SetFileName
(
png
.
c_str
());
png_reader
->
Update
();
vtkSmartPointer
<
vtkImageData
>
imagedata
=
png_reader
->
GetOutput
();
Size
sz
(
imagedata
->
GetDimensions
()[
0
],
imagedata
->
GetDimensions
()[
1
]);
int
channels
=
imagedata
->
GetNumberOfScalarComponents
();
CV_Assert
(
imagedata
->
GetScalarType
()
==
VTK_UNSIGNED_CHAR
);
void
*
ptr
=
imagedata
->
GetScalarPointer
(
0
,
0
,
0
);
Mat
(
sz
,
CV_8UC
(
channels
),
ptr
).
copyTo
(
mesh
.
texture
);
}
return
mesh
;
}
...
...
modules/viz/test/test_viz3d.cpp
View file @
ffad7b69
...
...
@@ -47,19 +47,11 @@ TEST(Viz_viz3d, develop)
{
cv
::
Mat
cloud
=
cv
::
viz
::
readCloud
(
get_dragon_ply_file_path
());
//cv::viz::Mesh3d mesh = cv::viz::Mesh3d::load(get_dragon_ply_file_path());
//theRNG().fill(mesh.colors, RNG::UNIFORM, 0, 255);
cv
::
viz
::
Viz3d
viz
(
"abc"
);
viz
.
setBackgroundMeshLab
();
viz
.
showWidget
(
"coo"
,
cv
::
viz
::
WCoordinateSystem
(
1
));
//viz.showWidget("cloud", cv::viz::WPaintedCloud(cloud, Vec3d(0.0, 0.0, -1.0), Vec3d(0.0, 0.0, 1.0)));
//viz.showWidget("cloud", cv::viz::WPaintedCloud(cloud, Vec3d(0.0, 0.0, -1.0), Vec3d(0.0, 0.0, 1.0), cv::viz::Color::green(), cv::viz::Color::red()));
viz
.
showWidget
(
"cloud"
,
cv
::
viz
::
WPaintedCloud
(
cloud
));
//viz.showWidget("h", cv::viz::Widget::fromPlyFile("d:/horse-red.ply"));
//viz.showWidget("a", cv::viz::WArrow(cv::Point3f(0,0,0), cv::Point3f(1,1,1)));
//---->>>>> <to_test_in_future>
//std::vector<cv::Affine3d> gt, es;
//cv::viz::readTrajectory(gt, "d:/Datasets/trajs/gt%05d.xml");
...
...
@@ -67,12 +59,5 @@ TEST(Viz_viz3d, develop)
//cv::Mat cloud = cv::viz::readCloud(get_dragon_ply_file_path());
//---->>>>> </to_test_in_future>
//theRNG().fill(colors, cv::RNG::UNIFORM, 0, 255);
//viz.showWidget("c", cv::viz::WCloud(cloud, colors));
//viz.showWidget("c", cv::viz::WCloud(cloud, cv::viz::Color::bluberry()));
//viz.showWidget("l", cv::viz::WLine(Point3f(0,0,0), Point3f(1,1,1)));
//viz.showWidget("s", cv::viz::WSphere(Point3f(0,0,0), 1));
//viz.showWidget("d", cv::viz::WCircle(Point3f(0,0,0), 1));
viz
.
spin
();
}
modules/viz/test/tests_simple.cpp
View file @
ffad7b69
...
...
@@ -145,6 +145,42 @@ TEST(Viz, show_mesh_random_colors)
viz
.
spin
();
}
TEST
(
Viz
,
show_textured_mesh
)
{
Mat
lena
=
imread
(
Path
::
combine
(
cvtest
::
TS
::
ptr
()
->
get_data_path
(),
"lena.png"
));
std
::
vector
<
Vec3d
>
points
;
std
::
vector
<
Vec2d
>
tcoords
;
std
::
vector
<
int
>
polygons
;
for
(
size_t
i
=
0
;
i
<
64
;
++
i
)
{
double
angle
=
CV_PI
/
2
*
i
/
64.0
;
points
.
push_back
(
Vec3d
(
0.00
,
cos
(
angle
),
sin
(
angle
))
*
0.75
);
points
.
push_back
(
Vec3d
(
1.57
,
cos
(
angle
),
sin
(
angle
))
*
0.75
);
tcoords
.
push_back
(
Vec2d
(
0.0
,
i
/
64.0
));
tcoords
.
push_back
(
Vec2d
(
1.0
,
i
/
64.0
));
}
for
(
size_t
i
=
0
;
i
<
points
.
size
()
/
2
-
1
;
++
i
)
{
int
polys
[]
=
{
3
,
2
*
i
,
2
*
i
+
1
,
2
*
i
+
2
,
3
,
2
*
i
+
1
,
2
*
i
+
2
,
2
*
i
+
3
};
polygons
.
insert
(
polygons
.
end
(),
polys
,
polys
+
sizeof
(
polys
)
/
sizeof
(
polys
[
0
]));
}
cv
::
viz
::
Mesh
mesh
;
mesh
.
cloud
=
Mat
(
points
,
true
).
reshape
(
3
,
1
);
mesh
.
tcoords
=
Mat
(
tcoords
,
true
).
reshape
(
2
,
1
);
mesh
.
polygons
=
Mat
(
polygons
,
true
).
reshape
(
1
,
1
);
mesh
.
texture
=
lena
;
Viz3d
viz
(
"show_textured_mesh"
);
viz
.
setBackgroundMeshLab
();
viz
.
showWidget
(
"coosys"
,
WCoordinateSystem
());
viz
.
showWidget
(
"mesh"
,
WMesh
(
mesh
));
viz
.
setRenderingProperty
(
"mesh"
,
SHADING
,
SHADING_PHONG
);
viz
.
spin
();
}
TEST
(
Viz
,
show_polyline
)
{
Mat
polyline
(
1
,
32
,
CV_64FC3
);
...
...
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