日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人工智能 > pytorch >内容正文

pytorch

OpenCV3与深度学习实例-使用OpenPose进行人体姿态估算

發(fā)布時(shí)間:2025/3/17 pytorch 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OpenCV3与深度学习实例-使用OpenPose进行人体姿态估算 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??

import cv2 import time import numpy as np import matplotlib.pyplot as plt import os# Load a Caffe Modelif not os.path.isdir('model'):os.mkdir("model") protoFile = "datas/models/caffe/openpose/pose_deploy_linevec_faster_4_stages.prototxt" weightsFile = "datas/models/caffe/openpose/pose_iter_160000.caffemodel"# Specify number of points in the model nPoints = 15 POSE_PAIRS = [[0,1], [1,2], [2,3], [3,4], [1,5], [5,6], [6,7], [1,14], [14,8], [8,9], [9,10], [14,11], [11,12], [12,13] ] net = cv2.dnn.readNetFromCaffe(protoFile, weightsFile)# Read Image im = cv2.imread("datas/images/man.jpg") im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB) inWidth = im.shape[1] inHeight = im.shape[0]# Convert image to blob netInputSize = (368, 368) inpBlob = cv2.dnn.blobFromImage(im, 1.0 / 255, netInputSize, (0, 0, 0), swapRB=True, crop=False) net.setInput(inpBlob)# Run Inference (forward pass) output = net.forward()# Display probability maps plt.figure(figsize=(20,10)) plt.title('Probability Maps of Keypoints') for i in range(nPoints):probMap = output[0, i, :, :]displayMap = cv2.resize(probMap, (inWidth, inHeight), cv2.INTER_LINEAR)plt.subplot(3, 5, i+1); plt.axis('off'); plt.imshow(displayMap, cmap='jet')# Extract points# X and Y Scale scaleX = float(inWidth) / output.shape[3] scaleY = float(inHeight) / output.shape[2]# Empty list to store the detected keypoints points = []# Confidence treshold threshold = 0.1for i in range(nPoints):# Obtain probability mapprobMap = output[0, i, :, :]# Find global maxima of the probMap.minVal, prob, minLoc, point = cv2.minMaxLoc(probMap)# Scale the point to fit on the original imagex = scaleX * point[0]y = scaleY * point[1]if prob > threshold : # Add the point to the list if the probability is greater than the thresholdpoints.append((int(x), int(y)))else :points.append(None)# Display Points & SkeletonimPoints = im.copy() imSkeleton = im.copy() # Draw points for i, p in enumerate(points):cv2.circle(imPoints, p, 8, (255, 255,0), thickness=-1, lineType=cv2.FILLED)cv2.putText(imPoints, "{}".format(i), p, cv2.FONT_HERSHEY_SIMPLEX, 1, (255,0,0), 2, lineType=cv2.LINE_AA)# Draw skeleton for pair in POSE_PAIRS:partA = pair[0]partB = pair[1]if points[partA] and points[partB]:cv2.line(imSkeleton, points[partA], points[partB], (255, 255,0), 2)cv2.circle(imSkeleton, points[partA], 8, (255, 0, 0), thickness=-1, lineType=cv2.FILLED)plt.figure(figsize=(20,10)) plt.subplot(121); plt.axis('off'); plt.imshow(imPoints); #plt.title('Displaying Points') plt.subplot(122); plt.axis('off'); plt.imshow(imSkeleton); #plt.title('Displaying Skeleton') plt.show()

轉(zhuǎn)載于:https://my.oschina.net/wujux/blog/2050083

總結(jié)

以上是生活随笔為你收集整理的OpenCV3与深度学习实例-使用OpenPose进行人体姿态估算的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。