跳至內容
測試伺服器
開發伺服器

影像擷取#

本主題說明如何設定連續影像擷取,並提供關於 grab strategy 的建議。

Continuous Acquisition#

此範例示範如何使用以下項目設定連續影像擷取: LatestImageOnly grab strategy.

with pylon.InstantCamera(pylon.FirstFound) as camera:
    camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly)

    while camera.IsGrabbing():
        with camera.RetrieveResult(5000) as grab_result:
            if grab_result.GrabSucceeded():
                image = grab_result.Array

Grab Strategies#

當相機產生影格的速度大於應用程式消耗它們的速度時,grab strategy 會定義如何在內部緩衝區佇列中處理影像。

簡單來說,它們回答了這個問題:當應用程式仍在處理較舊的影像時,若有新影像到達,應該怎麼做?

有兩種常見的 grab strategy:

  • LatestImageOnly:
    • 只保留最新的影像。
    • 較舊的影格可能會被捨棄。
  • OneByOne:
    • 所有影格都會排隊並按順序處理。
    • 不會丟棄任何影格(除非緩衝區溢位)。

以下幾點有助於您決定何時使用哪種策略:

  • 使用 LatestImageOnly 適用於:
    • 即時顯示
    • GUI
    • 低延遲系統
  • 使用 OneByOne 適用於:
    • 檢測系統
    • 錄製
    • 確定性處理

如需權衡取捨與內部行為的詳細說明,請參閱 Performance Optimization 主題。

Mental Model#

Camera → [F1, F2, F3, F4]

LatestImageOnly:
                → Keep F4 only

OneByOne:
                → Process F1 → F2 → F3 → F4