Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Øystein Skotheim

I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).

I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.

 

In order to generate the stack trace, I built PCL and VTK in release mode with debug info.

 

The program crashes with:

  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

 

Stack trace:

>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++

               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++

               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++

               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++

               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++

               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++

               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++

               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++

               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++

               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++

               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C

               kernel32.dll!0000000076f5652d()             Unknown

               ntdll.dll!000000007718c541()      Unknown

 

This is the code that crashes:

//----------------------------------------------------------------------------

// Copy the tuple value into a user-provided array.

template <class T>

void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)

{

  T* t = this->Array + this->NumberOfComponents*i;

  for(int j=0; j < this->NumberOfComponents; ++j)

    {

    tuple[j] = static_cast<double>(t[j]);

    }

}

 

The program that reproduces the crash is included below. Can someone help me to debug this further?

 

#include <iostream>

#include <pcl/common/common_headers.h>

#include <pcl/visualization/pcl_visualizer.h>

 

pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()

{

       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);

       for (float z(-1.0); z <= 1.0; z += 0.05)

       {

             for (float angle(0.0); angle <= 360.0; angle += 5.0)

             {

                    pcl::PointXYZ basic_point;

                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));

                    basic_point.y = sinf (pcl::deg2rad(angle));

                    basic_point.z = z;

                    basic_cloud_ptr->points.push_back(basic_point);

             }

       }

       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();

       basic_cloud_ptr->height = 1;

       return basic_cloud_ptr;

}

 

int main (int argc, char** argv)

{

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();

 

  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));

  viewer->setBackgroundColor (0, 0, 0);

 

  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");

 

  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();

  vtkPropCollection* props = ren->GetViewProps();

 

  props->InitTraversal();

  for(int i = 0; i < props->GetNumberOfItems(); i++)

  {

       std::cout << "vtkProp #" << i << std::endl;

       vtkProp* prop = props->GetNextProp();

       prop->Print(std::cout);

  }

}

 

 

Regards,

---

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

SINTEF ICT [http://www.sintef.com/omd]

 

Fra: [hidden email] [mailto:[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

 

Hi,

 

I try to run the PCLVisualizer example from the documentation:

using Visual Studio 2012 on Windows 7

 

I managed to build all mandatory dependencies

boost 1.53.0

VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0

flann 1.8.4

eigen 3.1.2

 

and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.

 

I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:


Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.

 

To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.

 

This is the callstack:

            ntdll.dll!774915de()   Unknown

            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]

>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++

            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++

            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++

            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++

            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++

            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++

            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++

            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++

            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++

            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++

            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++

            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++

            user32.dll!762762fa() Unknown

            user32.dll!76276d3a()            Unknown

            user32.dll!76276ce9()            Unknown

            user32.dll!762777c4()            Unknown

            user32.dll!76277bca()            Unknown

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++

            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++

            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C

            kernel32.dll!76c433aa()         Unknown

            ntdll.dll!774a9ef2()    Unknown

            ntdll.dll!774a9ec5()    Unknown

 

It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:

          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Øystein Skotheim
By the way, this is my setup:

VTK 5.10
Boost 1.53
Eigen 3.05
Qt 4.8.5
OpenNI 1.5.4
Qhull 2012.1
PCL from trunk.

All of the above are compiled with VS2012 Win64 Release.

I have included installers with pre-compiled binaries for all the dependencies (VS2012, x64) in the link below, in case it can help you assisting me with the debugging:
http://sdrv.ms/14SmW9R

Regards
---

Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
SINTEF ICT [http://www.sintef.com/omd]

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Radu B. Rusu
Administrator
In reply to this post by Øystein Skotheim
<base href="x-msg://8/">Just out of curiosity, does that code work in VS 2010? Also, was VTK 5.10 compiled for VS 2012, or did you use our binary installers?

Thanks,
Radu.

On Sep 15, 2013, at 5:36 AM, Øystein Skotheim <[hidden email]> wrote:

I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).
I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.
 
In order to generate the stack trace, I built PCL and VTK in release mode with debug info.
 
The program crashes with:
  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
 
Stack trace:
>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++
               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++
               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++
               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++
               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++
               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++
               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++
               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++
               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++
               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++
               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C
               kernel32.dll!0000000076f5652d()             Unknown
               ntdll.dll!000000007718c541()      Unknown
 
This is the code that crashes:
//----------------------------------------------------------------------------
// Copy the tuple value into a user-provided array.
template <class T>
void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
{
  T* t = this->Array + this->NumberOfComponents*i;
  for(int j=0; j < this->NumberOfComponents; ++j)
    {
    tuple[j] = static_cast<double>(t[j]);
    }
}
 
The program that reproduces the crash is included below. Can someone help me to debug this further?
 
#include <iostream>
#include <pcl/common/common_headers.h>
#include <pcl/visualization/pcl_visualizer.h>
 
pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()
{
       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);
       for (float z(-1.0); z <= 1.0; z += 0.05)
       {
             for (float angle(0.0); angle <= 360.0; angle += 5.0)
             {
                    pcl::PointXYZ basic_point;
                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));
                    basic_point.y = sinf (pcl::deg2rad(angle));
                    basic_point.z = z;
                    basic_cloud_ptr->points.push_back(basic_point);
             }
       }
       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();
       basic_cloud_ptr->height = 1;
       return basic_cloud_ptr;
}
 
int main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();
 
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer->setBackgroundColor (0, 0, 0);
 
  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
 
  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();
  vtkPropCollection* props = ren->GetViewProps();
 
  props->InitTraversal();
  for(int i = 0; i < props->GetNumberOfItems(); i++)
  {
       std::cout << "vtkProp #" << i << std::endl;
       vtkProp* prop = props->GetNextProp();
       prop->Print(std::cout);
  }
}
 
 
Regards,
---
Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
 
Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem
 
Hi,
 
I try to run the PCLVisualizer example from the documentation:
using Visual Studio 2012 on Windows 7
 
I managed to build all mandatory dependencies
boost 1.53.0
VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0
flann 1.8.4
eigen 3.1.2
 
and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.
 
I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:

Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.
 
To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.
 
This is the callstack:
            ntdll.dll!774915de()   Unknown
            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++
            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++
            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++
            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++
            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++
            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++
            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++
            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++
            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++
            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++
            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++
            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++
            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++
            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++
            user32.dll!762762fa() Unknown
            user32.dll!76276d3a()            Unknown
            user32.dll!76276ce9()            Unknown
            user32.dll!762777c4()            Unknown
            user32.dll!76277bca()            Unknown
            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++
            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++
            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++
            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C
            kernel32.dll!76c433aa()         Unknown
            ntdll.dll!774a9ef2()    Unknown
            ntdll.dll!774a9ec5()    Unknown
 
It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:
          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Øystein Skotheim
In reply to this post by Øystein Skotheim
<base href="x-msg://8/">

Hi Radu. The code works in VS 2010. I have tested it both with the VTK 5.8 installer from pointclouds.org and with VTK 5.10 and it runs successfully (even if I add viewer->spin() in the end to actually visualize the point cloud).

 

For VS2012, I have built all the dependencies manually from source, including VTK 5.10. I have also made my own installers (by making the INSTALL target that CMake generates, zipping the resulting libraries/include files in C:\Program Files and converting the ZIP files to self-extracting EXEs with NSIS). These installers are available here: http://sdrv.ms/14SmW9R

 

Regards,

---

 

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

SINTEF ICT [http://www.sintef.com/omd]

 

 

 

Just out of curiosity, does that code work in VS 2010? Also, was VTK 5.10 compiled for VS 2012, or did you use our binary installers?

 

Thanks,

Radu.

 

On Sep 15, 2013, at 5:36 AM, Øystein Skotheim <[hidden email]> wrote:



I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).

I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.

 

In order to generate the stack trace, I built PCL and VTK in release mode with debug info.

 

The program crashes with:

  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

 

Stack trace:

>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++

               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++

               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++

               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++

               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++

               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++

               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++

               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++

               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++

               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++

               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C

               kernel32.dll!0000000076f5652d()             Unknown

               ntdll.dll!000000007718c541()      Unknown

 

This is the code that crashes:

//----------------------------------------------------------------------------

// Copy the tuple value into a user-provided array.

template <class T>

void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)

{

  T* t = this->Array + this->NumberOfComponents*i;

  for(int j=0; j < this->NumberOfComponents; ++j)

    {

    tuple[j] = static_cast<double>(t[j]);

    }

}

 

The program that reproduces the crash is included below. Can someone help me to debug this further?

 

#include <iostream>

#include <pcl/common/common_headers.h>

#include <pcl/visualization/pcl_visualizer.h>

 

pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()

{

       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);

       for (float z(-1.0); z <= 1.0; z += 0.05)

       {

             for (float angle(0.0); angle <= 360.0; angle += 5.0)

             {

                    pcl::PointXYZ basic_point;

                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));

                    basic_point.y = sinf (pcl::deg2rad(angle));

                    basic_point.z = z;

                    basic_cloud_ptr->points.push_back(basic_point);

             }

       }

       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();

       basic_cloud_ptr->height = 1;

       return basic_cloud_ptr;

}

 

int main (int argc, char** argv)

{

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();

 

  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));

  viewer->setBackgroundColor (0, 0, 0);

 

  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");

 

  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();

  vtkPropCollection* props = ren->GetViewProps();

 

  props->InitTraversal();

  for(int i = 0; i < props->GetNumberOfItems(); i++)

  {

       std::cout << "vtkProp #" << i << std::endl;

       vtkProp* prop = props->GetNextProp();

       prop->Print(std::cout);

  }

}

 

 

Regards,

---

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

 

Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

 

Hi,

 

I try to run the PCLVisualizer example from the documentation:

using Visual Studio 2012 on Windows 7

 

I managed to build all mandatory dependencies

boost 1.53.0

VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0

flann 1.8.4

eigen 3.1.2

 

and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.

 

I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:


Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.

 

To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.

 

This is the callstack:

            ntdll.dll!774915de()   Unknown

            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]

>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++

            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++

            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++

            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++

            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++

            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++

            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++

            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++

            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++

            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++

            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++

            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++

            user32.dll!762762fa() Unknown

            user32.dll!76276d3a()            Unknown

            user32.dll!76276ce9()            Unknown

            user32.dll!762777c4()            Unknown

            user32.dll!76277bca()            Unknown

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++

            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++

            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C

            kernel32.dll!76c433aa()         Unknown

            ntdll.dll!774a9ef2()    Unknown

            ntdll.dll!774a9ec5()    Unknown

 

It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:

          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Radu B. Rusu
Administrator
<base href="x-msg://8/">
On Sep 15, 2013, at 11:19 AM, Øystein Skotheim <[hidden email]> wrote:

Hi Radu. The code works in VS 2010. I have tested it both with the VTK 5.8 installer from pointclouds.org and with VTK 5.10 and it runs successfully (even if I add viewer->spin() in the end to actually visualize the point cloud).

I see. So the problem might be somewhere else. I wonder if we could debug why would that line crash - is this->Array null?

 
For VS2012, I have built all the dependencies manually from source, including VTK 5.10. I have also made my own installers (by making the INSTALL target that CMake generates, zipping the resulting libraries/include files in C:\Program Files and converting the ZIP files to self-extracting EXEs with NSIS). These installers are available here: http://sdrv.ms/14SmW9R

That's actually a great contribution! Would you mind hosting these under https://sourceforge.net/projects/pointclouds/files/dependencies/ ? Other folks will definitely appreciate this.

Best,
Radu.


 
Regards,
---
 
Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
 
 
 
Just out of curiosity, does that code work in VS 2010? Also, was VTK 5.10 compiled for VS 2012, or did you use our binary installers?
 
Thanks,
Radu.
 
On Sep 15, 2013, at 5:36 AM, Øystein Skotheim <[hidden email]> wrote:


I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).
I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.
 
In order to generate the stack trace, I built PCL and VTK in release mode with debug info.
 
The program crashes with:
  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
 
Stack trace:
>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++
               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++
               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++
               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++
               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++
               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++
               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++
               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++
               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++
               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++
               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C
               kernel32.dll!0000000076f5652d()             Unknown
               ntdll.dll!000000007718c541()      Unknown
 
This is the code that crashes:
//----------------------------------------------------------------------------
// Copy the tuple value into a user-provided array.
template <class T>
void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
{
  T* t = this->Array + this->NumberOfComponents*i;
  for(int j=0; j < this->NumberOfComponents; ++j)
    {
    tuple[j] = static_cast<double>(t[j]);
    }
}
 
The program that reproduces the crash is included below. Can someone help me to debug this further?
 
#include <iostream>
#include <pcl/common/common_headers.h>
#include <pcl/visualization/pcl_visualizer.h>
 
pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()
{
       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);
       for (float z(-1.0); z <= 1.0; z += 0.05)
       {
             for (float angle(0.0); angle <= 360.0; angle += 5.0)
             {
                    pcl::PointXYZ basic_point;
                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));
                    basic_point.y = sinf (pcl::deg2rad(angle));
                    basic_point.z = z;
                    basic_cloud_ptr->points.push_back(basic_point);
             }
       }
       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();
       basic_cloud_ptr->height = 1;
       return basic_cloud_ptr;
}
 
int main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();
 
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer->setBackgroundColor (0, 0, 0);
 
  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
 
  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();
  vtkPropCollection* props = ren->GetViewProps();
 
  props->InitTraversal();
  for(int i = 0; i < props->GetNumberOfItems(); i++)
  {
       std::cout << "vtkProp #" << i << std::endl;
       vtkProp* prop = props->GetNextProp();
       prop->Print(std::cout);
  }
}
 
 
Regards,
---
Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
 
Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem
 
Hi,
 
I try to run the PCLVisualizer example from the documentation:
using Visual Studio 2012 on Windows 7
 
I managed to build all mandatory dependencies
boost 1.53.0
VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0
flann 1.8.4
eigen 3.1.2
 
and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.
 
I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:

Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.
 
To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.
 
This is the callstack:
            ntdll.dll!774915de()   Unknown
            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++
            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++
            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++
            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++
            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++
            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++
            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++
            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++
            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++
            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++
            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++
            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++
            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++
            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++
            user32.dll!762762fa() Unknown
            user32.dll!76276d3a()            Unknown
            user32.dll!76276ce9()            Unknown
            user32.dll!762777c4()            Unknown
            user32.dll!76277bca()            Unknown
            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++
            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++
            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++
            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C
            kernel32.dll!76c433aa()         Unknown
            ntdll.dll!774a9ef2()    Unknown
            ntdll.dll!774a9ec5()    Unknown
 
It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:
          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13
 

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Øystein Skotheim
In reply to this post by Øystein Skotheim
<base href="x-msg://8/">

>> Hi Radu. The code works in VS 2010. I have tested it both with the VTK 5.8 installer from pointclouds.org and with VTK 5.10 and it runs successfully (even if I add viewer->spin() in the end to actually visualize the point cloud).

> I see. So the problem might be somewhere else. I wonder if we could debug why would that line crash - is this->Array null?

 

It is a little bit difficult to debug, because the error only appears in release mode. But I have copied some of the code that crashed from the GetBounds() function in vtkPolyData.cxx into my test program, and I discovered something somewhat disturbing:

 

See the code below:

 

       vtkCellArray* cella[4];

       double Bounds[6];

 

       vtkIdType *pts = 0;

       vtkIdType npts = 0;

 

       Bounds[0] = Bounds[2] = Bounds[4] =  VTK_DOUBLE_MAX;

       Bounds[1] = Bounds[3] = Bounds[5] = -VTK_DOUBLE_MAX;

 

       cella[0] = pd->GetVerts();

       cella[1] = pd->GetLines();

       cella[2] = pd->GetPolys();

       cella[3] = pd->GetStrips();

 

       // Iterate over cells's points

       for (int t = 0; t < 4; t++)

       {

             int c=0;

             for (cella[t]->InitTraversal(); cella[t]->GetNextCell(npts,pts); c++)

             {

                    std::cout << "Cell " << c << " has " << npts << " data points " << std::endl;

                    for (i = 0;  i < npts; i++)

                    {

                           pd->GetPoints()->GetPoint( pts[i], x );

                           Bounds[0] = (x[0] < Bounds[0] ? x[0] : Bounds[0]);

                           Bounds[1] = (x[0] > Bounds[1] ? x[0] : Bounds[1]);

                           Bounds[2] = (x[1] < Bounds[2] ? x[1] : Bounds[2]);

                           Bounds[3] = (x[1] > Bounds[3] ? x[1] : Bounds[3]);

                           Bounds[4] = (x[2] < Bounds[4] ? x[2] : Bounds[4]);

                           Bounds[5] = (x[2] > Bounds[5] ? x[2] : Bounds[5]);

                    }

             }

       }

 

In this code, pd points to the vtkPolyData class that holds the point cloud (generated as shown in my previous message).

When I run this code, I see the following on the screen:

 

Cell 0 has 1 data points

Cell 1 has 1 data points

Cell 2 has 1 data points

Cell 3 has 3 data points

Cell 4 has 5 data points

Cell 5 has 1 data points

Cell 6 has 9 data points

Cell 7 has 1 data points

Cell 8 has 15 data points

Cell 9 has 23 data points

Cell 10 has 35 data points

Cell 11 has 53 data points

Cell 12 has 1 data points

Cell 13 has 81 data points

Cell 14 has 1 data points

Cell 15 has 123 data points

Cell 16 has 185 data points

Cell 17 has 1 data points

Cell 18 has 279 data points

<Crash>

 

It seems like the GetNextCell(vtkIdType &npts, vtkIdType *& pts) returns cells with a large number of vertices (Isn’t the vertices array supposed to consist of cells with only 1 point each?)

I think it crashes in the inner for loop, because it tries to go beyond the actual contents of the pts array. I’ll look more into it tomorrow.

>>For VS2012, I have built all the dependencies manually from source, including VTK 5.10. I have also made my own installers (by making the INSTALL target that CMake generates, zipping the resulting >>libraries/include files in C:\Program Files and converting the ZIP files to self-extracting EXEs with NSIS). These installers are available here: http://sdrv.ms/14SmW9R

 

>That's actually a great contribution! Would you mind hosting these under https://sourceforge.net/projects/pointclouds/files/dependencies/ ? Other folks will definitely appreciate this.

 

I guess I could do that. Do I have access there? PS! For most of the libraries I have only included binaries in release version, do you need debug also? And the boost installer is very large (300MB) because it includes all variants of the Boost libraries (static/dynamic, debug/release, static/dynamic runtime) – I guess we don’t need all of them? Also Qt (debug+release) is very large (around 275MB).

 

Regards,

---

 

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

 

 

 

Just out of curiosity, does that code work in VS 2010? Also, was VTK 5.10 compiled for VS 2012, or did you use our binary installers?

 

Thanks,

Radu.

 

On Sep 15, 2013, at 5:36 AM, Øystein Skotheim <[hidden email]> wrote:




I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).

I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.

 

In order to generate the stack trace, I built PCL and VTK in release mode with debug info.

 

The program crashes with:

  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

 

Stack trace:

>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++

               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++

               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++

               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++

               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++

               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++

               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++

               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++

               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++

               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++

               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C

               kernel32.dll!0000000076f5652d()             Unknown

               ntdll.dll!000000007718c541()      Unknown

 

This is the code that crashes:

//----------------------------------------------------------------------------

// Copy the tuple value into a user-provided array.

template <class T>

void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)

{

  T* t = this->Array + this->NumberOfComponents*i;

  for(int j=0; j < this->NumberOfComponents; ++j)

    {

    tuple[j] = static_cast<double>(t[j]);

    }

}

 

The program that reproduces the crash is included below. Can someone help me to debug this further?

 

#include <iostream>

#include <pcl/common/common_headers.h>

#include <pcl/visualization/pcl_visualizer.h>

 

pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()

{

       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);

       for (float z(-1.0); z <= 1.0; z += 0.05)

       {

             for (float angle(0.0); angle <= 360.0; angle += 5.0)

             {

                    pcl::PointXYZ basic_point;

                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));

                    basic_point.y = sinf (pcl::deg2rad(angle));

                    basic_point.z = z;

                    basic_cloud_ptr->points.push_back(basic_point);

             }

       }

       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();

       basic_cloud_ptr->height = 1;

       return basic_cloud_ptr;

}

 

int main (int argc, char** argv)

{

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();

 

  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));

  viewer->setBackgroundColor (0, 0, 0);

 

  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");

 

  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();

  vtkPropCollection* props = ren->GetViewProps();

 

  props->InitTraversal();

  for(int i = 0; i < props->GetNumberOfItems(); i++)

  {

       std::cout << "vtkProp #" << i << std::endl;

       vtkProp* prop = props->GetNextProp();

       prop->Print(std::cout);

  }

}

 

 

Regards,

---

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

 

Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

 

Hi,

 

I try to run the PCLVisualizer example from the documentation:

using Visual Studio 2012 on Windows 7

 

I managed to build all mandatory dependencies

boost 1.53.0

VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0

flann 1.8.4

eigen 3.1.2

 

and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.

 

I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:


Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.

 

To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.

 

This is the callstack:

            ntdll.dll!774915de()   Unknown

            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]

>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++

            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++

            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++

            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++

            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++

            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++

            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++

            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++

            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++

            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++

            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++

            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++

            user32.dll!762762fa() Unknown

            user32.dll!76276d3a()            Unknown

            user32.dll!76276ce9()            Unknown

            user32.dll!762777c4()            Unknown

            user32.dll!76277bca()            Unknown

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++

            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++

            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C

            kernel32.dll!76c433aa()         Unknown

            ntdll.dll!774a9ef2()    Unknown

            ntdll.dll!774a9ec5()    Unknown

 

It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:

          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6667 - Release Date: 09/15/13


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Øystein Skotheim
In reply to this post by Øystein Skotheim
<base href="x-msg://8/">

I think I have found the cause of this problem. In release mode, the std::fill_n command in pcl_visualizer.cpp on line 3749 appears to have no effect (perhaps it gets optimized away??!)

See the below diff for the fix I applied. pcl_viewer and other examples utilizing pcl_visualization no longer crash in release mode.

 

diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visual

index 23c78e1..3059c8d 100644

--- a/visualization/src/pcl_visualizer.cpp

+++ b/visualization/src/pcl_visualizer.cpp

@@ -3746,11 +3746,13 @@ pcl::visualization::PCLVisualizer::updateCells (vtkSmart

       cells->SetNumberOfComponents (2);

       cells->SetNumberOfTuples (nr_points);

       vtkIdType *cell = cells->GetPointer (0);

-      // Fill it with 1s

-      std::fill_n (cell, nr_points * 2, 1);

-      cell++;

+

       for (vtkIdType i = 0; i < nr_points; ++i, cell += 2)

-        *cell = i;

+         {

+        *cell = 1;

+           *(cell+1) = i;

+         }

+

       // Save the results in initcells

       initcells = vtkSmartPointer<vtkIdTypeArray>::New ();

       initcells->DeepCopy (cells);

 

Regards,

---

 

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

SINTEF ICT [http://www.sintef.com/omd]

 

Fra: [hidden email] [mailto:[hidden email]] På vegne av Øystein Skotheim
Sendt: 15. september 2013 23:41
Til: Point Cloud Library (PCL) users
Emne: Re: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

 

>> Hi Radu. The code works in VS 2010. I have tested it both with the VTK 5.8 installer from pointclouds.org and with VTK 5.10 and it runs successfully (even if I add viewer->spin() in the end to actually visualize the point cloud).

> I see. So the problem might be somewhere else. I wonder if we could debug why would that line crash - is this->Array null?

 

It is a little bit difficult to debug, because the error only appears in release mode. But I have copied some of the code that crashed from the GetBounds() function in vtkPolyData.cxx into my test program, and I discovered something somewhat disturbing:

 

See the code below:

 

       vtkCellArray* cella[4];

       double Bounds[6];

 

       vtkIdType *pts = 0;

       vtkIdType npts = 0;

 

       Bounds[0] = Bounds[2] = Bounds[4] =  VTK_DOUBLE_MAX;

       Bounds[1] = Bounds[3] = Bounds[5] = -VTK_DOUBLE_MAX;

 

       cella[0] = pd->GetVerts();

       cella[1] = pd->GetLines();

       cella[2] = pd->GetPolys();

       cella[3] = pd->GetStrips();

 

       // Iterate over cells's points

       for (int t = 0; t < 4; t++)

       {

             int c=0;

             for (cella[t]->InitTraversal(); cella[t]->GetNextCell(npts,pts); c++)

             {

                    std::cout << "Cell " << c << " has " << npts << " data points " << std::endl;

                    for (i = 0;  i < npts; i++)

                    {

                           pd->GetPoints()->GetPoint( pts[i], x );

                           Bounds[0] = (x[0] < Bounds[0] ? x[0] : Bounds[0]);

                           Bounds[1] = (x[0] > Bounds[1] ? x[0] : Bounds[1]);

                           Bounds[2] = (x[1] < Bounds[2] ? x[1] : Bounds[2]);

                           Bounds[3] = (x[1] > Bounds[3] ? x[1] : Bounds[3]);

                           Bounds[4] = (x[2] < Bounds[4] ? x[2] : Bounds[4]);

                           Bounds[5] = (x[2] > Bounds[5] ? x[2] : Bounds[5]);

                    }

             }

       }

 

In this code, pd points to the vtkPolyData class that holds the point cloud (generated as shown in my previous message).

When I run this code, I see the following on the screen:

 

Cell 0 has 1 data points

Cell 1 has 1 data points

Cell 2 has 1 data points

Cell 3 has 3 data points

Cell 4 has 5 data points

Cell 5 has 1 data points

Cell 6 has 9 data points

Cell 7 has 1 data points

Cell 8 has 15 data points

Cell 9 has 23 data points

Cell 10 has 35 data points

Cell 11 has 53 data points

Cell 12 has 1 data points

Cell 13 has 81 data points

Cell 14 has 1 data points

Cell 15 has 123 data points

Cell 16 has 185 data points

Cell 17 has 1 data points

Cell 18 has 279 data points

<Crash>

 

It seems like the GetNextCell(vtkIdType &npts, vtkIdType *& pts) returns cells with a large number of vertices (Isn’t the vertices array supposed to consist of cells with only 1 point each?)

I think it crashes in the inner for loop, because it tries to go beyond the actual contents of the pts array. I’ll look more into it tomorrow.

>>For VS2012, I have built all the dependencies manually from source, including VTK 5.10. I have also made my own installers (by making the INSTALL target that CMake generates, zipping the resulting >>libraries/include files in C:\Program Files and converting the ZIP files to self-extracting EXEs with NSIS). These installers are available here: http://sdrv.ms/14SmW9R

 

>That's actually a great contribution! Would you mind hosting these under https://sourceforge.net/projects/pointclouds/files/dependencies/ ? Other folks will definitely appreciate this.

 

I guess I could do that. Do I have access there? PS! For most of the libraries I have only included binaries in release version, do you need debug also? And the boost installer is very large (300MB) because it includes all variants of the Boost libraries (static/dynamic, debug/release, static/dynamic runtime) – I guess we don’t need all of them? Also Qt (debug+release) is very large (around 275MB).

 

Regards,

---

 

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

 

 

 

Just out of curiosity, does that code work in VS 2010? Also, was VTK 5.10 compiled for VS 2012, or did you use our binary installers?

 

Thanks,

Radu.

 

On Sep 15, 2013, at 5:36 AM, Øystein Skotheim <[hidden email]> wrote:





I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).

I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.

 

In order to generate the stack trace, I built PCL and VTK in release mode with debug info.

 

The program crashes with:

  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

 

Stack trace:

>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++

               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++

               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++

               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++

               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++

               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++

               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++

               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++

               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++

               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++

               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C

               kernel32.dll!0000000076f5652d()             Unknown

               ntdll.dll!000000007718c541()      Unknown

 

This is the code that crashes:

//----------------------------------------------------------------------------

// Copy the tuple value into a user-provided array.

template <class T>

void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)

{

  T* t = this->Array + this->NumberOfComponents*i;

  for(int j=0; j < this->NumberOfComponents; ++j)

    {

    tuple[j] = static_cast<double>(t[j]);

    }

}

 

The program that reproduces the crash is included below. Can someone help me to debug this further?

 

#include <iostream>

#include <pcl/common/common_headers.h>

#include <pcl/visualization/pcl_visualizer.h>

 

pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()

{

       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);

       for (float z(-1.0); z <= 1.0; z += 0.05)

       {

             for (float angle(0.0); angle <= 360.0; angle += 5.0)

             {

                    pcl::PointXYZ basic_point;

                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));

                    basic_point.y = sinf (pcl::deg2rad(angle));

                    basic_point.z = z;

                    basic_cloud_ptr->points.push_back(basic_point);

             }

       }

       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();

       basic_cloud_ptr->height = 1;

       return basic_cloud_ptr;

}

 

int main (int argc, char** argv)

{

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();

 

  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));

  viewer->setBackgroundColor (0, 0, 0);

 

  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");

 

  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();

  vtkPropCollection* props = ren->GetViewProps();

 

  props->InitTraversal();

  for(int i = 0; i < props->GetNumberOfItems(); i++)

  {

       std::cout << "vtkProp #" << i << std::endl;

       vtkProp* prop = props->GetNextProp();

       prop->Print(std::cout);

  }

}

 

 

Regards,

---

Øystein Skotheim, Senior Researcher

Optical Measurement Systems and Data Analysis

 

Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

 

Hi,

 

I try to run the PCLVisualizer example from the documentation:

using Visual Studio 2012 on Windows 7

 

I managed to build all mandatory dependencies

boost 1.53.0

VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0

flann 1.8.4

eigen 3.1.2

 

and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.

 

I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:


Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.

 

To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.

 

This is the callstack:

            ntdll.dll!774915de()   Unknown

            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]

>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++

            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++

            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++

            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++

            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++

            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++

            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++

            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++

            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++

            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++

            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++

            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++

            user32.dll!762762fa() Unknown

            user32.dll!76276d3a()            Unknown

            user32.dll!76276ce9()            Unknown

            user32.dll!762777c4()            Unknown

            user32.dll!76277bca()            Unknown

            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++

            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++

            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++

            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C

            kernel32.dll!76c433aa()         Unknown

            ntdll.dll!774a9ef2()    Unknown

            ntdll.dll!774a9ec5()    Unknown

 

It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:

          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

 


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6667 - Release Date: 09/15/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6667 - Release Date: 09/15/13


No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6671 - Release Date: 09/16/13


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem

Radu B. Rusu
Administrator
<base href="x-msg://8/">Awesome, thanks! That's a great find!

Can you please submit a pull request on GitHub? We'll get this integrated into master asap.

Best,
Radu.

On Sep 16, 2013, at 11:11 AM, Øystein Skotheim <[hidden email]> wrote:

I think I have found the cause of this problem. In release mode, the std::fill_n command in pcl_visualizer.cpp on line 3749 appears to have no effect (perhaps it gets optimized away??!)
See the below diff for the fix I applied. pcl_viewer and other examples utilizing pcl_visualization no longer crash in release mode.
 
diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visual
index 23c78e1..3059c8d 100644
--- a/visualization/src/pcl_visualizer.cpp
+++ b/visualization/src/pcl_visualizer.cpp
@@ -3746,11 +3746,13 @@ pcl::visualization::PCLVisualizer::updateCells (vtkSmart
       cells->SetNumberOfComponents (2);
       cells->SetNumberOfTuples (nr_points);
       vtkIdType *cell = cells->GetPointer (0);
-      // Fill it with 1s
-      std::fill_n (cell, nr_points * 2, 1);
-      cell++;
+
       for (vtkIdType i = 0; i < nr_points; ++i, cell += 2)
-        *cell = i;
+         {
+        *cell = 1;
+           *(cell+1) = i;
+         }
+
       // Save the results in initcells
       initcells = vtkSmartPointer<vtkIdTypeArray>::New ();
       initcells->DeepCopy (cells);
 
Regards,
---
 
Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
 
Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Øystein Skotheim
Sendt: 15. september 2013 23:41
Til: Point Cloud Library (PCL) users
Emne: Re: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem
 
>> Hi Radu. The code works in VS 2010. I have tested it both with the VTK 5.8 installer from pointclouds.org and with VTK 5.10 and it runs successfully (even if I add viewer->spin() in the end to actually visualize the point cloud).
> I see. So the problem might be somewhere else. I wonder if we could debug why would that line crash - is this->Array null?
 
It is a little bit difficult to debug, because the error only appears in release mode. But I have copied some of the code that crashed from the GetBounds() function in vtkPolyData.cxx into my test program, and I discovered something somewhat disturbing:
 
See the code below:
 
       vtkCellArray* cella[4];
       double Bounds[6];
 
       vtkIdType *pts = 0;
       vtkIdType npts = 0;
 
       Bounds[0] = Bounds[2] = Bounds[4] =  VTK_DOUBLE_MAX;
       Bounds[1] = Bounds[3] = Bounds[5] = -VTK_DOUBLE_MAX;
 
       cella[0] = pd->GetVerts();
       cella[1] = pd->GetLines();
       cella[2] = pd->GetPolys();
       cella[3] = pd->GetStrips();
 
       // Iterate over cells's points
       for (int t = 0; t < 4; t++)
       {
             int c=0;
             for (cella[t]->InitTraversal(); cella[t]->GetNextCell(npts,pts); c++)
             {
                    std::cout << "Cell " << c << " has " << npts << " data points " << std::endl;
                    for (i = 0;  i < npts; i++)
                    {
                           pd->GetPoints()->GetPoint( pts[i], x );
                           Bounds[0] = (x[0] < Bounds[0] ? x[0] : Bounds[0]);
                           Bounds[1] = (x[0] > Bounds[1] ? x[0] : Bounds[1]);
                           Bounds[2] = (x[1] < Bounds[2] ? x[1] : Bounds[2]);
                           Bounds[3] = (x[1] > Bounds[3] ? x[1] : Bounds[3]);
                           Bounds[4] = (x[2] < Bounds[4] ? x[2] : Bounds[4]);
                           Bounds[5] = (x[2] > Bounds[5] ? x[2] : Bounds[5]);
                    }
             }
       }
 
In this code, pd points to the vtkPolyData class that holds the point cloud (generated as shown in my previous message).
When I run this code, I see the following on the screen:
 
Cell 0 has 1 data points
Cell 1 has 1 data points
Cell 2 has 1 data points
Cell 3 has 3 data points
Cell 4 has 5 data points
Cell 5 has 1 data points
Cell 6 has 9 data points
Cell 7 has 1 data points
Cell 8 has 15 data points
Cell 9 has 23 data points
Cell 10 has 35 data points
Cell 11 has 53 data points
Cell 12 has 1 data points
Cell 13 has 81 data points
Cell 14 has 1 data points
Cell 15 has 123 data points
Cell 16 has 185 data points
Cell 17 has 1 data points
Cell 18 has 279 data points
<Crash>
 
It seems like the GetNextCell(vtkIdType &npts, vtkIdType *& pts) returns cells with a large number of vertices (Isn’t the vertices array supposed to consist of cells with only 1 point each?)
I think it crashes in the inner for loop, because it tries to go beyond the actual contents of the pts array. I’ll look more into it tomorrow.
>>For VS2012, I have built all the dependencies manually from source, including VTK 5.10. I have also made my own installers (by making the INSTALL target that CMake generates, zipping the resulting >>libraries/include files in C:\Program Files and converting the ZIP files to self-extracting EXEs with NSIS). These installers are available here: http://sdrv.ms/14SmW9R
 
>That's actually a great contribution! Would you mind hosting these under https://sourceforge.net/projects/pointclouds/files/dependencies/ ? Other folks will definitely appreciate this.
 
I guess I could do that. Do I have access there? PS! For most of the libraries I have only included binaries in release version, do you need debug also? And the boost installer is very large (300MB) because it includes all variants of the Boost libraries (static/dynamic, debug/release, static/dynamic runtime) – I guess we don’t need all of them? Also Qt (debug+release) is very large (around 275MB).
 
Regards,
---
 
Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
 
 
 
Just out of curiosity, does that code work in VS 2010? Also, was VTK 5.10 compiled for VS 2012, or did you use our binary installers?
 
Thanks,
Radu.
 
On Sep 15, 2013, at 5:36 AM, Øystein Skotheim <[hidden email]> wrote:




I  have also compiled PCL and all its dependencies in 64-bit for Visual Studio 2012, and I experience the same problems with crashes in PCLVisualizer in release mode (it does not crash in debug mode).
I have included a short program that reproduces the crash below. This does not even fire up the visualizer – the crash apparently happens in the prop->Print() call when trying to calculate the bounds for the point cloud.
 
In order to generate the stack trace, I built PCL and VTK in release mode with debug info.
 
The program crashes with:
  Unhandled exception at 0x000007FEE31905A0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
 
Stack trace:
>             pcl_visualization.dll!vtkDataArrayTemplate<float>::GetTuple(__int64 i, double * tuple) Line 612           C++
               pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636   C++
               pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176             C++
               pcl_visualization.dll!vtkMapper::GetBounds() Line 107                C++
               pcl_visualization.dll!vtkActor::GetBounds() Line 318     C++
               pcl_visualization.dll!vtkProp3D::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 636               C++
               pcl_visualization.dll!vtkActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 447               C++
               pcl_visualization.dll!vtkLODActor::PrintSelf(std::basic_ostream<char,std::char_traits<char> > & os, vtkIndent indent) Line 67 C++
               pcl_visualizer_demo.exe!vtkObjectBase::Print(std::basic_ostream<char,std::char_traits<char> > & os) Line 150                C++
               pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 37  C++
               pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536             C
               kernel32.dll!0000000076f5652d()             Unknown
               ntdll.dll!000000007718c541()      Unknown
 
This is the code that crashes:
//----------------------------------------------------------------------------
// Copy the tuple value into a user-provided array.
template <class T>
void vtkDataArrayTemplate<T>::GetTuple(vtkIdType i, double* tuple)
{
  T* t = this->Array + this->NumberOfComponents*i;
  for(int j=0; j < this->NumberOfComponents; ++j)
    {
    tuple[j] = static_cast<double>(t[j]);
    }
}
 
The program that reproduces the crash is included below. Can someone help me to debug this further?
 
#include <iostream>
#include <pcl/common/common_headers.h>
#include <pcl/visualization/pcl_visualizer.h>
 
pcl::PointCloud<pcl::PointXYZ>::Ptr createCloud()
{
       pcl::PointCloud<pcl::PointXYZ>::Ptr basic_cloud_ptr (new pcl::PointCloud<pcl::PointXYZ>);
       for (float z(-1.0); z <= 1.0; z += 0.05)
       {
             for (float angle(0.0); angle <= 360.0; angle += 5.0)
             {
                    pcl::PointXYZ basic_point;
                    basic_point.x = 0.5 * cosf (pcl::deg2rad(angle));
                    basic_point.y = sinf (pcl::deg2rad(angle));
                    basic_point.z = z;
                    basic_cloud_ptr->points.push_back(basic_point);
             }
       }
       basic_cloud_ptr->width = (int) basic_cloud_ptr->points.size ();
       basic_cloud_ptr->height = 1;
       return basic_cloud_ptr;
}
 
int main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud = createCloud();
 
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
  viewer->setBackgroundColor (0, 0, 0);
 
  viewer->addPointCloud<pcl::PointXYZ> (cloud, "sample cloud");
 
  vtkRenderer* ren = viewer->getRendererCollection()->GetFirstRenderer();
  vtkPropCollection* props = ren->GetViewProps();
 
  props->InitTraversal();
  for(int i = 0; i < props->GetNumberOfItems(); i++)
  {
       std::cout << "vtkProp #" << i << std::endl;
       vtkProp* prop = props->GetNextProp();
       prop->Print(std::cout);
  }
}
 
 
Regards,
---
Øystein Skotheim, Senior Researcher
Optical Measurement Systems and Data Analysis
 
Fra: [hidden email] [mailto:pcl-[hidden email]] På vegne av Jakob Unger
Sendt: 7. august 2013 09:37
Til: [hidden email]
Emne: [PCL-users] PCLVisualizer+VS2012+PCL1.7.0 Release Mode Problem
 
Hi,
 
I try to run the PCLVisualizer example from the documentation:
using Visual Studio 2012 on Windows 7
 
I managed to build all mandatory dependencies
boost 1.53.0
VTK 5.8.0 (this was only possible after some changes mentioned here: http://sourceforge.net/p/viste/wiki/BuildWindowsVS2012/) - 6.0.0 has too many changes to work with PCL 1.7.0
flann 1.8.4
eigen 3.1.2
 
and i build PCL 1.7.0 (2013.07.23) from the gzipped source tarball using the dependencies. All this using CMake 2.8.10.1 and all for 32bit.
 
I also used CMake+VS2012 to build the PCLVisualizer example in debug and in release mode. Both successful. In debug mode the program runs without problems, but the release build gives me this:

Unhandled exception at 0x514018B0 (pcl_visualization.dll) in pcl_visualizer_demo.exe: 0xC0000005: Access violation reading location 0x12BE2BEC.
 
To figure out where this comes from, i built the dependencies and PCL and the example project in release with debug.
 
This is the callstack:
            ntdll.dll!774915de()   Unknown
            [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
>          pcl_visualization.dll!vtkPolyData::ComputeBounds() Line 636     C++
            pcl_visualization.dll!vtkDataSet::GetBounds(double * bounds) Line 176 C++
            pcl_visualization.dll!vtkMapper::GetBounds() Line 105     C++
            pcl_visualization.dll!vtkActor::GetBounds() Line 318        C++
            pcl_visualization.dll!vtkFrustumCoverageCuller::Cull(vtkRenderer * ren, vtkProp * * propList, int & listLength, int & initialized) Line 98 C++
            pcl_visualization.dll!vtkRenderer::AllocateTime() Line 557           C++
            pcl_visualization.dll!vtkRenderer::Render() Line 336         C++
            pcl_visualization.dll!vtkRendererCollection::Render() Line 53       C++
            pcl_visualization.dll!pcl::visualization::PCLVisualizerInteractorStyle::OnTimer() Line 1039       C++
            pcl_visualization.dll!vtkSubjectHelper::InvokeEvent(unsigned long event, void * callData, vtkObject * self) Line 605         C++
            pcl_visualization.dll!vtkObject::InvokeEvent(unsigned long event, void * callData) Line 773    C++
            pcl_visualization.dll!vtkWin32RenderWindowInteractor::OnTimer(HWND__ * __formal, unsigned int timerId) Line 555       C++
            pcl_visualization.dll!vtkHandleMessage2(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam, vtkWin32RenderWindowInteractor * me) Line 826          C++
            pcl_visualization.dll!vtkHandleMessage(HWND__ * hWnd, unsigned int uMsg, unsigned int wParam, long lParam) Line 708        C++
            user32.dll!762762fa() Unknown
            user32.dll!76276d3a()            Unknown
            user32.dll!76276ce9()            Unknown
            user32.dll!762777c4()            Unknown
            user32.dll!76277bca()            Unknown
            pcl_visualization.dll!vtkWin32RenderWindowInteractor::Start() Line 129           C++
            pcl_visualization.dll!pcl::visualization::PCLVisualizer::spinOnce(int time, bool force_redraw) Line 449 C++
            pcl_visualizer_demo.exe!main(int argc, char * * argv) Line 378     C++
            pcl_visualizer_demo.exe!__tmainCRTStartup() Line 536   C
            kernel32.dll!76c433aa()         Unknown
            ntdll.dll!774a9ef2()    Unknown
            ntdll.dll!774a9ec5()    Unknown
 
It is caused by the lines 635 to 636 of pcl_visualizer_demo.cpp:
          this->Points->GetPoint( pts[i], x );
          this->Bounds[0] = (x[0] < this->Bounds[0] ? x[0] : this->Bounds[0]);
 
I don't have a clue why this happens and how to fix it. I think its caused by some code optimizations during release build by VS2012 compiler!? Can anyone help me with this?
BTW: Going back to VS2010 is not an option for me. I want to use PCL in an existing VS2012 project AND I want to be able to run this project in release mode ;-)
 
Thanks!

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13
 

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13
 

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6666 - Release Date: 09/14/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6667 - Release Date: 09/15/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6667 - Release Date: 09/15/13

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.3408 / Virus Database: 3222/6671 - Release Date: 09/16/13

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users