zoukankan      html  css  js  c++  java
  • openpose pytorch 测试

    openpose pytorch 测试

    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(2)
    cap.set(3, 640)
    cap.set(4, 480)
    while True:
        ret, oriImg = cap.read()
        #oriImg=cv2.resize(oriImg,(320,240))
        
        candidate, subset = body_estimation(oriImg)
        canvas = copy.deepcopy(oriImg)
        canvas = util.draw_bodypose2(canvas, candidate, subset)
        
        '''
        # detect hand
        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)
            all_hand_peaks.append(peaks)
    
        canvas = util.draw_handpose(canvas, all_hand_peaks)
        '''
        
        cv2.imshow('demo', canvas)#一个窗口用以显示原视频
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    
    cap.release()
    cv2.destroyAllWindows()
    QQ 3087438119
  • 相关阅读:
    JavaScript中对事件简单的理解
    正则表达式 RE模块
    模块
    面向对象进阶
    元类详细解释
    四.面向对象和函数补充
    四.函数
    Python的基础知识:
    五层协议及tcp三次握手四次挥手
    nginx常见错误
  • 原文地址:https://www.cnblogs.com/herd/p/14619213.html
Copyright © 2011-2022 走看看