ziker
ziker

Reputation: 168

PCL library basic project returns abort has been called

I have succesfully linked my basic project containing only one ReadPc.cpp file obviously reading point cloud from file in Visual Studio 2010 After running exception is thrown and pop up window "R6010 abort() has been called" is shown When i was setting up my application i followed this tutorial

Here is my code

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

int
main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  std::cout << "bejzikl";
  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("kitchen.pcd", *cloud) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
    return (-1);
  }
  std::cout << "Loaded "
            << cloud->width * cloud->height
            << " data points from test_pcd.pcd with the following fields: "
            << std::endl;
  for (size_t i = 0; i < cloud->points.size (); ++i)
    std::cout << "    " << cloud->points[i].x
              << " "    << cloud->points[i].y
              << " "    << cloud->points[i].z << std::endl;

  return (0);
}

Problem line seems to be this one if (pcl::io::loadPCDFile ("kitchen.pcd", *cloud) == -1)

In debug mode Output says

First-chance exception at 0x7566812f in Meshes.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0030f36c..
Unhandled exception at 0x7566812f in Meshes.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0030f36c..
The program '[15424] Meshes.exe: Native' has exited with code -529697949 (0xe06d7363).

I appreciate any advice

Upvotes: 1

Views: 1266

Answers (3)

Tharun
Tharun

Reputation: 31

In my case, this is due to difference in the configuration of dependencies and the configuration of the project. Solved by changing the configuration to Release mode as my project dependencies are in release mode.

Upvotes: 2

elaheh r
elaheh r

Reputation: 484

If you are using the "kitchen.pcd" from the tutorials of the PCL site or github, then you should know that the points of this file is of type . you can open the ".pcd" file in wordpad and make sure of this. If so, change the types "PointXYZ" to "PointXYZRGB". Hope it would be helpful!

Upvotes: 0

nix
nix

Reputation: 1

I don't have experience with PCL library but std::bad_alloc, means that new failed. "Type of the exceptions thrown by the standard definitions of operator new and operator new[] when they fail to allocate the requested storage space." source: cplusplus

Maybe the file you are loading is too big, or if that load is requesting continues memory you don't have it available.

Also you can try to catch exception and see what ex.what() will suggest about exception cause.

Upvotes: 0

Related Questions