English 中文(简体)
Create: 缩略语
原标题:Create a pcl::PointCloud::Ptr from a pcl::PointCloud

我想知道这是否可行。 我有以下职能:

 pcl::PointCloud<pcl::PointXYZRGB> createPointCloud(std::Vector<Nodes> input)

哪怕是点云。 我愿知道,能否把这个点云放在一边,并把它的复印件放在一边。 页: 1

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(new pcl::PointCloud<pcl::PointXYZRGB>)

我努力这样做:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(createPointCloud(nodeList))

This results in a pretty obvious error ie. createPointCloud doesnt return a pointer to a cloud.

我也试图这样做:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR = &createPointCloud(nodeList)

并且:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(&createPointCloud(nodeList))

由此产生了汇编错误:“处理临时问题”

是否唯一选择是让职能退回点类型,还是有办法去做我要求的东西?

EDIT:

以下两种答复都是正确的,我给若昂以正确的标准,因为他第一次这样做。

最佳回答

我知道这一点是老旧的,而且可能不会再用于被占领土,但其他用户可能对此 st。 我建议采取以下行动:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(new pcl::PointCloud<pcl::PointXYZRGB>);
*cloudPTR = createPointCloud(nodeList);

Jonathon的回答是危险的: Ptr是一种促进的类型:共享的吸收器,意味着所指明的物体的所有权。 然而,在他的答复中,该物体实际上是一个当地变量,意思是该物体可能超出范围,而现在还提及该物体,而共同接收者最终将要求删除该物体,这是不明确的行为。

而使用_共享()则深度复制云。 该方案将正确运作,但如果你确实需要额外拷贝,则远远不够理想。

问题回答

是的,使用。 方法。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签