類的功能:醜類接口定義
- 接收圖像幀的序列,該序列是無限。
- 檢測幀中是否有運動。
- 按照一定的算法對運動幀進行分組。
到目前爲止,該設計(非常愚蠢的):
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