Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
4e6e8a4e
Commit
4e6e8a4e
authored
Dec 11, 2015
by
Andrew Hundt
Committed by
Vitaly Tuzov
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loadPLYSimple basic automatic detection of normals, color, and alpha properties
parent
47237bf1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
14 deletions
+33
-14
ppf_helpers.hpp
...matching/include/opencv2/surface_matching/ppf_helpers.hpp
+1
-1
ppf_helpers.cpp
modules/surface_matching/src/ppf_helpers.cpp
+32
-13
No files found.
modules/surface_matching/include/opencv2/surface_matching/ppf_helpers.hpp
View file @
4e6e8a4e
...
...
@@ -61,7 +61,7 @@ namespace ppf_match_3d
* and whether it should be loaded or not
* @return Returns the matrix on successfull load
*/
CV_EXPORTS
Mat
loadPLYSimple
(
const
char
*
fileName
,
int
withNormals
);
CV_EXPORTS
Mat
loadPLYSimple
(
const
char
*
fileName
,
int
withNormals
=
0
);
/**
* @brief Write a point cloud to PLY file
...
...
modules/surface_matching/src/ppf_helpers.cpp
View file @
4e6e8a4e
...
...
@@ -69,10 +69,13 @@ std::vector<std::string> split(const std::string &text, char sep) {
Mat
loadPLYSimple
(
const
char
*
fileName
,
int
withNormals
)
Mat
loadPLYSimple
(
const
char
*
fileName
,
int
withNormals
/* = 0 */
)
{
Mat
cloud
;
int
numVertices
=
0
;
int
numCols
=
3
;
bool
with_color
=
false
;
bool
with_alpha
=
false
;
// alpha transparency
std
::
ifstream
ifs
(
fileName
);
...
...
@@ -90,41 +93,57 @@ Mat loadPLYSimple(const char* fileName, int withNormals)
{
numVertices
=
atoi
(
tokens
[
2
].
c_str
());
}
if
(
tokens
.
size
()
==
3
&&
tokens
[
0
]
==
"property"
)
{
if
(
tokens
[
3
]
==
"nx"
||
tokens
[
3
]
==
"normal_x"
)
{
withNormals
=
true
;
numCols
+=
3
;
}
else
if
(
tokens
[
3
]
==
"r"
||
tokens
[
3
]
==
"red"
)
{
with_color
=
true
;
numCols
+=
3
;
}
else
if
(
tokens
[
3
]
==
"a"
||
tokens
[
3
]
==
"alpha"
)
{
with_alpha
=
true
;
numCols
+=
1
;
}
}
else
if
(
tokens
.
size
()
>
1
&&
tokens
[
0
]
==
"format"
)
{
if
(
tokens
[
1
]
!=
"ascii"
){
printf
(
"Cannot read file, only ascii ply format is currently supported...
\n
"
);
// uncomment below when CV_StsBadArg can be located
//OPENCV_ERROR (CV_StsBadArg, "loadPLYSimple", "Cannot read file, only ascii ply format is currently supported...");
return
Mat
();
}
}
std
::
getline
(
ifs
,
str
);
}
if
(
withNormals
)
cloud
=
Mat
(
numVertices
,
6
,
CV_32FC1
);
else
cloud
=
Mat
(
numVertices
,
3
,
CV_32FC1
);
cloud
=
Mat
(
numVertices
,
numCols
,
CV_32FC1
);
for
(
int
i
=
0
;
i
<
numVertices
;
i
++
)
{
float
*
data
=
cloud
.
ptr
<
float
>
(
i
);
for
(
int
col
=
0
;
col
<
numCols
;
++
col
)
{
ifs
>>
data
[
col
];
}
if
(
withNormals
)
{
ifs
>>
data
[
0
]
>>
data
[
1
]
>>
data
[
2
]
>>
data
[
3
]
>>
data
[
4
]
>>
data
[
5
];
// normalize to unit norm
double
norm
=
sqrt
(
data
[
3
]
*
data
[
3
]
+
data
[
4
]
*
data
[
4
]
+
data
[
5
]
*
data
[
5
]);
if
(
norm
>
0.00001
)
{
data
[
3
]
/=
(
float
)
norm
;
data
[
4
]
/=
(
float
)
norm
;
data
[
5
]
/=
(
float
)
norm
;
data
[
3
]
/=
static_cast
<
float
>
(
norm
)
;
data
[
4
]
/=
static_cast
<
float
>
(
norm
)
;
data
[
5
]
/=
static_cast
<
float
>
(
norm
)
;
}
}
else
{
ifs
>>
data
[
0
]
>>
data
[
1
]
>>
data
[
2
];
}
}
//cloud *= 5.0f;
...
...
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