简体   繁体   中英

face Removal using opencv-python

hi I want to detect and tracking the hand using skin color based but I don't need to see face or any skin color ( I mean i need just left hand to tracking) in output video. thanks

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()

You can train OpenCV haar cascades . It works well for face detection and should also work for hand detection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM