how to effeciently convert ROS PointCloud2 to pcl point cloud and visualize it in python
<p>I'm trying to do some segmentation on a pointcloud from a kinect one in ROS. As of now i have this:</p>

<pre><code>import rospy
import pcl
from sensor_msgs.msg import PointCloud2
import sensor_msgs.point_cloud2 as pc2
def on_new_point_cloud(data):
    pc = pc2.read_points(data, skip_nans=True, field_names=("x", "y", "z"))
    pc_list = []
    for p in pc:
        pc_list.append( [p[0],p[1],p[2]] )

    p = pcl.PointCloud()
    p.from_list(pc_list)
    seg = p.make_segmenter()
    seg.set_model_type(pcl.SACMODEL_PLANE)
    seg.set_method_type(pcl.SAC_RANSAC)
    indices, model = seg.segment()

rospy.init_node('listener', anonymous=True)
rospy.Subscriber("/kinect2/hd/points", PointCloud2, on_new_point_cloud)
rospy.spin()
</code></pre>

<p>This seems to work but is very slow because of the for loop.
My questions are:</p>

<p>1) How do i effeciently convert from the PointCloud2 message to a pcl pointcloud</p>

<p>2) How do i visualize the clouds.</p>