pythonopencvcameraframe-rate

low fps by using cv2.VideoCapture


I have low FPB ~5, I have checked this code on different cameras logitech c270 and logitech 9000, same situation.

I completed all the tips about turn off right light etc.

import urllib.request as urllib
import cv2
import numpy as np
import time

while True:

    # Use urllib to get the image and convert into a cv2 usable format
    cap = cv2.VideoCapture(0)

    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    hiegh = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

    ret, frame = cap.read()


    # put the image on screen
    cv2.imshow('Webcam', frame)


    if cv2.waitKey(1) & 0xFF == 27:
        break

cap.release()        
cv2.destroyAllWindows()

What should I do for increasing FPS ?


Solution

  • # Use urllib to get the image and convert into a cv2 usable format
    cap = cv2.VideoCapture(0)
    
    width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
    hiegh = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
    

    Put these lines above while function.