vision_detect

영상처리, 인공지능 비전 기술을 사용합니다.

Class: putTextPIL() vision_api() 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)) – 글자 색깔 RGB 값 (b, g, r) or 16진수 값 ‘#ffffff’

openpibo.vision_detect.vision_api(mode, image, params={})[소스]

인공지능 비전 API를 호출합니다.

매개변수:
  • mode (str) – 호출할 비전 API (https://o-vapi.circul.us/guide)

  • image (str/numpy.ndarray) – 표시할 이미지 (파일 경로 or cv 이미지)

반환:

Json 타입 결과의 데이터

example:

{ 'type': 'caption', 'result': 'ok', 
  'data': {
    caption:  "사람에게 로봇을 과시하는 사람", 
    caption_en:  "a person showing off a robot to a person",
    raw:  [
      "a person showing off a robot to a person",
      "a robot that is sitting on top of a table",
      "a very cute white robot that is sitting in front of a table"
    ]
  }
}
class openpibo.vision_detect.Detect[소스]

기반 클래스: object

Functions: load_hand_gesture_model() detect_object() detect_qr() detect_pose() analyze_pose() classify_image() object_tracker_init() track_object() detect_marker() detect_marker_vis()

인식과 관련된 다양한 기능을 사용할 수 있는 클래스입니다.

  • 90개 class 안에서의 객체 인식 (MobileNet V2)

  • QR/바코드 인식 (pyzbar)

  • Pose 인식

  • 이미지 분류

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)[소스]

손동작을 인식합니다.

매개변수:

img (numpy.ndarray) – 이미지 객체

반환:

모델에 따른 손동작 인식 결과

recognize_hand_gesture_vis(img, items)[소스]

손동작 인식 결과를 표시합니다.

매개변수:
  • img (numpy.ndarray) – 이미지 객체

  • items (array) – 손동작 인식 결과

load_object_model(modelpath='/home/pi/.model/object/yolo11s.onnx')[소스]

인식 모델을 불러옵니다.

매개변수:

modelpath (str) – 사물인식 모델 경로

detect_object(img)[소스]

사물 인식 결과를 표시합니다.

매개변수:
  • img (numpy.ndarray) – 이미지 객체

  • items (array) – 사물 인식 결과

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']

object_tracker_init(img, p)[소스]

이미지 안의 사물 트래커를 설정합니다.

example:

img = camera.read()
detect.object_tracker_init(img)
매개변수:

img (numpy.ndarray) – 이미지 객체

track_object(img)[소스]

이미지 안의 사물 트래커를 갱신합니다.

example:

img = camera.read()
detect.object_tracker_init(img, (10,10,100,100))
position = detect.track_object(img)
매개변수:

img (numpy.ndarray) – 이미지 객체

반환:

x1,y1,x2,y2 업데이트 된 사물 위치

track_object_vis(img, item)[소스]

마커 결과를 표시합니다.

매개변수:
  • img (numpy.ndarray) – 이미지 객체

  • items (array) – 마커 결과

detect_marker(img, marker_length=2)[소스]

이미지 안의 마커를 인식합니다. # cv2.aruco.DICT_4X4_50

example:

img = camera.read()
result = detect.detect_marker(img)
매개변수:

img (numpy.ndarray) – 이미지 객체

반환:

[{"id": 마커번호, "center":  }, ...]

detect_marker_vis(img, items)[소스]

마커 결과를 표시합니다.

매개변수:
  • img (numpy.ndarray) – 이미지 객체

  • items (array) – 마커 결과