How to maximize frame captured by video_capture.read()

Hello, I want to resize the video image to 1/1 size instead of 1/4 to display the result on a screen.
attached part of my code


import face_recognition
import cv2

video_capture = cv2.VideoCapture(0)
frame = video_capture.read()
    # Resize frame of video to 1/1 size
    width = 500
    height = 700
    dsize = (height, width)
    small_frame = cv2.resize(frame, dsize, fx=0.25, fy=0.25)
    # Display the results
    for (top, right, bottom, left), name in zip(face_locations, face_names):
        # Scale back up face locations since the frame we detected in was scaled to 1/4 size
        top *= 4
        right *= 4
        bottom *= 4
        left *= 4
        # Draw a box around the face
        cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
        # Draw a label with a name below the face
        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
        font = cv2.FONT_HERSHEY_DUPLEX
        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)
    # Display the resulting image
    cv2.imshow('Video', frame)
    # Hit 'q' on the keyboard to quit!
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

how to make the frame take the whole window of my pc? thank you

the following screenshot explains my problem

your code is incomplete / broken , cant be reproduced, please fix !

apart from that, you probably should NOT try to resize the image, but make imshow() show it “full screen”:
add a

cv2.namedWindow("Video", cv2.WINDOW_NORMAL)

and it will resize the image automatically, once you click the full-screen button

1 Like

Hello berack,
I added the line you suggested but my problem is not solved yet.

I still have the same frame size

I was able to solve the problem thanks to God I would like to share the solution with everyone

# Display the resulting image
    cv2.namedWindow("Video", cv2.WND_PROP_FULLSCREEN)
    cv2.setWindowProperty('Video', cv2.WND_PROP_FULLSCREEN, 0)
    cv2.imshow('Video', frame)

then you didn’t add the line in the right place.

that is wrong. it only “works” because cv.WND_PROP_FULLSCREEN == 0 == cv.WINDOW_NORMAL you should have used the WINDOW_NORMAL creation flag there, as you were suggested to do. the other named constant is for setting window properties, not creation flags.

1 Like
# Display the resulting image
cv2.namedWindow("Video", cv2.WINDOW_NORMAL)
cv2.imshow('Video', frame)

You were right I was tired that’s why I didn’t pay attention to the location of the line but it works perfectly thank you again