# -*- coding: utf-8 -*
import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while True:
    _ , frame = cap.read()
    hsv = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
    lower_red = np.array([150,150,50])#在此调参
    upper_red = np.array([180,255,255])

    dark_red = np.uint8([[[12,22,121]]])
    dark_red = cv2.cvtColor(dark_red,cv2.COLOR_BGR2HSV)

    mask = cv2.inRange(hsv,lower_red,upper_red)
    res = cv2.bitwise_and(frame,frame,mask=mask)

    cv2.imshow('frame',frame)
    cv2.imshow('mask', mask)
    cv2.imshow('res', res)
    k = cv2.waitKey(5) & 0xff
    if k == 27:
        break

cv2.destroyAllWindows()
cap.release()

opencv颜色提取color filting

把红色提取了出来,有点模糊

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2021-12-19
  • 2021-11-23
  • 2022-02-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-14
  • 2022-12-23
  • 2021-08-16
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
相关资源
相似解决方案