Я получаю приведенную ниже ошибку для следующего кода, чтобы обнаружить определенный цвет - PullRequest
0 голосов
/ 21 мая 2018
import cv2
import numpy as np 


# Load our input image
image = cv2.imread('./images/domino.png')
cv2.imshow('Original',image)

# We use cvtColor, to convert to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

#Getting the original image dimension
height,width= gray.shape[:2]

#Creating a threshold image with same size as that of original image
threshold = np.zeros((height,width,3), np.uint8)

#BGR Threshold value 
Min=np.array([255,255,255],dtype = "uint8")
Max=np.array([255,255,255],dtype = "uint8")

#Creating the output image on the basis of RGB thresholds   
threshold = cv2.inRange(gray,Min,Max)

#Displaying the output image
cv2.imshow('Threshold', threshold)

#Saving the output image 
cv2.imwrite('output.jpg', threshold)

cv2.waitKey(0)
cv2.destroyAllWindows()

Привет! Я пытаюсь замаскировать определенное значение BGR на изображении, но получаю приведенную ниже ошибку для приведенного выше кода.

Ошибка Traceback (последний вызов был последним)in () 25 # Создание выходного изображения на основе порогов RGB 26 ---> 27 threshold = cv2.inRange (серый, минимальный, максимальный) 28 29

ошибка: ........ \ opencv \ modules \ core \ src \ arithm.cpp: 2703: ошибка: (-209) Нижняя граница не является ни массивом того же размера и того же типа, что и src, ни скаляром в функции cv :: inRange

...