davidcaron / pclpy

Python bindings for the Point Cloud Library (PCL)
MIT License
427 stars 59 forks source link

Unable to fit the output to the window properly? #13

Closed niranjanreddy891 closed 6 years ago

niranjanreddy891 commented 6 years ago

Hi, When I am converting las file to pcd file, then visualizing converted pcd file, I am unable to fit the output to the window properly. I tried using R in the keyboard. For zooming I used mouse and also F. A small dot is being displayed in the output. Please go through the output which I have attached. capture window. But it couldn't help me. Can you please solve the issue?

This is the file. It has both las file and the converted PCD file.

This is the code which I am trying to use.

import os
import time

import pytest
import numpy as np
import laspy

from pclpy import pcl
import pclpy

def test_las_rgb():
    pc = pclpy.io.las.read("E:/Lidar-practice/new-files/las14_type7_ALS_RIEGL_Q680i.las", "PointXYZ")
    assert pc.size() == 5025
    assert np.any(pc.r)

    writer = pcl.io.PCDWriter()

    writer.writeBinary("E:/Lidar-practice/new-files/qwerty.pcd", pc)

las14_type7_ALS_RIEGL_Q680i.zip

davidcaron commented 6 years ago

and where is the code you're using to view the cloud? are you using viewer.resetCamera()?

niranjanreddy891 commented 6 years ago

This is the code which I am using for visualizing pcd file.

from __future__ import print_function
import numpy as np
import pcl
import pcl.pcl_visualization

cloud = pcl.load_XYZRGB('E:/Lidar-practice/new-files/testing/las14_type7_ALS_RIEGL_Q680i.pcd')
visual = pcl.pcl_visualization.CloudViewing()

visual.ShowColorCloud(cloud, b'cloud')

visual.resetCamera()
flag = True
while flag:
    flag != visual.WasStopped()
end

Is there anyway to do the same thing using pclpy?

davidcaron commented 6 years ago

This should work:

from pclpy import pcl

path = r"C:\Users\David Caron\Downloads\las14_type7_ALS_RIEGL_Q680i.pcd"
reader = pcl.io.PCDReader()
pc = pcl.PointCloud.PointXYZRGBA()
reader.read(path, pc)

viewer = pcl.visualization.PCLVisualizer("cloud viewer")
viewer.addPointCloud(pc)
viewer.resetCamera()
while not viewer.wasStopped():
    viewer.spinOnce(100)

Refer to the PCL documentation on PCLVisualizer: http://pointclouds.org/documentation/tutorials/pcl_visualizer.php

The function calls should be very close, once you change the syntax a bit. If you're familiar with PCL, you shouldn't be lost.

I plan on adding some examples when I get the time.