파이썬
import cv2 import numpy as np 필요한 모듈 import def yolo(frame, size, score_threshold, nms_threshold): # YOLO 네트워크 불러오기 net = cv2.dnn.readNet(f"yolov3_{size}.weights", "yolov3.cfg") layer_names = net.getLayerNames() output_layers = [layer_names[i[0] - 1] for i in net.getUnconnectedOutLayers()] # 클래스의 갯수만큼 랜덤 RGB 배열을 생성 colors = np.random.uniform(0, 255, size=(len(classes), 3)) # 이미지의 높이, 너비, 채널 받아오기..
파이썬
import cv2 import math 필요한 모듈 import def output_keypoints(image_path, proto_file, weights_file, threshold, model_name, BODY_PARTS): global points # 이미지 읽어오기 frame = cv2.imread(image_path) # 네트워크 불러오기 net = cv2.dnn.readNetFromCaffe(proto_file, weights_file) # 입력 이미지의 사이즈 정의 image_height = 368 image_width = 368 # 네트워크에 넣기 위한 전처리 input_blob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (image_width, im..
파이썬
import cv2 필요한 모듈 import def output_keypoints(frame, net, threshold, BODY_PARTS, now_frame, total_frame): global points # 입력 이미지의 사이즈 정의 image_height = 368 image_width = 368 # 네트워크에 넣기 위한 전처리 input_blob = cv2.dnn.blobFromImage(frame, 1.0 / 255, (image_width, image_height), (0, 0, 0), swapRB=False, crop=False) # 전처리된 blob 네트워크에 입력 net.setInput(input_blob) # 결과 받아오기 out = net.forward() # The outpu..
파이썬
아래 Git을 통하여 OpenPose를 다운로드 후 model폴더의 getModels.bat을 실행(윈도우) https://github.com/CMU-Perceptual-Computing-Lab/openpose CMU-Perceptual-Computing-Lab/openpose OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation - CMU-Perceptual-Computing-Lab/openpose github.com import cv2 필요한 모듈 import def output_keypoints(frame, proto_file, weights_file, threshold..