PointCloudLibrary / pcl

Point Cloud Library (PCL)

Home Page:https://pointclouds.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PCLVisualizer crash

AliAmin110 opened this issue · comments

I wrote this code

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>

int main(int argc, char** argv) {
    // Load point cloud data
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::PointXYZ point;
    point.x = 0;
    point.y = 0;
    point.z = 0;
    cloud->points.push_back(point);

    // Initialize visualization
    pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("Point Cloud Viewer"));

    // Set background color to black
    viewer->setBackgroundColor(0, 0, 0);

    // Add point cloud to viewer
    viewer->addPointCloud(cloud, "cloud");

    // Set camera position
    viewer->initCameraParameters();
    viewer->setCameraPosition(0, 0, 0, 0, 0, 1, 0, -1, 0);

    // Display viewer
    while (!viewer->wasStopped()) {
        viewer->spinOnce(100);
    }

    return 0;
}

project properties is this :
windows10
visual studio 2019
PCL 1.14.0
vtk-9.3
release x64
the program crashes at addPointCloud when i run it.
Untitled
what should i do?

@AliAmin110 Do you use CMake for building? If yes, please show your CMakeLists.txt. Also, how did you install PCL? Is it possible that there are other (older) PCL and/or VTK installations on your computer?

@mvieth thanks for replying.
no i didnt use CMake for building. only installed PCL-1.14.0-AllInOne-msvc2022-win64.exe and added below properties to visual studio
1
2

@AliAmin110 I can't reproduce the problem. Is it possible that you have multiple installations of PCL or VTK? Or did you previously have other versions of PCL or VTK installed, which may not be completely removed?

@mvieth no i checked it again and i have only PCL-1.14.0 installed on my pc. is there any way to check the PCL or VTK version?
there is a point , i can run a simple plot without any problem but visualizion has error. the function addPointCloud crashes!

PCL defines the preprocessor symbols PCL_VERSION and PCL_VERSION_PRETTY, VTK defines VTK_VERSION and VTK_VERSION_NUMBER (see also https://examples.vtk.org/site/Cxx/Utilities/CheckVTKVersion/)

I found an issue which seems to be related: #4278 although that concerned updatePointCloud and was already fixed.

@larshg Maybe there is an vertices->SetNumberOfCells(nr_points); missing here: https://github.com/PointCloudLibrary/pcl/blob/master/visualization/include/pcl/visualization/impl/pcl_visualizer.hpp#L366 ?

@mvieth I checked both versions and the result is this
PCL version

I can't reproduce it:
image

Works as expected.

@AliAmin110 can you please show the libraries you link into your application - maybe you added debug libraries of vtk in the release tab?

@larshg Thanks a lot , the point was that. I was added debug libs into release properties.
Thanks again

@AliAmin110 Great - then we can close the issue 👍