久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 OpenCV Python 中檢測紅色?

How To Detect Red Color In OpenCV Python?(如何在 OpenCV Python 中檢測紅色?)
本文介紹了如何在 OpenCV Python 中檢測紅色?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試檢測從我的網絡攝像頭拍攝的視頻中的紅色.下面給出的以下代碼示例取自 OpenCV 文檔.代碼如下:

I am trying to detect red color from the video that's being taken from my webcam. The following code example given below is taken from OpenCV Documentation. The code is given below:

import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while(1):

    # Take each frame
    _, frame = cap.read()

    # Convert BGR to HSV
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    # define range of blue color in HSV
    lower_blue = np.array([110,50,50])
    upper_blue = np.array([130,255,255])

    # Threshold the HSV image to get only blue colors
    mask = cv2.inRange(hsv, lower_blue, upper_blue)

    # Bitwise-AND mask and original image
    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()

lower_blue = np.array([110,50,50]) 具有下限 Blue HSV 值,行 upper_blue = np.array([130,255,255]) 具有更高范圍的藍色 HSV 值.我在互聯網上查找了紅色的上限值和下限值,但找不到.如果有人能說出 OpenCV 的紅色 HSV 值(OpenCV H 值范圍為 0 - 179),那將非常有幫助.非常感謝您的幫助(提前).

The line lower_blue = np.array([110,50,50]) has the lower range Blue HSV value and the line upper_blue = np.array([130,255,255]) has the higher range Blue HSV value. I have looked for the upper value and lower value of Red color on internet but I couldn't find it. It would be very helpful if anyone could tell the HSV value of Red for OpenCV (OpenCV H value ranges from 0 - 179). Thanks a lot for help (In Advance).

我也嘗試過運行以下命令來查找 Red 的范圍,但我可能無法選擇合適的值.我試過的是這個(紅色):

I have also tried running the following to find the range of Red but I was unable to pick proper value maybe. What I tried was this(for red):

>>> green = np.uint8([[[0,255,0 ]]])
>>> hsv_green = cv2.cvtColor(green,cv2.COLOR_BGR2HSV)
>>> print hsv_green
[[[ 60 255 255]]]

這也取自 OpenCV 文檔.請告訴我或幫我找到 OpenCV 的 RED COLOR 范圍.

This was also taken from OpenCV documentation. Please tell me or help me find the RANGE of RED COLOR for OpenCV.

推薦答案

對 red 運行相同的代碼似乎可行:

Running the same code for red seems to work:

>>> red = numpy.uint8([[[0,0,255]]])
>>> hsv_red = cv2.cvtColor(red,cv2.COLOR_BGR2HSV)
>>> print(hsv_red)
[[[  0 255 255]]]

然后您可以嘗試不同顏色的偏紅.請注意,紅色范圍包括略大于 0 的數字和略小于 179 的數字(例如 red = numpy.uint8([[[0,31,255]]]) 導致 [[[ 4 255 255]]]red = numpy.uint8([[[31,0,255]]]) 導致 [[[176 255 255]]]].

And then you can try different colors that appear reddish. Beware that the red range includes both numbers slightly greater than 0 and numbers slightly smaller than 179 (e.g. red = numpy.uint8([[[0,31,255]]]) results in [[[ 4 255 255]]] whereas red = numpy.uint8([[[31,0,255]]]) results in [[[176 255 255]]].

這篇關于如何在 OpenCV Python 中檢測紅色?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 国产一区二区在线免费观看 | 久久国产三级 | 午夜精品久久久久久久 | 日韩福利| 国产成人精品久久二区二区 | 久久亚洲一区 | 成人a视频片观看免费 | 日日摸日日碰夜夜爽亚洲精品蜜乳 | 精品一区国产 | 日韩免费av一区二区 | 日日人人 | 久久国产精品免费 | 极品电影院 | 亚洲高清三级 | 亚洲成人av在线播放 | 四虎永久免费地址 | 久久久.com | 奇米视频777 | 日本成人在线观看网站 | 成人欧美一区二区 | 亚洲一区二区三区四区五区中文 | 成人在线不卡 | 丝袜美腿一区 | 韩国av一区二区 | 欧美午夜影院 | 成人精品鲁一区一区二区 | 亚洲一区二区三区在线播放 | 国产在线精品一区二区三区 | 国产成人精品网站 | 中文字幕在线第一页 | 三级黄视频在线观看 | 亚洲精品视频一区二区三区 | 久久av资源网| 精品在线观看入口 | 91精品国产色综合久久 | 亚洲网在线 | 日韩欧美中文 | 777777777亚洲妇女| 欧美三级三级三级爽爽爽 | 久久美女视频 | 国产不卡视频 |