cap_inspector package
Subpackages
Submodules
cap_inspector.cap_inspector module
赤色キャップの位置・傾斜に基づく開閉検査。
- class cap_inspector.cap_inspector.CapInspector(camera_id=0, BOTTLE_RIM_Y=275, MM_TO_PIXEL=4.0, TARGET_CLOSE_MM=0.5, TARGET_OPEN_MM=3.5, TOLERANCE_MM=1.0, current_mode='closed', logger=None)[source]
Bases:
object赤色キャップの検出・開閉判定を行うクラス。
- current_mode
inspect() の既定判定モード。
- Type:
str
- camera_id
画像取得に使用するカメラ番号。
- Type:
int
Notes
コンストラクタ引数は初期値であり、個別setterで変更できる。 is_open() と is_closed() は直近の判定結果だけを返す。
- get_image(jpeg_quality=85)[source]
最新フレームを取得し、判定結果を描画したJPEGを返す。
- Parameters:
jpeg_quality – JPEG品質(0~100)。
- Returns:
image``(JPEGバイト列)、``is_safe、reason。- Return type:
dict
Notes
画像ストリーミングも検査状態を更新する。GUIと制御スクリプトで 同じインスタンスを共有する場合は、状態更新の競合に注意する。
- inspect(current_mode=None)[source]
カメラから1フレーム取得して検査する。
- Parameters:
current_mode –
closedまたはopened。省略時は インスタンスの現在のモードを使用する。指定時は設定も更新する。- Returns:
指定モードの検査に合格した場合は True。
- Return type:
bool
- is_closed() bool[source]
直近の検査で閉栓条件を満たしたか返す。
- Returns:
- 最後のフレームで閉栓条件を満たした場合は True。
未検査または検出失敗時は False。
- Return type:
bool
- is_open() bool[source]
直近の検査で開栓条件を満たしたか返す。
- Returns:
- 最後のフレームで開栓条件を満たした場合は True。
未検査または検出失敗時は False。
- Return type:
bool
Notes
画像の取得や再判定は行わない。inspect() または process_frame() で更新された状態を参照する。
- property mode
- process_frame(frame, current_mode=None)[source]
指定したフレームから開栓・閉栓の両条件を判定する。
- Parameters:
frame – OpenCV BGR画像。
current_mode – 返却する判定結果のモード。省略時は現在の設定。
- Returns:
指定モードの条件を満たした場合は True。
- Return type:
bool
Notes
開栓・閉栓の判定フラグは同じフレームから同時に更新する。
cap_inspector.viewer module
- class cap_inspector.viewer.CapInspectorViewer(*args: Any, **kwargs: Any)[source]
Bases:
QMainWindowCapInspector / CapInspectorClient 共通 GUI viewer。
- class cap_inspector.viewer.ImageLabel(*args: Any, **kwargs: Any)[source]
Bases:
QLabel認識済み画像をそのまま表示する。