Former-commit-id: 1b34dc488f5306fcb5d20746c217255bb9ead3c5
This commit is contained in:
2025-06-06 23:02:15 +08:00
parent 8184179a17
commit c1f33df66d
7 changed files with 112 additions and 49 deletions

11
test2.py Normal file
View File

@ -0,0 +1,11 @@
import cv2
import numpy as np
cap = cv2.VideoCapture(2) # 使用摄像头0通常更稳定
im = cap.read()[1]
hsv = cv2.cvtColor(im, cv2.COLOR_BGR2HSV)
h, s, v = cv2.split(hsv)
pink_mask = (((h >= 300/360) | (h <= 20/360)) & (s >= 0.15) & (v >= 0.2))
cv2.imshow("Pink Mask", im * pink_mask[:,:,np.newaxis]) # 显示掩码
cv2.waitKey(0) # 等待按键
cap.release()