Trung Dang
Trung Dang

Reputation: 55

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

Upvotes: 5

Views: 19022

Answers (1)

Vinod Sawant
Vinod Sawant

Reputation: 623

you can add following code in your while loop,

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

print(frame.shape)

Upvotes: 4

Related Questions