Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Trackbar callback as a member function

I am modeling my whole app with one class, let's call it X. As I intend to have many X objects, I need to use a Videocapture object as a member of each X object and I need to have a member function thereof to act as a callback for GUI trackbars. Plus, my callback needs to access X.cap status. However, C++ pointers to functions as required by createTrackbar() have to be either global or static, thus defeating the idea of having many X objects. Has somebody worked around this problem? StackOverflow and other communities present non-working or non-feasible solutions. Thank you in advance!

Trackbar callback as a member function

I am modeling my whole app with one class, let's call it X. As I intend to have many X objects, I need to use a Videocapture object as a member of each X object and I need to have a member function thereof to act as a callback for GUI trackbars. Plus, my callback needs to access X.cap status. However, C++ pointers to functions as required by createTrackbar() have to be either global or static, thus defeating the idea of having many X objects. Has somebody worked around this problem? StackOverflow and other communities present non-working or non-feasible solutions. solutions. Thank you in advance!

EDIT: In all fairness, StackOverflow user Daniel offers a good, similar response I was not able to understand in http://stackoverflow.com/questions/8636689/opencv-trackbar-callback-in-c-class

Trackbar callback as a member function

I am modeling my whole app with one class, let's call it X. As I intend to have many X objects, I need to use a Videocapture object as a member of each X object and I need to have a member function thereof to act as a callback for GUI trackbars. Plus, my callback needs to access X.cap status. However, C++ pointers to functions as required by createTrackbar() have to be either global or static, thus defeating the idea of having many X objects. Has somebody worked around this problem? StackOverflow and other communities present non-working or non-feasible solutions. Thank you in advance!

EDIT: In all fairness, StackOverflow user Daniel offers a good, similar response I was not able to understand in http://stackoverflow.com/questions/8636689/opencv-trackbar-callback-in-c-class