【发布时间】:2016-04-14 16:31:02
【问题描述】:
我正在尝试将图像从 RGB 转换为 HSV 颜色空间,这是我的一段代码:
import cv2
import numpy as np
import imutils
lower = np.array([0, 48, 80], dtype= "uint8")
upper = np.array([20, 255, 255], dtype= "uint8")
img = cv2.imread('3.JPG', 0)
img = imutils.resize(img, width = 400)
cv2.waitKey(1)
converted = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
new_skinMask = cv2.inRange(converted, lower, upper)
但我遇到了一个错误:
converted = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
错误是:
OpenCV 错误: 断言失败 ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) 在 cv::cvtColor
谁能帮我解决这个问题?
【问题讨论】:
-
您也可以发布您的错误吗?
-
我编辑了我的问题并包含了错误,感谢您指出:))
-
似乎您的输入未能通过断言。 img 应该有 3 或 4 个频道。你应该检查一下。
标签: python opencv computer-vision hsv