forked from Hzzone/pytorch-openpose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,095 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
sys.path.insert(0, 'python') | ||
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') | ||
|
||
cap = cv2.VideoCapture(0) | ||
cap.set(3, 640) | ||
cap.set(4, 480) | ||
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 = [] | ||
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() | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.