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
8 changed files
with
354 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 | ||
|
||
body_estimation = Body('model/body_pose_model.pth') | ||
hand_estimation = Hand('model/hand_pose_model.pth') | ||
|
||
test_image = 'images/demo.jpg' | ||
oriImg = cv2.imread(test_image) # B,G,R order | ||
candidate, subset = body_estimation(oriImg) | ||
# canvas = util.draw_bodypose(oriImg, candidate, subset) | ||
canvas = copy.deepcopy(oriImg) | ||
# detect hand | ||
hands_list = util.handDetect(candidate, subset, oriImg) | ||
|
||
for x, y, w, is_left in hands_list: | ||
cv2.rectangle(canvas, (x, y), (x+w, y+w), (0, 255, 0), 2, lineType=cv2.LINE_AA) | ||
cv2.putText(canvas, 'left' if is_left else 'right', (x, y), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2) | ||
|
||
if is_left: | ||
plt.imshow(oriImg[y:y+w, x:x+w, :][:, :, [2, 1, 0]]) | ||
plt.show() | ||
# peaks = hand_estimation(oriImg[y:y+w, x:x+w, :]) | ||
# canvas = util.draw_handpose(canvas, peaks, True) | ||
|
||
plt.imshow(canvas[:, :, [2, 1, 0]]) | ||
plt.show() | ||
# cv2.imwrite('t.jpg', canvas) |
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.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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