PROPOSED APPROACH
The MR !291 (merged) contains the following implementation.
There are 2 possible lines of execution, when a capture or a keyframe is notified via callback: New capture:
void captureCallback(CaptureBasePtr) (public): Is the external API (called by SensorBase::process(CaptureBasePtr)). Implemented in ProcessorBase: it calls processCapture(CaptureBasePtr) if triggerInCapture(CaptureBasePtr) == true.
virtual bool triggerInCapture(CaptureBasePtr) (protected): Implemented in derived classes. It returns if processCapture(CaptureBasePtr) should be called.
virtual void processCapture(CaptureBasePtr) (protected): Implemented in derived classes. For those processors that process all or some captures, the algorithm should be here.
New key-frame:
void keyFrameCallback(FrameBasePtr, TimeStamp) (public): Is the external API (called by Problem::keyFrameCallback(...)). Implemented in ProcessorBase: it calls processKeyFrame(FrameBasePtr, TimeStamp) if triggerInKeyFrame(FrameBasePtr, TimeStamp) == true.
virtual bool triggerInKeyFrame(FrameBasePtr, TimeStamp) (protected): Implemented in derived classes. It returns if processKeyFrame(FrameBasePtr, TimeStamp) should be called.
virtual void processKeyFrame(FrameBasePtr, TimeStamp) (protected): Implemented in derived classes. For those processors that process all or some key-frames, the algorithm should be here.
process(CaptureBasePtr) was modified to processKeyFrame(FrameBasePtr, TimeStamp)
new virtual bool triggerInCapture(CaptureBasePtr){return false;}
new virtual bool triggerInKeyFrame(FrameBasePtr, TimeStamp){return true;}
new virtual void processCapture(CaptureBasePtr){} (not called)
OPEN ISSUES
Everything is working now. However, there is still a thing that I don't like.
The implementation of ProcessorBase::captureCallback(CaptureBasePtr) is:
void ProcessorBase::captureCallback(CaptureBasePtr _capture_ptr){ // if trigger, process directly without buffering if (triggerInCapture(_capture_ptr)) processCapture(_capture_ptr); else buffer_capture_.add(_capture_ptr->getTimeStamp(), _capture_ptr);}
And the implementation of ProcessorBase::keyFrameCallback(FrameBasePtr _keyframe_ptr, const Scalar& _time_tol_other) is:
As you can see, they are not equivalent. All key-frames are stored in the buffer in all types of processors but the captures are not if triggerInCapture(...) is true. I imagine some cases in which maybe the storage and the processing of a capture/key-frame are independent choices. Maybe 2 new parameters in ParamsProcessorBase::store_captures and ParamsProcessorBase::store_keyframes would be better?
ProcessorCaptureHolder Actually, I think that this is a processor that implemented the capture buffer, now included in ProcessorBase. I don't know who did it, I am not sure it is still useful: #243 (closed)