简体   繁体   中英

Resize frame of cv2.VideoCapture

I'm trying to resize frame image-array in original (480,640,3) to (224,224,3), but I use CV_CAP_PROP_FRAME_WIDTH, CV_CAP_PROP_FRAME_HEIGHT, only change size of frame that displayed on my screen. Thank you very much! My code here!

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()

you can add following code in your while loop,

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

print(frame.shape)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM