Python Forum

Full Version: How to get OpenCV to display entire camera frame?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using a 180 degree FOV fisheye camera for a project and am having difficulty getting OpenCV to display the entire camera frame. When I open the camera in the standard Windows camera app it shows the full 180 degree FOV, but when I use a simple script to display the camera in Python it crops a decent chunk of the image and nearly halves the FOV.

Image using Windows camera app: https://ibb.co/WFK8Jm2

Image when Python script is running: https://ibb.co/QddnWXJ

Below is the code I'm using:


import cv2

cap = cv2.VideoCapture(0)

# Check if the webcam is opened correctly
if not cap.isOpened():
raise IOError("Cannot open webcam")

while True:
ret, frame = cap.read()
frame = cv2.resize(frame, (1500,1000), fx=0, fy=0, interpolation=cv2.INTER_AREA)
cv2.imshow('Input', frame)

c = cv2.waitKey(1)
if c == 27:
break

cap.release()
cv2.destroyAllWindows()



Anyone know how to stop this auto-cropping and display the full frame? Resizing the window doesn't help. Any help would be much appreciated!
I never used cv2 with a webcam. I only use cv2 for marking multiple-choice questions.

Got the code from here.

This seems to show the whole picture, no cropping:

def camON():
    import cv2

    cap = cv2.VideoCapture(0)

    # Check if the webcam is opened correctly
    if not cap.isOpened():
        raise IOError("Cannot open webcam")

    while True:
        ret, frame = cap.read()
        # smaller window
        frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
        # bigger window
        #frame = cv2.resize(frame, None, fx=1, fy=1, interpolation=cv2.INTER_AREA)
        cv2.imshow('Input', frame)

        c = cv2.waitKey(1)
        if c == 27:
            break

    cap.release()
    cv2.destroyAllWindows()