import cv2
import matplotlib.pyplot as plt
import copy
import numpy as np
import torch
from src import model
from src import util
from src.body import Body
from src.hand import Hand
body_estimation = Body('model/body_pose_model.pth')
hand_estimation = Hand('model/hand_pose_model.pth')
#print(f"Torch device: {torch.cuda.get_device_name()}")
cap = cv2.VideoCapture("A.mp4")#原视频
# fourcc=cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
# out=cv2.VideoWriter("D:\pytorch-openpose-master\trying pictures\1.mp4",fourcc,20,(640,480))
cap.set(30, 640)
cap.set(40, 480)
i = 0
while True:
ret, oriImg = cap.read()
candidate, subset = body_estimation(oriImg)
canvas = copy.deepcopy(oriImg)
canvas = util.draw_bodypose(canvas, candidate, subset)
# detect hand
hands_list = util.handDetect(candidate, subset, oriImg)
all_hand_peaks
torch版的openpose的应用,外加调侃。
于 2022-07-31 10:35:46 首次发布