Closed joooooonie closed 5 years ago
import sys #import os #os.chdir('./gdrive/My Drive/Colab Notebooks/') sys.path.insert(0, './gdrive/My Drive/Colab Notebooks/') import cv2 import model import util from hand import Hand from body import Body import matplotlib.pyplot as plt import copy import numpy as np body_estimation = Body('model/body_pose_model.pth') hand_estimation = Hand('model/hand_pose_model.pth') for i in range(33,67): test_image = 'dataframe/are_you_hurt/1/frame'+str(i)+'.jpg' oriImg = cv2.imread(test_image) # B,G,R order candidate, subset = body_estimation(oriImg) canvas = copy.deepcopy(oriImg) canvas = util.draw_bodypose(canvas, candidate, subset) hands_list = util.handDetect(candidate, subset, oriImg) all_hand_peaks = [] for x, y, w, is_left in hands_list: peaks = hand_estimation(oriImg[y:y+w, x:x+w, :]) peaks[:, 0] = np.where(peaks[:, 0]==0, peaks[:, 0], peaks[:, 0]+x) peaks[:, 1] = np.where(peaks[:, 1]==0, peaks[:, 1], peaks[:, 1]+y) print(peaks) all_hand_peaks.append(peaks) canvas = util.draw_handpose(canvas, all_hand_peaks) plt.imshow(canvas[:, :, [2, 1, 0]]) plt.axis('off') plt.show()
reference pytorch -openpose demo.py
reference pytorch -openpose demo.py