加快PLY文件读取 [英] Speed up PLY file reading

查看:241
本文介绍了加快PLY文件读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我在MATLAB中使用以下代码段将PLY读取到MATLAB矩阵中. 这是示例PLY文件.但是,当PLY文件的大小很大时,将花费相当长的时间.

Currently I use the following code segment in MATLAB to read a PLY into a MATLAB matrix. Here is a sample PLY file. But it take a considerable time when the size of the PLY file is quite large.

有没有更好的方法可以在MATLAB中有效地读取文本文件?

Is there a better way to read a text file efficiently in MATLAB?

data = textread(fileName, '%s','delimiter', '\n');
data = data(15:length(data),1);
data = (cellfun(@(x) strread(x,'%s','delimiter',' '), data, 'UniformOutput', false));

(此问题是我上一个问题的一部分

(This question is a part of my previous question listed here.)

推荐答案

您可以使用

You can use the dlmread function and make use of its ability to specify a starting position

>> data = dlmread(filename, ' ', 14, 0)
data =

    0.1054   -0.2731    0.8550  220.0000  195.0000  173.0000  255.0000         0
    0.1008   -0.2754    0.8550  228.0000  202.0000  184.0000  255.0000         0
    ...
    0.1139   -0.2803    0.8490  221.0000  194.0000  172.0000  255.0000         0
    0.1117   -0.2829    0.8500  225.0000  200.0000  178.0000  255.0000         0

最后两个参数指定数据的起始行和列.由于测试文件中的每一行都以空格结尾,因此出现了最终的零.我们可以用

The last two arguments specify the starting row and column of the data. The final zeros arise because each of the lines in your test file ends with a space. We can remove these with

>> data = data(:, 1:end-1);

dlmread 函数读取数字数据并删除在我的上一个答案中需要从string转换为double.

这篇关于加快PLY文件读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆