c++ - PCL 读取 PLY 错误
问题描述
我无法使用 PCL 读取 PLY 文件,并且尝试了各种输入,甚至是斯坦福兔子。我得到的错误是
parse error: couldn't read the magic string
[pcl::PLYReader::read] problem parsing header!
[pcl::PLYReader::read] problem parsing header!
Couldn't read ply file
看这里https://github.com/PointCloudLibrary/pcl/blob/master/io/src/ply/ply_parser.cpp它正在尝试读取与文件内容匹配的4个字符
ply
format ascii 1.0
element vertex 3511
property double x
property double y
property double z
element face 0
property list int int vertex_indices
end_header
编辑
编码
if (pcl::io::loadPLYFile(filename, out_pcd) == -1) {
PCL_ERROR("Couldn't read ply file \n");
return 0;
}
我已经在 meshlab 中成功打开了文件,所以我不认为文件格式错误。
编辑 2
我的 C++ 不是很好,我不确定如何深入调试 PCL,因此将他们的代码复制到我的main()
. 它运行良好,可以解析魔术字符串而不会触发上述错误(!istream
)。
// PCL SRC START
std::ifstream istream (pathToInput, std::ios::in | std::ios::binary);
std::string line;
int line_number_ = 0;
char line_delim = '\n';
int char_ignore_count = 0;
// magic
char magic[4];
istream.read (magic, 4);
// Check if CR/LF, setup delim and char skip
if (magic[3] == '\r')
{
istream.ignore (1);
line_delim = '\r';
char_ignore_count = 1;
}
++line_number_;
if (!istream)
{
if (error_callback_)
error_callback_ (line_number_, "parse error: couldn't read the magic string");
return false;
}
// PCL SRC END
// VALUE OF magic IS 'ply\r'
解决方案
推荐阅读
- angular - Angular 4 OnClick 选项卡
- sql - 为每个记录增加一个变量
- java - java Authenticator 类不在 POST 上进行身份验证
- javascript - npm install 和流星 npm install 有什么区别
- vba - 在excel中使用VBA删除列
- asp.net - Window server 2016 - HTTP 错误 503 服务不可用
- android - 以前的活动在查看页面更改时被破坏
- php - Android Studio 使用 Android Volley 登录
- html - 如果它不是我悬停的那个的子元素,我如何影响一个 div 的 css?
- html - 使用 knockoutjs 时 Chrome 中的 Maxlength 约束验证异常