Open camera shows correct fps but when recording the fps is different

68 views Asked by At

I have 3 Logitech brio/4k stream cameras. Until yesterday, I used them with 30 fps properly. My OS is Linux. i'm using outer application called 'guvcview' to watch the fps of the cameras on live. It means that this application open them but without recording. Yesterday my computer crashed while using it, so I forced it to restart, and since then what happens is that I record with the cameras (in Python, with the cv2 library) and the fps result looks really bad! It is also not clear what exactly is happening there, one camera outputs 45 fps while another camera 55 fps and the third one 37 let's say, the mean fps of the cameras is not steady from run to run.

  • Certainly the settings and configuration of the cameras are correct and have not changed from what was before the bug.
  • The average fps measurement in Python that I perform is sampling all the frames according to time.time and making a diff between every 2 adjacent frames and finally an average on this list.

Suppose a camera was defined like this - video = cv2.VideoWriter.. I tried to remove the 'video.write' line in the application (in Python) and run it and I really got an average fps as I expected as I had seen in advance in the external application (guvcview). And as mentioned when I return this line, in other words the frames are written to the hard disk, the average comes out bad as I explained.

This is my code : def run(self) -> None: """Thread runnable function.""" self.capture = cv2.VideoCapture(int(self.src_id)) self.capture.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')) self.capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1920); self.capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080); self.capture.set(cv2.CAP_PROP_FPS, 30)

Each camera ran in a separate thread

0

There are 0 answers