Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOW-TO] Record at 50 fps with 2 camera V3 wide angle #1031

Open
Rayanne-M opened this issue May 2, 2024 · 5 comments
Open

[HOW-TO] Record at 50 fps with 2 camera V3 wide angle #1031

Rayanne-M opened this issue May 2, 2024 · 5 comments

Comments

@Rayanne-M
Copy link

I've tried to set the framerate and change the frame duration limits but it doesn't seems to change anything. I also tried to put the resolution from 2304x1296 to 1536x864, it able me to get a higher fps but the video is cropped. When I connect a second camera v3 the fps are divided by 2 (turning around 10 fps).

Do anyone know how I could get to 50 fps with the full veiw of the wide angle ? Weirdly it seems to work when I launch the recording from the cmd using libcamera-vid

@davidplowman
Copy link
Collaborator

Hi, thanks for the question. You probably need to set the sensor mode explicitly. You don't say what OS you are using, but this should work:

from picamera2 import Picamera2

picam2 = Picamera2()
main = {'size': (1920, 1080)}
raw = {'size': (2304, 1296)}
controls = {'FrameRate': 50}
config = picam2.create_video_configuration(main, raw=raw, controls=controls)
picam2.configure(config)
picam2.start()

You don't say what kind of Pi you have, but in general only 1080p30 is guaranteed. You can normally just about achieve 1080p50 with a single camera, so long as you're not running too much else. You can't start recording with a 2nd camera without dropping frames. Also, note that 2304x1296 is too large for h264 on Pi 4s or earlier. A Pi 5 should encode that, but it is 44% more pixels than 1080p, so the maximum framerate will drop in proportion.

@Rayanne-M
Copy link
Author

Thanks for you answer ! I'm using the last version of Pi OS 64 bits on a RPi 5. I'll try that tomorrow, and I'll let you know, thanks again :)

@davidplowman
Copy link
Collaborator

Yes, I think the thing to be aware of is that you have up to about 100 MP/s of throughput. You can divide that up relatively arbitrarily between cameras, framerates and image resolution, though at some point you might find there are additional limits (e.g. really high framerates may struggle however small you make the images). It's always a case of try it and see.

On a Pi 5, always make sure you use "YUV420" format for any stream you wish to pass to the H264 encoder, as that saves an (expensive) software conversion. For best performance, avoid displaying anything, don't run too much else, and consider putting force_turbo=1 into your /boot/firmware/config.txt.

@Rayanne-M
Copy link
Author

Rayanne-M commented May 7, 2024

Thank you so much ! I managed to record at max 55 fps for a resolution of 960x540 with both camera. For context, we're recording monkeys performing on touchscreen with 2 camera (one on the side and one on the ceilling) with the aim to do an automated tracking of their hands on the screen.

Thus, we'd like to avoid blurred image I've lower the exposure time and it seemed to work. We are also trying to synchronise the camera, for now I've just calculated the time difference between the begining of the cam0 et cam1 recording and i'll cut them afterward. If you have any advice or idea to improve it, you're welcome aha.

Thanks again !

Here is a video of a monkey :)

Nekke_hesitation.mp4

@davidplowman
Copy link
Collaborator

Glad it's working, and love the video!

One small tip is that you can force lower exposures by setting the "AnalogueGain" control to a fixed value (such as 8.0). This will allow the AEC/AGC to operate at the normal brightness level, but you'll get (effectively) a high ISO image with shorter exposure times. Obviously there's an image noise trade-off here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants