小编Mic*_*22T的帖子

OpenCv Python 颜色检测

我正在尝试在 python 中使用 opencv 跟踪红色对象。这是我到目前为止的代码:

#Identify red objects in an image

#import OpenCV
import cv2
#Import numpy
import numpy as np

#open webcam
imgcap=cv2.VideoCapture(0)

while(1):

    #view the image from the webcam
    _, frame=imgcap.read()
    #convert the image to HSV
    hsv=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    #lower threshold for red
    lower_red=np.array([0, 100, 75])
    #upper threshold for red
    upper_red=np.array([5, 76, 100])

    mask=cv2.inRange(hsv, lower_red, upper_red)
Run Code Online (Sandbox Code Playgroud)

当我运行它时,出现的错误如下:

OpenCV Error: Sizes of input arguments do not match (The lower bounary is             neither an array of the same size and same …
Run Code Online (Sandbox Code Playgroud)

python opencv image colors detection

3
推荐指数
1
解决办法
7930
查看次数

标签 统计

colors ×1

detection ×1

image ×1

opencv ×1

python ×1