We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
简单的手势识别,基本思路是基于皮肤检测,皮肤的颜色在HSV颜色空间下与周围环境的区分度更高,从RGB转换到HSV颜色空间下针对皮肤颜色进行二值化,得到mask:
def HSVBin(img): hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV) lower_skin = np.array([100, 50, 0]) upper_skin = np.array([125, 255, 255]) mask = cv2.inRange(hsv, lower_skin, upper_skin) # res = cv2.bitwise_and(img, img, mask=mask) return mask
然后通过腐蚀与膨胀等形态学变化去除一些噪点,得到更完整的白色(皮肤)色块,最后找出色块的轮廓,并通过色块大小排除一些面积较小的噪点:
def getContours(img): kernel = np.ones((5,5),np.uint8) closed = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel) closed = cv2.morphologyEx(closed, cv2.MORPH_CLOSE, kernel) contours, h = cv2.findContours(closed, cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) validContours = []; for cont in contours: if cv2.contourArea(cont) > 9000: # x,y,w,h = cv2.boundingRect(cont) # if h/w > 0.75: # filter face failed validContours.append(cv2.convexHull(cont)) # rect = cv2.minAreaRect(cont) # box = cv2.cv.BoxPoints(rect) # validContours.append(np.int0(box)) return validContours
如果需要排除脸部皮肤干扰,可以同时加入人脸识别,在转换颜色空间之前将识别到的脸部位置颜色去除掉,最终运行结果如下:
完整代码
🍺🍺🍺🍺
The text was updated successfully, but these errors were encountered:
rainyear
No branches or pull requests
简单的手势识别,基本思路是基于皮肤检测,皮肤的颜色在HSV颜色空间下与周围环境的区分度更高,从RGB转换到HSV颜色空间下针对皮肤颜色进行二值化,得到mask:
然后通过腐蚀与膨胀等形态学变化去除一些噪点,得到更完整的白色(皮肤)色块,最后找出色块的轮廓,并通过色块大小排除一些面积较小的噪点:
如果需要排除脸部皮肤干扰,可以同时加入人脸识别,在转换颜色空间之前将识别到的脸部位置颜色去除掉,最终运行结果如下:
完整代码
🍺
🍺
🍺
🍺
The text was updated successfully, but these errors were encountered: