jiandingzhe
Posts: 39
Joined: Wed Jun 07, 2017 6:00 am

Can I do down sample in ISP before other post-processing?

Sun Sep 24, 2023 11:48 am

I'm trying to real-time display video from an IMX290 CSI camera using RPi3A and libcamera. Now I face with a dilemma situation:

- If I configure the camera to work at its native full resolution (1920x1080), the RPi3A's ISP is not capable with a 50 FPS stream at that high data rate. As a result, I only got a video for about 20~30 FPS.
- If I configure the camera to work at 1280x720, the RPi3A's ISP can handle that, but the image is actually cropped from the original 1920x1080, and the angle of view is much narrower than I need.

I'm wondering if there is any possibility to firstly downsample the original resolution to a lower one, before ISP took further post processing procedure, so that I can obtain both original angle of view and a higher FPS? If it is possible, how to do it via libcamera?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15326
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Can I do down sample in ISP before other post-processing?

Sun Sep 24, 2023 2:38 pm

No, the ISP is designed to consume a maximum of one input pixel per clock cycle, and produce a maximum of one output pixel per clock cycle. A downscaling is therefore limited by the source image size, and an upscaling is limited by the destination image size.

The Pi4 runs at a higher core clock frequency, so may be able to achieve your desired pixel rate. 500MHz on Pi4 vs 400MHz on Pi3.
You can overclock the ISP to some degree using "isp_freq=..." and "isp_freq_min=..." in config.txt - https://www.raspberrypi.com/documentati ... erclocking.

Note that there are overheads as the ISP processes in tile, and there is also setup time required, so these clock frequencies will not convert directly to 400MPix/s and 250MPix/s.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jiandingzhe
Posts: 39
Joined: Wed Jun 07, 2017 6:00 am

Re: Can I do down sample in ISP before other post-processing?

Wed Sep 27, 2023 1:48 am

6by9 wrote:
Sun Sep 24, 2023 2:38 pm
No, the ISP is designed to consume a maximum of one input pixel per clock cycle, and produce a maximum of one output pixel per clock cycle. A downscaling is therefore limited by the source image size, and an upscaling is limited by the destination image size.

The Pi4 runs at a higher core clock frequency, so may be able to achieve your desired pixel rate. 500MHz on Pi4 vs 400MHz on Pi3.
You can overclock the ISP to some degree using "isp_freq=..." and "isp_freq_min=..." in config.txt - https://www.raspberrypi.com/documentati ... erclocking.

Note that there are overheads as the ISP processes in tile, and there is also setup time required, so these clock frequencies will not convert directly to 400MPix/s and 250MPix/s.
Hi 6by9:

If I turn off some image processing stages, i.e. white balance or denoise, does it speed up ISP processing? Or it is always works at same speed?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15326
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Can I do down sample in ISP before other post-processing?

Wed Sep 27, 2023 6:19 am

jiandingzhe wrote:
Wed Sep 27, 2023 1:48 am
If I turn off some image processing stages, i.e. white balance or denoise, does it speed up ISP processing? Or it is always works at same speed?
The ISP pipeline always runs at the same speed as it is pipelined.
Memory says there is one denoise stage done in software. Playing about with the --denoise parameter in the libcamera-apps may speed things up a little, but again as the processing is all done in parallel it may make little difference.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32871
Joined: Sat Jul 30, 2011 7:41 pm

Re: Can I do down sample in ISP before other post-processing?

Wed Sep 27, 2023 6:35 am

Does the camera have a binned or skip mode, to get a smaller resolution straight of that, or would that be too small?
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 15326
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Can I do down sample in ISP before other post-processing?

Wed Sep 27, 2023 9:26 am

jamesh wrote:
Wed Sep 27, 2023 6:35 am
Does the camera have a binned or skip mode, to get a smaller resolution straight of that, or would that be too small?
My memory of that sensor is that it doesn't have a binned or skipped mode. It's one of the Sony Starvis sensors which seem just not to as (AIUI) they're half aimed at automotive applications.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

therealdavidp
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 977
Joined: Tue Jan 07, 2020 9:15 am

Re: Can I do down sample in ISP before other post-processing?

Wed Sep 27, 2023 9:51 am

jiandingzhe wrote:
Sun Sep 24, 2023 11:48 am
I'm trying to real-time display video from an IMX290 CSI camera using RPi3A and libcamera. Now I face with a dilemma situation:
...
Could you include the actual command or code that you're using? I also wasn't quite clear whether the problem is that a preview window isn't running at 50fps, or whether the camera isn't delivering frames at 50fps, or whether the images are being encoded and not keeping up at 50fps? Perhaps you could also confirm the maximum framerates of the various camera modes (the output of "libcamera-hello --list-cameras" will tell us), as I don't have one available to me.

You also mention the field of view changing. You can get lower resolution outputs whilst maintaining the the full field of view, though that will depend on what application or code you are running. Maybe that would help? Thanks!

jiandingzhe
Posts: 39
Joined: Wed Jun 07, 2017 6:00 am

Re: Can I do down sample in ISP before other post-processing?

Wed Sep 27, 2023 9:53 am

6by9 wrote:
Wed Sep 27, 2023 9:26 am
jamesh wrote:
Wed Sep 27, 2023 6:35 am
Does the camera have a binned or skip mode, to get a smaller resolution straight of that, or would that be too small?
My memory of that sensor is that it doesn't have a binned or skipped mode. It's one of the Sony Starvis sensors which seem just not to as (AIUI) they're half aimed at automotive applications.
Actually I'm trying to make a blind-spot monitor.
So maybe I should choose a ISP-integrated UVC camera when video processing requirement is high.

Return to “Camera board”