2
我有一個奇怪的問題與opencv。在jupyter筆記本上工作時,我沒有任何問題,但嘗試運行此Sublime時卻遇到了問題。OpenCV錯誤:使用COLOR_BGR2GRAY函數時聲明失敗
cvtColor,file/Users/jenkins/miniconda/1/x64/conda-bld /中的OpenCV錯誤:斷言失敗(depth == CV_8U || depth == CV_16U || depth == CV_32F)工作/ OpenCV的-3.1.0 /模塊/ imgproc/src目錄/ color.cpp,線路7935
import numpy as np
import cv2
img = [[[150,160,170], [150,32, 199], [145, 212, 234], [145, 212, 234]],
[[150,190,170], [150,32, 199], [145, 212, 234], [145, 212, 234]],
[[150,160,170], [150,32, 199], [145, 212, 234], [145, 212, 234]],
[[150,160,170], [150,32, 199], [145, 212, 234], [145, 212, 234]]]
img = np.array(img)
def grayscale(x):
# plt.imshow(gray, cmap='gray')to show on screen
# turns dim from (32,32,3) to (32,32)
return cv2.cvtColor(x, cv2.COLOR_BGR2GRAY)
img2 = grayscale(img)