【问题标题】:Resize frame of cv2.VideoCapture调整 cv2.VideoCapture 的帧大小
【发布时间】:2020-03-12 04:46:33
【问题描述】:

我正在尝试将原始 (480,640,3) 中的帧图像数组的大小调整为 (224,224,3),但我使用 CV_CAP_PROP_FRAME_WIDTH、CV_CAP_PROP_FRAME_HEIGHT,只改变我屏幕上显示的帧的大小。非常感谢! 我的代码在这里!

import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while(True): 
    # Capture frame-by-frame
    ret, frame = cap.read()
    frame = cv2.flip(frame, 1)

    # Display the resulting frame
    cv2.imshow('frame',frame)
    print(frame.shape)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

【问题讨论】:

  • 但是... 在哪里您实际上是在哪里调整框架的大小? oO 你不想添加类似frame = imutils.resize(frame, width=500) 的东西吗?

标签: python numpy machine-learning computer-vision cv2


【解决方案1】:

您可以在 while 循环中添加以下代码,

frame = cv2.resize(frame, (224, 224))

打印(frame.shape)

【讨论】:

  • 感谢您的帮助,它成功了,我感到非常高兴,这是我第一次在这个网站上提问
  • 感谢您的精彩回复,我很高兴能够提供帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-29
  • 1970-01-01
  • 2016-07-08
  • 2012-11-07
  • 1970-01-01
  • 2020-03-03
相关资源
最近更新 更多