0

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.

benelgiac
  • 941
  • 6
  • 10
  • 2
    How about attaching the same USB 2.0 camera to Dell XPS 9560 and checking results? Maybe the problem is crappy internal camera? – user7860670 May 23 '18 at 08:59
  • Mhh that is an idea... I had attached a Logitech USB external camera, just to try another one, and still getting the same results. But, yeah, it could be crappy as well! Going to try even though it's not easy, I have to dismantle the jetson-based device, the camer is internally mounted... It'll probably be quicker to attach the external logitech to the jetson device. If that is fast, I have reproduced the problem with the logitech camera. – benelgiac May 23 '18 at 10:07
  • Ehi, just tried that: same logitech C525 camera, attached on the laptop and on the jetson, and despite being a 30fps camera (nominally, by v4l2-ctl), I capture at 15 fps on both systems! Now, I really need to attach the internal jetson camera to the laptop! – benelgiac May 23 '18 at 10:14

1 Answers1

0

I dropped this problem out of frustration only to discover its answer some days ago while I was chasing another one... I just had to turn on the lights to find the answer!

It turns out that my camera automatically lowers its FPS when in poor light condition. When you think about it, it may surely happen when the exposure time needs to be longer than the 1/30s.

So, in the end it looks like the 30fps should be intended as "Maximum fps=30". But it can and will be lower than that. Very annoying in my opinion, too bad I had to learn it the hard way.

benelgiac
  • 941
  • 6
  • 10