I am unexpectedly getting a very low FPS (~16 fps) while capturing from the internal webcam (1280x720 @ 30fps) of a recent Dell XPS 9560.
This is the trivial code I'm using ( python3, OpenCV 3.4.0 )
import cv2, time
cam = cv2.VideoCapture(0)
n_frames = 0
execution_time = 0
while True:
t_start = time.time()
rv, frame = cam.read()
n_frames+=1
if rv:
#also tried to comment imshow. Same FPS.
cv2.imshow('window', frame)
if cv2.waitKey(1) >= 0:
break
pass
else:
print('Cannot read Frame')
t_end = time.time()
execution_time += (t_end-t_start)*1000
if execution_time > 10000:
print ('avg FPS in 10 seconds: %.2f' % (n_frames*1000/execution_time))
n_frames = 0
execution_time = 0
I tried to write the same simple program in C++ and got the same result, the same ~16 FPS.
Occasionally, both the C++ and Python program can generate a higher FPS for a shorter amount of time.
By monitoring CPU usage with i7z, I could see that all 4 cores where running at a very low frequency, close to the minimum, for most of the time, with occasional spikes that seemed not to affect very much the average FPS.
I then transferred the exact same code to a Jetson TX1. For those who don't know it, it's an ARM-based system on a chip, running a dedicated Ubuntu 16.10. It is connected to an USB 2.0 camera, 1920x1080 @ 25fps.
Needless to say, I got exactly 25 FPS as expected.
Can anybody explain this behaviour? Is it something related to differences at operating system level?
How to get full FPS in any case?
Thanks for your help
EDIT: after VTT comment, I attached the same external (supposed 30 fps) USB camera to both systems, and I get 15 FPS on both. This points to crappy cameras/usb bus. I will need to dismantle the jetson device internal camera and connect it to the laptop to double-check this is camera-related.