使用点云库从C++中的 URL 读取文件,而不是本地文件
Read files from URL in C++ instead of local files using Point Cloud Library
我是点云库 (PCL( 的新手,对指针如何工作C++了解有限。虽然我们可以从文件加载文件并可视化它(使用本教程(,但我们如何从 HTTP URL 读取它?
int main () {
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile ("my_point_cloud.pcd", *cloud);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//blocks until the cloud is actually rendered
viewer.showCloud(cloud);
//use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer
while (!viewer.wasStopped ())
{
}
return 0;
}
我不知道PCL 是否直接执行此操作,但您可以使用 cpr 或 urdl C++库将文件下载到本地临时文件,或者实际处理流。
Urdl 示例:
// For urdl::url.
#include <urdl/url.hpp>
// etc...
urdl::url url("http://somehost/path");
urdl::istream is("http://somehost/path");
并且可以直接使用此 iStream(如果 PCL 支持(,也可以将流上的数据写入文件。
使用 cpr 的示例程序(又名 C++ 请求;基于 C 库libcurl
(:
#include <cpr/cpr.h>
int main(int argc, char** argv) {
auto r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass"},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
r.status_code; // 200
r.header["content-type"]; // application/json; charset=utf-8
r.text; // JSON text string
}
(摘自CPR官方网站(
相关文章:
- 正在将csv文件读取为双精度矢量
- 将从格式化文本文件读取的文本数据存储到链表
- C++ 读取文件读取文件不正确
- 使用对象文件读取三角形数据网格
- 如何减慢从 BVH 文件读取的 opengl 动画?
- 从文件读取,并写入函数C++中的数组
- 从对象C++中的文件读取内容时出现分段错误
- 从文件读取并通过矢量输出到控制台
- 尝试将字符串从文件读取到无符号字符向量中
- 如何将文本文件读取到二维数组中并以 c++ 打印
- 简化文件读取的函数
- 如何将逗号分隔的文件读取为 2D int 数组?
- 在 c++ 中将数据从文件读取到队列中
- 'std::wstring_convert'尽可能多地转换(从 UTF8 文件读取块)
- C++,从文件读取到结构,然后读取到向量(结构被推入向量太多次,而不仅仅是一次)
- 文件读取C++包括空格键
- 从文件读取时未将值推回矢量
- 从文件 C++ 读取时的无限循环
- 从同一文件读取和写入?
- 从.txt文件读取到C++中的双精度向量