vision_detect · 사물·QR·손·포즈 인식¶
사물·QR코드·포즈·손동작·마커를 인식합니다.
Class:
putTextPIL()
Detect
- openpibo.vision_detect.putTextPIL(img, text, points, size=30, colors=(255, 255, 255))[소스]¶
이미지에 문자를 입력합니다. (한/영 가능 - pillow 이용)- COPY
- 매개변수:
img (numpy.ndarray) – 이미지 객체
text (str) – 표시할 문자열
points (tuple(int, int)) – 텍스트 블록 좌측상단 좌표 (x, y)
size (int) – 표시할 글자의 크기
colors (tuple(int, int, int)) – 글자 색깔 BGR 값 (b, g, r) or 16진수 값 ‘#rrggbb’
- class openpibo.vision_detect.Detect(object_model=None)[소스]¶
기반 클래스:
objectFunctions:
load_object_model()detect_object()detect_object_vis()detect_qr()detect_qr_vis()detect_pose()detect_pose_vis()analyze_pose()load_hand_gesture_model()recognize_hand_gesture()recognize_hand_gesture_vis()detect_marker()detect_marker_vis()인식과 관련된 다양한 기능을 사용할 수 있는 클래스입니다.
사물 인식 (easydetect ed, 기본 COCO 80개 class · lab 에서 학습한 모델, onnxruntime)
QR/바코드 인식 (pyzbar)
Pose 인식 (MoveNet)
손동작 인식 (MediaPipe)
마커 인식 (ArUco)
example:
from openpibo.vision_detect import Detect detect = Detect() # 아래의 모든 예제 이전에 위 코드를 먼저 사용합니다.
- load_hand_gesture_model(modelpath='/home/pi/.model/hand/gesture_recognizer.task')[소스]¶
손동작 인식 모델을 불러옵니다.
- 매개변수:
modelpath (str) – 손동작 인식 모델 경로
- recognize_hand_gesture(image)[소스]¶
손동작을 인식합니다.
- 매개변수:
image (numpy.ndarray) – 이미지 객체
- 반환:
모델에 따른 손동작 인식 결과
- recognize_hand_gesture_vis(img, items)[소스]¶
손동작 인식 결과를 표시합니다.
- 매개변수:
img (numpy.ndarray) – 이미지 객체
items (array) – 손동작 인식 결과
- load_object_model(modelpath=None)[소스]¶
사물 인식 모델을 불러옵니다.
easydetect 모델 파일(
.onnx)을 고릅니다. easydetect lab 에서 받은job<번호>.onnx가 그대로 쓰입니다. 클래스 이름과 확신 기준은 파일 안에 들어 있고, 이름은 한글일 수 있습니다. 모델을 못 쓰면(파일이 없음, onnxruntime 1.13 미만, 읽기 실패) 이유가 담긴 오류가 납니다.example:
detect.load_object_model('/home/pi/code/job3.onnx') # lab 에서 받은 모델 detect.load_object_model() # 기본 모델(COCO)로 돌아가기
- 매개변수:
modelpath (str) – 사물 인식 모델 파일(
.onnx). 없으면 기본 모델
- detect_object(img)[소스]¶
이미지에서 사물을 찾습니다(모델은
load_object_model로 바꿀 수 있습니다).- 매개변수:
img (numpy.ndarray) – 이미지 객체
- 반환:
[{"name": 이름, "score": 점수(%), "box": (x1, y1, x2, y2)}, ...]
- detect_object_vis(img, items)[소스]¶
사물 인식 결과를 표시합니다.
- 매개변수:
img (numpy.ndarray) – 이미지 객체
items (array) – 사물 인식 결과
- detect_qr(img)[소스]¶
이미지 안의 QR코드 및 바코드를 인식합니다.
example:
img = camera.read() detect.detect_qr(img)
- 매개변수:
img (numpy.ndarray) – 이미지 객체
- 반환:
{"data": 내용, "type": 바코드 / QR코드, "position":(startX,startY,endX,endY)}
- detect_qr_vis(img, items)[소스]¶
QR/바코드 결과를 표시합니다.
- 매개변수:
img (numpy.ndarray) – 이미지 객체
items (array) – QR 인식 결과
- detect_pose(img)[소스]¶
이미지 안의 Pose를 인식합니다.
example:
img = camera.read() detect.detect_pose(img)
- 매개변수:
img (numpy.ndarray) – 이미지 객체
- 반환:
인식한 결과
- detect_pose_vis(img, items)[소스]¶
포즈를 표시 합니다.
- 매개변수:
img (numpy.ndarray) – 이미지 객체
items (array) – 포즈 데이터
- analyze_pose(data)[소스]¶
detect_pose 함수의 결과 값을 분석합니다.
example:
img = camera.read() result = detect.detect_pose(img) detect.analyze_pose(result)
- 매개변수:
data (dict) – 이미지 객체
- 반환:
인식한 포즈 리스트 ['left_hand_up', 'right_hand_up', 'clap']