OpenCV Image Resize翻转尺寸?

ade*_*ter 12 python opencv

我正在尝试使用Python OpenCV绑定(CV2,新绑定)缩小图像:

ret, frame = cap.read()
print frame.shape
# prints (720, 1280, 3)
smallsize = (146,260)

smallframe = cv2.resize(frame, smallsize)
print smallframe.shape
# prints (260, 146, 3)
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,尺寸最终会在缩小的图像上翻转.而不是返回尺寸为(WxH)146x260的图像,而是获得260x146.

是什么赋予了?

Kob*_*ohn 22

这很久以前就被回答了,但从未被接受.让我为那些对此感到困惑的其他人解释一下.问题是在python中,OpenCV使用numpy.Numpy数组形状,函数等假设(高度,宽度),而OpenCV函数,方法等使用(宽度,高度).你只需要注意.

摘要:

  • cv2.anything() - >使用 (width, height)
  • image.anything() - >使用 (height, width)
  • numpy.anything() - >使用 (height, width)