情况:快速索引到数据阵列
我有UINT8的数据阵列(例如UINT8(零(24 * 30000,1))),其编码24各字节的30000点。说,我有一个指向这个数据数组的数组,例如1:2:30000。我知道想要有效地为指向向量中引用的点创建正确的数据数组。例如,当尝试使用Robotics系统工具箱从'sensor_msgs/PointCloud2'消息中删除点时会发生这种情况。
解决方案
到现在为止,我的解决办法是这样的上述
startIndices = (pointIndices-1) * double(pointCloud_out.PointStep) + 1;
endIndices = pointIndices * double(pointCloud_out.PointStep);
indices = zeros(pointCloud_out.RowStep,1);
for ii = 1:numel(pointIndices)
indices((ii-1)*pointCloud_out.PointStep+1 : ii*pointCloud_out.PointStep) = startIndices(ii):endIndices(ii);
end
pointCloud_out.Data = pointCloud_in_msg.Data(indices);
其中pointIndices是上述指数之向量和pointCloud_out.PointStep编码多少字节有一个点( 24)。然而,这个解决方案在我的机器上需要大约1.5秒,而且这个解决方案需要很长的时间。
问:
你能想到的任何(非常)快速的解决方案做到这一点的?
我对你在问什么有点困惑。 pointCloud(:,indices)'有什么问题? – Suever
@Suever:pointCloud(-2消息)的数据字段是一个m×1的矩阵,在这里 – user1809923