Python -:';的操作数类型不受支持;列表';和';int';

Python -:';的操作数类型不受支持;列表';和';int';,python,numpy,opencv,vector,cv2,Python,Numpy,Opencv,Vector,Cv2,我提取特征并将它们作为向量传递给训练分类器。我得到了这个错误: unsupported operand type(s) for -: 'list' and 'int'` 我理解错误,但我似乎不知道我做错了什么,有什么帮助吗 def featurestest (img): # corners gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) corners = cv2.goodFeaturesToTrack(gray, 25,

我提取特征并将它们作为向量传递给训练分类器。我得到了这个错误:

unsupported operand type(s) for -: 'list' and 'int'` 
我理解错误,但我似乎不知道我做错了什么,有什么帮助吗

def featurestest (img):
    # corners
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    corners = cv2.goodFeaturesToTrack(gray, 25, 0.01, 10)
    corners = np.int0(corners)

    for i in corners:
        x, y = i.ravel()
        cv2.circle(img, (x, y), 3, 255, -1)

    # edges
    edges = cv2.Canny(gray, 10, 100, apertureSize=3)
    minLineLength = 50
    lines = cv2.HoughLinesP(image=edges, rho=1, theta=np.pi / 180, threshold=100, lines=np.array([]),
                            minLineLength=minLineLength, maxLineGap=80)

    a, b, c = lines.shape
    for i in range(a):
        cv2.line(gray, (lines[i][0][0], lines[i][0][1]), (lines[i][0][2], lines[i][0][3]), (0, 0, 255), 3, cv2.LINE_AA)
    # print(lines, edges)

    # aspect ratio
    ar = 1.0 * float(img.shape[1] / img.shape[0])

    # skew and kurtosis

    skew = scipy.stats.skew(img)
    kurt = scipy.stats.kurtosis(img)

    for i in range(0, img.shape[0]):
        for j in range(0, img.shape[1]):

         vector_val = np.arange([lines,edges, ar, x, y, skew,kurt])
         return_raf= (vector_val)

    return return_raf
线路

vector_val = np.arange([lines, edges, ar, x, y, skew, kurt])
这是错误的。我不确定您想做什么,但是
np.arange
会选择开始、停止和步长,并返回该范围内的一个等距数字数组。您将给它一个列表作为其第一个参数,这是一个类型错误


出现实际错误消息是因为
np.arange
内部正在通过执行类似
(停止-启动)/step
的操作来计算其范围<代码>停止在本例中是您提供给它的列表,
开始
默认为0。所以它在做
[线,边,ar,x,y,skew,kurt]-0
,这在这里引起了确切的
类型错误。

我添加了np.arange,因为它是将向量转换为numpy数组的解决方案之一,还有其他方法吗?如果您想将该列表转换为向量,请使用
np.array