PointCloudLibrary / pcl

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

access violation reading position 0x0000000000000000 #5159

Open zeljko21 opened 2 years ago

zeljko21 commented 2 years ago

https://github.com/PointCloudLibrary/pcl/blob/d98313133b014553ab1b1b5b112f9aade837d55c/doc/tutorials/content/sources/narf_keypoint_extraction/narf_keypoint_extraction.cpp#L161

Hello,

I am a beginner with point cloud library and wanted to start by running some tutorials. When I tried the narf_keypoint_extraction following the steps from https://pcl.readthedocs.io/projects/tutorials/en/latest/narf_keypoint_extraction.html,I ran into an issue. The build with cmake was successful but a runtime error occured at line 161.

Error: Exception thrown at 0x00007FFF817356FD (vtkRenderingContext2D-9.0d.dll) in narf_keypoint_extraction.exe: 0xC0000005: access violation reading position 0x0000000000000000.

Exception

I read that this is due to dereferencing a null pointer but I don't understand why?

Shouldn't the tutorial work basically without any user input, as an example point cloud is generated, if no point cloud is passed by the user? Or am I forgetting something?

Any help is appreciated. Thank you!

mvieth commented 2 years ago

Do you give any (command line) arguments to narf_keypoint_extrraction.exe? Which PCL version do you use and how did you install it?

larshg commented 2 years ago

5160 partly fixes this issue. However we also need to add:

vtk_module_autoinit(TARGETS pcl-narf-keypoints 
                    MODULES VTK::RenderingContextOpenGL2)

to the CmakeLists.txt tutorial. I couldn't get it to run without it. I wonder how we can propagate these autoinit downstream. EDIT: The target name needs to be changed accordingly. This was a copy paste from my local test.

zeljko21 commented 2 years ago

Do you give any (command line) arguments to narf_keypoint_extrraction.exe? Which PCL version do you use and how did you install it?

I tried it with command line arguments and without. E.g. an example point cloud but with the same result. The 3D viewer opens and shows the point cloud (either the one I give it or the generated rectangle depending on arguments). Then the Range Image window opens but doesn't show anything. Then the exception from above is thrown.

I installed it using the 1.12.1 All-in-One .exe.

zeljko21 commented 2 years ago

5160 partly fixes this issue. However we also need to add:

vtk_module_autoinit(TARGETS pcl-narf-keypoints 
                    MODULES VTK::RenderingContextOpenGL2)

to the CmakeLists.txt tutorial. I couldn't get it to run without it. I wonder how we can propagate these autoinit downstream. EDIT: The target name needs to be changed accordingly. This was a copy paste from my local test.

OK thank you. I will try to make it run using your fixes.

larshg commented 2 years ago

@zeljko21 have you managed to try out my fixes?

unclesammy commented 2 years ago

I have the same problem at line 150.ont this tutorials https://pcl.readthedocs.io/projects/tutorials/en/latest/range_image_visualization.html#range-image-visualization

oliteksamuelfogarty commented 2 years ago

I was having the same problem. I don't know the minimum changes that are necessary to get it to work, but this CMakeLists ended up working: cmake_minimum_required(VERSION 2.6 FATAL_ERROR) project(range_image_visualization) find_package(PCL 1.12 REQUIRED) find_package(VTK REQUIRED) include_directories(${PCL_INCLUDE_DIRS} ${VTK_USE_FILE} ${VTK_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) add_executable (range_image_visualization CloudToRangeImage.cpp) target_link_libraries (range_image_visualization ${PCL_LIBRARIES} ${VTK_LIBRARIES}) vtk_module_autoinit( TARGETS ${PROJECT_NAME} MODULES ${VTK_LIBRARIES} )

brlcad commented 2 years ago

I tested this in #5284 and calling vtk_module_init() indeed appears to get it working. That macro appears to add a slew of preprocessor directives that apparently affect vtk initialization.