久久久久久久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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 成人高潮片免费视频欧美 | 亚洲精品视频在线看 | 丁香久久 | 国内精品久久久久久 | 国产日韩欧美中文 | 在线欧美亚洲 | 精品国产一区二区三区久久久久久 | 亚洲免费久久久 | 在线看h | 黄色网址在线免费观看 | 我想看国产一级毛片 | 亚洲天堂影院 | 人人做人人澡人人爽欧美 | 久久久久久久久久久久久9999 | 国产高清视频一区二区 | 欧美三级久久久 | 欧州一区二区三区 | 羞羞色视频 | 日韩视频―中文字幕 | 日韩精品一区二区三区中文在线 | 日本高清视频在线播放 | 91精品国产综合久久久久久首页 | 欧美精品一区二区三区视频 | 仙人掌旅馆在线观看 | 日韩 欧美 二区 | 日日草夜夜草 | 国产精品日韩欧美一区二区三区 | 国产1区2区在线观看 | 久久精品16 | 精品久久久久久久 | 国产不卡在线观看 | 欧美精品福利 | 欧美激情视频一区二区三区免费 | 国产亚洲一区二区三区在线 | 日韩精品999 | 久久成人免费 | 亚洲高清一区二区三区 | 欧美一区二区三区视频在线 | 欧美成人精品激情在线观看 | 九九免费在线视频 | 欧美日韩精品区 |