I am trying to register a keyboard callback function to a 3D viewer using the Point Cloud Library API.
Todo this I do:
viewer->registerKeyboardCallback(&(RailExtraction::keyboard_callback), (void*)(>_data));
But I get the following error message:
note: no known conversion for argument 1 from 'void (RailExtraction< pcl::PointXYZI >::*)
(const pcl::visualization::KeyboardEvent&, void*)' to 'void (*)(const pcl::visualization::KeyboardEvent&, void*)'
I am trying to understand the error message. I understand what void and void * mean but what does void(*)(...) or void(RailExtraction< pcl::PointXYZI >::*>(...) mean ??
I figured out the problem I am using the wrong version of
registerKeyBoardCallBack. I am currently trying to use this signature:registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = NULL)But I should be using this signature:
registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = NULL)This is because my
keyboard_callbackfunction is part of a class and therefore I need to specify the instance of the class so that the compiler can figure out which instance thekeyboard_callbackfunction to use. Therefore my new call toregisterKeyboardCallBacklooks like this:viewer->registerKeyboardCallback(&RailExtraction::keyboard_callback, *this, (void*)>_data);