Hi all.
I’m working on a project to build an independent camera system based on an old CCD 1080p GigE camera module, a Pi5 and a battery. The camera is a Basler Aviator that I’ve been testing on a windows computer and it’s working great, but yesterday I tried connecting it to the Pi and even though the Basler software works and the camera delivers around 26fps (enough for me), the whole system slows down a lot when I’m showing the live feed. The mouse stutters, there’s at least a 0.5 sec delay in the video and the moment I try to do something else, the camera starts skipping frames and showing black areas in the feed.
It’s just a 1080p feed and it’s not even 60fps. The Pi should be able to handle it without much trouble. I tried setting the MTU to 9000 and it’s even worse. What can I do about it?
Thanks!
EDIT:
Ok, turns out I was activating the jumbo frames but the camera was still sending the small packets. Once I set it to 9000 on the camera as well, everything improved. Here's what I've done so far:
sudo ifconfig eth0 mtu 9000
sudo ethtool -G eth0 rx 4096 tx 4096
And I'm supposed to do this as well:
sudo ethtool -C ethX adaptive-rx off adaptive-tx off rx-usecs 62 tx-usecs 62
But the PI gives me an error.
With the two first lines I get consistent 24fps without dropped frames (maybe one or two every few minutes) and the lag showing the video feed on screen is slightly better, but still present. Also, when I move the mouse on top of the video window, framerate goes down to 3-4fps.
Anything else I can do?
Thanks again!
EDIT 2:
I managed to get consistent 24fps with almost no lag at all. In fact, my iphone camera has more lag than my current setup. I just needed to bypass the part of the code where I converted the grabbed image to an OpenCV format. Using the stream straight from the camera really sped things up. Now I'm struggling again because I can either show the stream at full speed and full screen or save the images to disk, but not both at the same time. If I try to do it, the fps counter goes down hard. I'm currently trying to build a multithread approach. One thread for the visuals and the other for saving, but it's giving me timer/sync issues. It says the timer can't be stopped from another thread. Any ideas?
THANKS!
EDIT 3:
I managed to find a middle ground by adding all images to a buffer while shooting, then saving each one after I'm done. It's not a very elegant solution and I'd like to find a way to start saving asynchronously before I cut, but at least right now the camera is working as it should.