Python Forum
How to get OpenCV to display entire camera frame?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get OpenCV to display entire camera frame?
#1
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!
Reply
#2
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Make entire script run again every 45 mo NDillard 0 316 Jan-23-2024, 09:40 PM
Last Post: NDillard
  How to display <IPython.core.display.HTML object>? pythopen 3 45,898 May-06-2023, 08:14 AM
Last Post: pramod08728
  Get image from PI camera and analyze it korenron 0 1,149 Apr-28-2022, 06:49 AM
Last Post: korenron
  Reiszing figure to occupy entire frame fishbackp 0 1,369 Jan-06-2022, 10:33 PM
Last Post: fishbackp
  Create RTSP stream from camera? korenron 1 3,242 Jan-04-2022, 10:38 AM
Last Post: Larz60+
  How to apply a class method to an entire dataframe column tirtha9 1 5,119 Jan-03-2021, 04:44 AM
Last Post: klllmmm
  2d Array adds last element to entire list waiteup 2 2,068 Nov-19-2020, 08:25 PM
Last Post: bowlofred
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,220 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  Wifi Camera Connection MeenAg 2 3,081 Oct-02-2020, 06:35 PM
Last Post: MeenAg
  encrypt entire project mattc 2 2,413 Jul-21-2020, 07:05 AM
Last Post: mattc

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020