1
votes

I am new to pcl and I am trying to visualize the code from the "Smoothing and normal estimation based on polynomial reconstruction" tutorial and I get this message when I debug it in VS2012 (I'm using pcl 1.7):

Debug Assertion Failed!

Program: C:\Windows\system32\MSVCP110D.dll File: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector Line: 1140

Expression: vector subscript out of range

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

and after I press "Retry" I get another one:

Debug Assertion Failed!

Program: ...tudio 2012\Projects\Tutorials\x64\Debug\pcl_surface_debug.dll File: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector Line: 1141

Expression: "Standard C++ Libraries Out of Range" && 0

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application) The program '[964] MLS.exe' has exited with code 3 (0x3).

then I debugged it line by line it stops at

mls.process(mls_points);

It also opens the "stdthrow.cpp" :

ifdef _DEBUG

_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line) { // report error and die if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, L"%s", message)==1) { ::_CrtDbgBreak(); } } _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const unsigned short *message, const unsigned short *file, unsigned int line) { // report error and die _Debug_message((wchar_t *) message, (wchar_t *) file, line); }

endif

and stops at

::_CrtDbgBreak();

Can someone explain the problem? Here is the code from pcl tutorial page:

#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/surface/mls.h>

int
main (int argc, char** argv)
{
  // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ> ());
  // Load bun0.pcd -- should be available with the PCL archive in test 
  pcl::io::loadPCDFile ("bun0.pcd", *cloud);

  // Create a KD-Tree
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);

  // Output has the PointNormal type in order to store the normals calculated by MLS
  pcl::PointCloud<pcl::PointNormal> mls_points;

  // Init object (second point type is for the normals, even if unused)
  pcl::MovingLeastSquares<pcl::PointXYZ, pcl::PointNormal> mls;
 
  mls.setComputeNormals (true);

  // Set parameters
  mls.setInputCloud (cloud);
  mls.setPolynomialFit (true);
  mls.setSearchMethod (tree);
  mls.setSearchRadius (0.03);

  // Reconstruct
  mls.process (mls_points);

  // Save output
  pcl::io::savePCDFile ("bun0-mls.pcd", mls_points);
}
1

1 Answers

0
votes

Your KdTree has no input, this will solve your problem: Add tree->setInputCloud (cloud); Afterpcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);