The function of the class:
- Receive a sequence of image frames, the sequence is infinite.
- Detect if there is motion in the frames.
- Group motion frames according to certain algorithm.
So far the design is(pretty silly):
class MotionDetector
{
//detect motion in the frame, return true if the group is captured.
//frameToDispose is the frame that need be dispose, or for further process.
public bool ProcessFrame(Frame in, out frameToDispose);
}
The consumer(snippet):
public void Foo()
{
bool groupCaptured = motionDetector.ProcessFrame(nextFrame, out lastFrame);
if (IsStaticFrame(lastFrame)) { lastFrame.Dispose(); }
else { imagesArray.Add(lastFrame); }
if(groupCaptured) { processImageGroup(imagesArray); }
}
I feel uncomfortable with the MotionDetector's design of the following:
- The way to get the images group.
- The way to dispose motionless frame.
- The way to notify client that group captured.
Can you give some advice on the class's interface design, so that it is easier and more elegant for the client to consume this class?