嗨我想使用基于肤色的颜色来检测和跟踪手部,但我不需要在输出视频中看到脸部或任何肤色(我的意思是我只需要左手跟踪)。 感谢
import cv2
import numpy as np
# Range for finding skin color in YCrCb
Low_YCrCb = np.array([0,125,80],np.uint8)
High_YCrCb = np.array([255,169,133],np.uint8)
while True
# grab frames from Video
_, img = videoFrame.read()
# Convert to YCrCb --
img_YCrCb = cv2.cvtColor(img, cv2.COLOR_BGR2YCR_CB)
# Find ROI in YCrCb
skin_ROI = cv2.inRange(img_YCrCb, Low_YCrCb, High_YCrCb)
# Find contour in skin region
_, contours, _= cv2.findContours(skinROI, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
# Draw the contour --
for i, cnt in enumerate(contours):
area = cv2.contourArea(cnt)
if area > 500:
cv2.drawContours(img, contours, i, (255, 0, 0), 2)
# Results
cv2.imshow('Result',img)
cv2.waitKey(0)
cv2.destroyWindow('Result')
videoFrame.release()