返回

python-如何更改媒体管道中 HandConnections 的颜色?

发布时间:2022-07-08 21:37:16 355
# node.js

我正在从一些教程中学习 MediaPipe,并注意到 HandConnection 的颜色是白色。如何将 HandConnections 的颜色从白色 ---> 绿色更改?这是我的代码:

import cv2 
import mediapipe as mp
import time

cap = cv2.VideoCapture(0)

mpHands = mp.solutions.hands
hands = mpHands.Hands(static_image_mode=False, max_num_hands=2, min_detection_confidence = 0.4, min_tracking_confidence=0.5)
# Parameters,
""" 
static_image_mode, takes a boolean value. if True, It will track at all times (Not Recommended)
max_num_hands, Takes a Ineteger. Max Hands in a Capture
min_detection_confidence, Takes a float (0 --> 1). Min Confidence for static_image_mode to operate if False (Detection)
min_tracking_confidence, Takes a float (0 --> 1). Min Confidence for static_image_mode to operate if False (Tracking)
"""

mpDraw = mp.solutions.drawing_utils

while True:
    success, img = cap.read() # Succes representing if image captured
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Changing format

    results = hands.process(imgRGB)
    # print(results)
    # print(results.multi_hand_landmarks)

    if results.multi_hand_landmarks:
        for handLms in results.multi_hand_landmarks:
                mpDraw.draw_landmarks(img, handLms, mpHands.HAND_CONNECTIONS)

    # print(success)
    cv2.imshow('Image', img)

    if cv2.waitKey(65) == ord('e'):
        break
        
cv2.destroyAllWindows() # Must
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(1)
按点赞数排序
用户头像