类的功能:丑类接口定义
- 接收图像帧的序列,该序列是无限。
- 检测帧中是否有运动。
- 按照一定的算法对运动帧进行分组。
到目前为止,该设计(非常愚蠢的):
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);
}
消费者(片段):
public void Foo()
{
bool groupCaptured = motionDetector.ProcessFrame(nextFrame, out lastFrame);
if (IsStaticFrame(lastFrame)) { lastFrame.Dispose(); }
else { imagesArray.Add(lastFrame); }
if(groupCaptured) { processImageGroup(imagesArray); }
}
我觉得与MotionDetector的设计以下的不舒服:
- 获取图像组的方式。
- 处置静止帧的方法。
- 通知客户端该组捕获的方式。
您能否就该类的界面设计给出一些建议,以便客户端使用该类更容易和更优雅?
究竟是什么感觉不舒服? – AxelEckenberger 2010-03-04 08:36:12
@Obalix,编辑添加我不舒服的。 – Benny 2010-03-04 08:39:42