Skip to content

Frame Extraction

inspection.FrameExtractor

주어진 연속된 프레임들 중에서 검사에 사용할 최적의 프레임을 추출하고, 자동 보정을 수행합니다.

Usage

demo/frame_extraction.py 참고

build(config) classmethod

FrameExtractor class의 instance를 생성합니다.

Parameters:

Name Type Description Default
config Dict

FrameExtractor build 하기 위한 config가 담겨 있는 dictionary 입니다.

{
    "reference_frame": Union[str, np.ndarray],  # 최적 검사 프레임으로 판단할 기준이 되는 프레임.
                                                # str인 경우, 해당 경로의 이미지를 로드하여 사용합니다.
    "roi": Optional[Dict],                      # ROI 세팅. ROIHandlerAPI의 build config와 동일합니다.
                                                # ROI는 내부 비교에만 사용되며, 최종 결과에는 반영되지 않습니다.
                                                # None이면 ROI를 적용하지 않습니다. (default None)
    "weights": Optional[List[float]],           # 인접 프레임 간의 가중치. 길이는 홀수여야 합니다. (default None)
    "auto_calibrate": bool,                     # 자동 보정 여부. (default True)
    "calibration_roi": Optional[Dict],          # 보정에 사용할 ROI 세팅. ROIHandlerAPI의 build config와 동일합니다.
                                                # ROI는 프레임 보정을 위해 사용됩니다.
                                                # None이면 `roi`의 주변 영역을 사용합니다. (default None)
    "calibration_threshold": float,             # 보정에 사용할 keypoint 매칭 threshold. (default 0.7)
}

required

Returns:

Name Type Description
FrameExtractor FrameExtractor

build가 완료된 FrameExtractor class의 instance를 반환합니다.

Note

경로에서 이미지를 로드할 때 다른 모듈에서 사용하는 ImageLoader를 사용하고 있지 않으므로, 16bit 이미지 등은 로드가 불가능할 수 있습니다.

extract_optimal_frame(frames)

주어진 연속된 프레임들 중에서 검사에 사용할 최적의 프레임을 추출합니다. auto_calibrate=True인 경우, 프레임들을 기준 프레임에 맞게 보정합니다.

Parameters:

Name Type Description Default
frames List[ndarray]

연속된 프레임들의 List 입니다. 각 프레임은 다음 제약 조건을 갖습니다. data type: uint8 channel: H x W / H x W x 1 - Gray H x W x 3 - RGB H x W x 4 - RGBA

required

Returns:

Type Description
ndarray

np.ndarray: 추출된 최적 프레임입니다. auto_calibrate=True로 build된 경우 기준 프레임에 맞게 보정된 프레임임니다.