Python Numpy Hstack值错误

Python Numpy Hstack值错误,python,numpy,opencv,Python,Numpy,Opencv,我正在为俄罗斯方块编写一些颜色检测,但是当我尝试运行代码时,我得到了以下错误: Traceback (most recent call last): File "C:\Users\hampus.ramsten\Desktop\Detection - test.py", line 49, in <module> cv2.imshow("virtual_board", np.hstack([resize, output])) Fil

我正在为俄罗斯方块编写一些颜色检测,但是当我尝试运行代码时,我得到了以下错误:

Traceback (most recent call last):
  File "C:\Users\hampus.ramsten\Desktop\Detection - test.py", line 49, in <module>
    cv2.imshow("virtual_board", np.hstack([resize, output]))
  File "<__array_function__ internals>", line 5, in hstack
  File "C:\Users\hampus.ramsten\AppData\Local\Programs\Python\Python38-32\lib\site-packages\numpy\core\shape_base.py", line 346, in hstack
    return _nx.concatenate(arrs, 1)
  File "<__array_function__ internals>", line 5, in concatenate
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 168 and the array at index 1 has size 1080

问题出在哪里?

您的错误消息准确地指出了原因:

ValueError: ...
but along dimension 0
the array at index 0 has size 168 and
the array at index 1 has size 1080
错误实际上发生在np.hstack中,因为
您试图水平堆叠具有不同行数的数组。

两个输入数组的
形状
不匹配。什么是
resize.shape
output.shape
?您可能需要(重新)读取
hstack
对其输入的期望。你明白我们所说的
shape
是什么意思吗?我是个新手,所以不,那是什么?所以你使用的是其他人的代码,但使用的是你自己的数据(或一组图像)?是的,就是这样,“”和“”,我如何解决这个问题?如果你水平堆叠两个数组,那么它们的行数必须相同。也许ResizeWithAspectRatio会生成“压缩过多”的输出。另一种解决方案是,至少允许执行hstack,即在“较小的”数组中追加所需的行数,以对齐它们的行号。另一个问题是添加行的值应该是多少(我不知道,我对图像处理的知识非常有限)。
ValueError: ...
but along dimension 0
the array at index 0 has size 168 and
the array at index 1 has size 1080