Skip to content

ColorDetection

Robomation RnD Center edited this page Jul 8, 2026 · 1 revision

ColorDetection (색깔 찾기)

카메라 영상에서 등록한 색(8가지)을 찾아 위치, 크기, 감지 여부를 제공하는 색깔 찾기 AI 확장 모듈입니다.

인스턴스 선언

color_detection = ColorDetection(0)
이름 구분 설명 범위 / 종류 기본값
index 드롭다운 옵션 인스턴스 번호 (0부터 시작) 0 이상 정수 0

함수

device

색깔 찾기에 사용할 카메라 장치를 선택합니다. 카메라 이름(문자열), 인덱스, 또는 Camera 객체를 전달할 수 있습니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
unit 드롭다운 옵션 카메라 지정 값 카메라 라벨(str) / 인덱스(int) / Camera 객체 -

예제

color_detection = ColorDetection(0)

color_detection.device('')

register_color

지정한 색을 인식 대상으로 등록합니다. waitTrue 이면 등록이 엔진에 반영될 때까지 기다립니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
color 드롭다운 옵션 색깔 이름 검정(black), 빨강(red), 노랑(yellow), 초록(green), 청록(cyan), 파랑(blue), 자홍(magenta), 흰색(white) -
wait 체크박스 완료 대기 여부 True / False True

예제

color_detection = ColorDetection(0)

color_detection.register_color('red', wait=True)

delete_color

지정한 색을 인식 대상에서 삭제합니다. waitTrue 이면 삭제가 엔진에 반영될 때까지 기다립니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
color 드롭다운 옵션 색깔 이름 검정(black), 빨강(red), 노랑(yellow), 초록(green), 청록(cyan), 파랑(blue), 자홍(magenta), 흰색(white) -
wait 체크박스 완료 대기 여부 True / False True

예제

color_detection = ColorDetection(0)

color_detection.delete_color('blue', wait=True)

area_condition

색이 감지되었다고 판단할 최소 면적 조건값을 설정합니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
data 입력값 (블록) 면적 조건값 0 이상 실수 -

예제

color_detection = ColorDetection(0)

color_detection.area_condition(50)

detect_once

색을 한 번만 인식합니다.

매개변수: 없음

예제

color_detection = ColorDetection(0)

color_detection.detect_once()

detect_continuous

색을 연속적으로 인식하기 시작합니다.

매개변수: 없음

예제

color_detection = ColorDetection(0)

color_detection.detect_continuous()

stop

연속 색 인식을 정지합니다.

매개변수: 없음

예제

color_detection = ColorDetection(0)

color_detection.stop()

display

색 인식 결과를 카메라 화면에 표시할지 여부를 설정합니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
on 드롭다운 옵션 표시 ON / OFF 표시(True/1), 숨기기(False/0) True

예제

color_detection = ColorDetection(0)

color_detection.display(True)
color_detection.display(False)

color

지정한 색의 위치/크기 값을 반환합니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
color 드롭다운 옵션 색깔 이름 검정(black), 빨강(red), 노랑(yellow), 초록(green), 청록(cyan), 파랑(blue), 자홍(magenta), 흰색(white) -
pos 드롭다운 옵션 좌표/크기 종류 x, y, min_x, max_x, min_y, max_y, width, height, area -

반환값 — 지정한 좌표/크기 값 (정수)

예제

color_detection = ColorDetection(0)

color_detection.color('red', 'x')
color_detection.color('blue', 'area')
color_detection.color('green', 'y')

color_detected

지정한 색이 (면적 조건값 이상으로) 감지되었는지 여부를 반환합니다.

매개변수

이름 구분 설명 범위 / 종류 기본값
color 드롭다운 옵션 색깔 이름 검정(black), 빨강(red), 노랑(yellow), 초록(green), 청록(cyan), 파랑(blue), 자홍(magenta), 흰색(white) -

반환값 — 감지되었으면 True, 아니면 False (bool)

예제

color_detection = ColorDetection(0)

color_detection.color_detected('red')

Clone this wiki locally