PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.86k stars 4.61k forks source link

PCLVisualizer tutorial issue on Windows #1601

Open SergioRAgostinho opened 8 years ago

SergioRAgostinho commented 8 years ago

There's been some people getting exceptions on the PCLVisualizer tutorial on Windows platforms. More info in threads http://www.pcl-users.org/Can-t-visualize-normals-Exception-thrown-td4041574.html http://www.pcl-users.org/Access-Violation-vtkOpenGLBufferObject-GenerateBuffer-enum-vtkOpenGLBufferObject-ObjectType-td4041634.html

@UnaNancyOwen do you mind giving it a try? You're kind of our Windows person :)

UnaNancyOwen commented 8 years ago

I have tried the PCLVisualizer tutorial on Windows.

Test results of each command argument is here. I couldn't identify the error cause. But, I found that doesn't occur error with to remove the following lines. The error cause might be on that lines.

command arguments test result doesn't occur error
when comment out this lines
-h operate correctly
-s operate correctly
-r operate correctly
-c operate correctly
-n runtime error #L92
-a runtime error #L117
-v runtime error #L169-170
-i runtime error

Does this tutorial will operate correctly in other environments (Linux, Mac OS)?

SergioRAgostinho commented 8 years ago

Thanks a lot Tsukasa.

On Linux yes, I will try on Mac over the weekend but assume that it does.

I've requested people a bunch of stacktraces but the thing was kind of cryptic. The only thing I know is that the problem is triggered once you request the viewer to spinOnce().

I would also suggest we now start with the addPointCloudNormals, and ver minimal example. Synthesize a 3-point point cloud, compute the normals, see if we can reproduce the error.

UnaNancyOwen commented 8 years ago

This runtime error didn't occur when VTK_RENDERING_BACKEND is OpenGL. There is a possibility that there is a cause of the problem in the OpenGL2 backend support of PCL. (Probably, "-i" case is another cause.)

command arguments OpenGL2 backend OpenGL backend
-h operate correctly operate correctly
-s operate correctly operate correctly
-r operate correctly operate correctly
-c operate correctly operate correctly
-n runtime error operate correctly
-a runtime error operate correctly
-v runtime error operate correctly
-i runtime error runtime error

From now on, PCL is desirable to be able to use the OpenGL2 backend for performance. For the reason, I think that this issue is should be solved.

SergioRAgostinho commented 8 years ago

Is the runtime error on the interactive mode, triggered when you start interacting with the mouse or does it happens regardless of the interaction? I've had a crash on Linux on '-i' when I started using the mouse.

UnaNancyOwen commented 8 years ago

I've had a crash on Linux on '-i' when I started using the mouse.

That runtime error will occur at the same situation on Windows. It error will occur when controlled mouse.

UnaNancyOwen commented 8 years ago

Does anyone have ideas to solve these errors? Under the circumstances, Would it be better to use the OpenGL-backend rather than OpenGL2-backend on Windows?

UnaNancyOwen commented 8 years ago

I have distribute "PCL 1.8.0 RC2 All-in-one Installer" that include VTK OpenGL/OpenGL2 backend for verify this issues. You can confirm this issues immediately.

SergioRAgostinho commented 8 years ago

Thanks Tsukasa. I'll try to at least sort the bug with the interactive mode before the Hackfest. But I won't be able to sort the issue with the OpenGL2 backend.

UnaNancyOwen commented 8 years ago

@SergioRAgostinho Probably, This issues will take more time to resolve because it is only occur on Windows. I will propose that PCL 1.8.0 pre-built package for Windows should release with OpenGL-backend.

RobertSpir commented 8 years ago

I don't have any of these crashes with opengl2 backend, only crashing with -i and that is caused because the viewer pointer somehow doesn't get passed to event handlers. When I changed the viewer to global variable, everything works without crashing.

And I think that in this case the tutorial is wrong because it is passing the address of local variable viewer when registering callback (lines 216 and 217) viewer->registerKeyboardCallback (keyboardEventOccurred, (void*)&viewer); the variable on that address doesn't exist when the event handler gets called

RobertSpir commented 8 years ago

oh and another problem on windows is when mixing static and dynamic vtk/pcl libraries, it is causing a lot of crashes. I'm currently using both vtk and pcl libraries as static without problems. It also worked when I was using both as dynamic dll's.

ShangxuanWu commented 7 years ago

Is this related to addsphere() crash? I am using win10+pcl1.8.0 and when I call addshpere() it always crashes.

ShangxuanWu commented 7 years ago

Fixed by switching VTK backend from OpenGL2 to OpenGL backend. Hope that PCL (VTK) fix this bug soon.

bygreencn commented 7 years ago

Is this issue continue fixing? addPointCloudNormals still crash with

  1. PCL 1.8.1 rc2
  2. VTK 7.0.0 with opengl backend static version.
  3. MSVC-2013p5

Have run VTK tests, all passed except TestStructuredGridLIC2DYSlice(this is not reason of addPointCloudNormals crash).

the crash reason is:

vtkObjectFactory::RegisteredFactories->InitTraversal() got NULL result, which cause the pointer of vtkActor is NULL and the next operation is crashed.

I do not know how to fixed, so...

YouYue123 commented 6 years ago

Recompiling PCL and VTK with OPENGL option works for me. All of the samples under pcl visualisation works for me.

My env is as ::

  1. MacOS 10.13.1 (17B1003)
  2. PCL 1.8.0
  3. VTK 8.0.0
  4. cmake 3.10.0
  5. Apple LLVM version 9.0.0 (clang-900.0.39.2) x86_64-apple-darwin17.2.0

I wrote a resolve solution

https://youyue123.github.io/tech/2018/01/19/Fix-Add-Normal-Crash-Bug-for-PCL.html

Hope next release of PCL could consider this issue and make a progressive way by leveraging OPENGL2 performance bonus and some regression bug.

SergioRAgostinho commented 6 years ago

I wrote a resolve solution

https://youyue123.github.io/tech/2018/01/19/Fix-Add-Normal-Crash-Bug-for-PCL.html

I went through your blog post but didn't exactly see any solution posted, just instructions for building PCL and selecting the VTK rendering engine. Nevertheless if you have indeed solved it, please consider submitting a pull request.

bygreencn commented 6 years ago

After more debugging, I could confirm that almost more reasons about addPointCloudNormals crashed at Windows is cauesed by User that he does not operate completely by this rule of "How Implementation Modules Are Initialized at VTK/Build System Migration" .

Put the following definition before the code will fix almost all of them:

include

VTK_MODULE_INIT(vtkRenderingOpenGL); //if render backen is OpenGL2, it should changes to vtkRenderingOpenGL2 VTK_MODULE_INIT(vtkInteractionStyle); VTK_MODULE_INIT(vtkRenderingFreeType); VTK_MODULE_INIT(vtkRenderingVolumeOpenGL); //if render backen is OpenGL2, it should changes to vtkRenderingVolumeOpenGL2

SergioRAgostinho commented 6 years ago

@bygreencn Thanks for digging that up. We now have some pointers on what to look for.

@taketwo How about we migrate the default rendering engine to OpenGL 2 and see how it goes during the RC?

taketwo commented 6 years ago

I'm not sure what you mean. Backend version is a property of VTK installation that the user has, we have no control over it.

SergioRAgostinho commented 6 years ago

Tsukasa controlled it in its all in one installer. I mixed concepts and thought we were setting it ourselves somehow.

taketwo commented 6 years ago

Oh, I see what you mean. But what would this bring? We already know that OpenGL 2 on Windows causes problems. Having a bunch of people try pre-compiled library and report this again won't help.

I think we rather need a Windows person who knows how to compile PCL to figure out what's wrong with VTK_MODULE_INIT. From the link posted by @bygreencn I gather we either need these inits either in the source code, or in compiler definitions. As far as I understand, in PCL we go the latter way and on Linux it works smoothly. When I build against VTK with old backend I get a bunch of AUTOINIT options like this inserted into the compiler flags:

-DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL)"

And when compiling against VTK with OpenGL 2 backend, the version number in these options is changed accordingly:

-DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL2)" 
UnaNancyOwen commented 5 years ago

Can this issue be add in pcl-1.9.0 milestone? The recent versions of VTK display many warning against will be removed OpenGL backend in near future. In fact, this merge request has already been merged to VTK. I think it's about time we should be fix this issue in this version. I will report update the latest status of this issue in the near days.

SergioRAgostinho commented 5 years ago

👍 Jump on it. I'll be cleaning up things on the other topics.

Edit: Don't forget to confirm that the VTK definitions are being passed properly to the tutorial.

claudiofantacci commented 5 years ago

I can also make test on Windows (but only during work days). Let me know if you need any 👍

SergioRAgostinho commented 5 years ago

Any updates on this?

UnaNancyOwen commented 5 years ago

Update Status (pcl-master ac27a0d) I think that normals is suspicious.

command arguments test result
-h operate correctly
-s operate correctly
-r operate correctly
-c operate correctly
-n runtime error
-a runtime error
-v runtime error
-i operate correctly
SergioRAgostinho commented 5 years ago

Thanks for the report. Yet I believe I misunderstood things, so me clear that up: @UnaNancyOwen are actually working on this bug or just asked for "someone" to fix it for 1.9.0?

claudiofantacci commented 5 years ago

I can try to make some tests asap on my workstation, but please bear with me that I'm quite busy these days 😞 I'll keep an eye on this issue anyway 👍

UnaNancyOwen commented 5 years ago

I don't have enough time to tackle this issue. I'm busy for a while. We need someone's help to solve this issue.

@claudiofantacci Thanks.

SergioRAgostinho commented 5 years ago

@claudiofantacci Thanks for that.

I'll will be removing issue this from the release milestone anyway. Whatever the fix ends up to be, it is likely that it can be merged even in patch version updates.

claudiofantacci commented 5 years ago

I tested PCLVisualizer tutorial with

All options work perfectly.

Note that in VTK version > 8.1

OpenGL rendering backend was deprecated for 8.1 and will not be available in subsequent VTK versions. Please switch to using OpenGL2 rendering backend.

So there is no VTK_RENDERING_BACKEND option in my setting. See also https://gitlab.kitware.com/vtk/vtk/merge_requests/3262 and this file https://gitlab.kitware.com/vtk/vtk/blob/v8.1.0/CMake/vtkBackends.cmake

SergioRAgostinho commented 5 years ago

So the deduction is that it might be fixed with the new version. We need to understand the differences between your environments @UnaNancyOwen and @claudiofantacci .

claudiofantacci commented 5 years ago

@UnaNancyOwen is checkedout at a PCL commit ahead of mine. I can try to recompile PCL pulling the latest version and see what happen.

@UnaNancyOwen, what VTK and MSVC are you using?

UnaNancyOwen commented 5 years ago

I'm using Visual Studio 2015, and VTK 8.1.1. I will test again on the same environment as you.

UnaNancyOwen commented 5 years ago

I tested with Visual Studio 2017, but it occur same runtime error on my emvironment yet. @claudiofantacci Could you try test again without vcpkg? This is my memo about how to build PCL and 3rdParty. (Please build VTK with default rendering backend option (OpenGL2) for test.)

claudiofantacci commented 5 years ago

@UnaNancyOwen, it is really difficult for me to install all the dependencies in reasonable time and test PCL 😞 for this particular issue.

First things first, let's create a table with our setup:

Dependency Claudio (vcpkg) UnaNancyOwen
MSVC 15.6.7 15.8.6
Boost 1.67.0 1.64.0
Eigen 3.3.4-2 3.3.4
FLANN 1.9.1-7 1.9.1
QHull 2015.2-2 2015.2
VTK 8.1.0-1 8.1.1
OpenNI n/a 2.2.0.33 Beta

@UnaNancyOwen, can you please provide a detailed MSVC version please?

Note that in my version dependency versions, when I have <version>-<number>, the -<number> means that succesive patches have been added to the base version of the port in vcpkg. I'll check asap whether there is something important fiexd in the Eigen, FLANN and QHull portfiles.

claudiofantacci commented 5 years ago

I also noted that you set BUILD_all_in_one_installer that I do not normally use and I'm not sure what it does 😄

UnaNancyOwen commented 5 years ago

@claudiofantacci I'm using Visual Studio 2017 15.8.6 (latest update). I don't use vcpkg for create PCL pre-built package (PCL All-in-one Installer). Therefor, I want to confirm whether occurs same error when don't use vcpkg in your environment. (Building PCL and 3rdParty on Windows is not as complicated as before. That method has already been established. Please see my memo. Can you try to build PCL and 3rdParty without vcpkg?)

claudiofantacci commented 5 years ago

@UnaNancyOwen ok, I'll do it, but it will take me some time 😃 Also, I'll try to compare your settings with the one set by vcpkg.

UnaNancyOwen commented 5 years ago

@claudiofantacci Did you reproduce this issue on your environment?

claudiofantacci commented 5 years ago

@claudiofantacci Did you reproduce this issue on your environment?

@UnaNancyOwen sorry to be late here, but I'm trying to fix other bugs first because of some failing tests under Windows. I'll be back here as soon as I have some time. 😄

UnaNancyOwen commented 5 years ago

@claudiofantacci Thanks for your contribution.

taketwo commented 5 years ago

Guys, is there any update here? There are so many people posting issues because of all the VTK warnings. It would be great if we could finally switch to OpenGL2 on Windows.

claudiofantacci commented 5 years ago

Hey @taketwo, unfortunately, I don't have news here.

It would be great if we could finally switch to OpenGL2 on Windows.

What do you mean? Is there any test I can make to help this transition? Please consider that installing other dependencies outside vcpkg and recompile PCL is quite a problem for me 😭

taketwo commented 5 years ago

It would be great if we could finally switch to OpenGL2 on Windows.

What do you mean?

@UnaNancyOwen please correct me if I'm wrong. Right now Tsukasa's all-in-one installer defaults to OpenGL backend. This is because he encounters errors with OpenGL2 backend. So everyone using that installer gets old backend and then gets swamped with deprecation warnings.

Back in October last year we figured that Claudio does not have problems with vcpkg-based installation. So the idea was to understand what is the difference between Tsukasa's and Claudio's environments.

UnaNancyOwen commented 5 years ago

@claudiofantacci I'm using Visual Studio 2017 15.8.6 (latest update). I don't use vcpkg for create PCL pre-built package (PCL All-in-one Installer). Therefor, I want to confirm whether occurs same error when don't use vcpkg in your environment. (Building PCL and 3rdParty on Windows is not as complicated as before. That method has already been established. Please see my memo. Can you try to build PCL and 3rdParty without vcpkg?)

@claudiofantacci Could you try this with OpenGL2 backend on your environment? https://gist.github.com/UnaNancyOwen/59319050d53c137ca8f3#file-pcl1-9-1-md

UnaNancyOwen commented 5 years ago

I confirmed that these work correctly with PCL installed using vcpkg in my environment. However, I couldn't identify that cause (why is it different from self-build) yet ... :( Can you think of anything that might have caused it?

larshg commented 5 years ago

Hey all

I have build it with following libraries, without vcpkg:

Dependency Lars
MSVC 16.2 Preview 3
Boost 1.67.0
Eigen 3.3.3
FLANN 1.9.1
QHull 2015.2
VTK 8.2/8.1 shared library
OpenNI n/a

VTK has only the opengl2 option.

And the tutorial works fine, showing normals, shapes and viewports (Works both in release and debug build).

UnaNancyOwen commented 5 years ago

@larshg I will try with a similar version of your system. Thanks for your report.

larshg commented 5 years ago

@UnaNancyOwen In the meantime I'll try to use VTK 8.1 to see if this makes it fail here. Still with Opengl2 backend.