-
Notifications
You must be signed in to change notification settings - Fork 56
Enable selection of sensor format to avoid a cropped FoV #100
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
Conversation
christianrauch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Can you add a before/after comparison to this PR? This will make it more clear what the new parameter do.
The new parameters and their behaviour and interaction with the other sizes and stream roles needs documentation, if this should make it into the upstream code. I think having two sets of sizes is confusing as it is not clear from the parameter names what the effect is.
|
Have you had a look at the |
|
When you update the PR, can you rebase and squash your commits? I merged a change that avoids referring to the read-only parameters multiple times. Have a look at this and try following the same with the new read-only parameters that you want to add. |
Setting the libcamera::SensorConfiguration sensor;
sensor.outputSize = libcamera::Size(4608, 2592);
sensor.bitDepth = 10;
if (sensor.isValid())
cfg->sensorConfig = sensor;
else
throw std::runtime_error("invalid sensor configuration");before the without the need to manage an additional stream. But the size and bit depth have to match exactly for the validation to pass. |
|
Back. I would then suggest to do a parameter |
Yeah, fine with me. Can you link here where the format string is used that way? How do they incorporate the other parameters, such as An alternative would be to have the parameters
You just have to know the valid values for each of the parameter, since there is no automatic adjustment. And it is not so obvious where to get this information from. I think it would be nice to show the valid values on the screen, similar to what |
|
Unfortunately SensorConfiguration is not an option for ROS Humble, as ros-humble-libcamera is version 0.1.0; see https://github.com/raspberrypi/libcamera/blob/v0.1.0/include/libcamera/camera.h, where SensorConfiguration is missing. (It seems to be included in some RPi specific patches, otherwise starting in v0.2.0. |
Looking at picamera2 -- doing generateConfiguration is what they do: |
Either we make this an libcamrea >= 0.2 only feature or we just leave libcamea 0.1 and ROS humble support for bloom packages behind. libcamera has high requirements on the meson version, the build farm only allows using system packages for build tool, and the RHEL 8 support here is the lower bound of the meson support we have to deal with on the build farm. Options:
I am in favour of disabling that feature and its parameters at compile time via |
|
Btw, if this changes the FoV independently of the output resoltion, that property has to be encoded in the calibration file name. Currently, the calibration file name is a concatenation of the model (property |
Then let's do the same. When the selected |
A third option is obviously to have two different implementations; using SensorConfiguration for higher versions of LibCamera, and the RAW stream for lower versions. It will be a bit of 'ifdef' spaghetti though. My personal need is to have support for Ubuntu 22.04 (meaning ROS Humble), Compute Module 4 and Camera Module v2; where for some reason legacy support is no longer working, so I would need something compatible with that (or else I would have to maintain a fork, which I don't want to do. |
I am not a fan of having two paths to the same function. That's just a additional maintainance burden. If a solution works for both ROS / libcamera versions, I would rather only maintain that one solution.
I see. If you cannot use the newer version and are the one goint to implement this, then you are leaving me no choice but to accept your implementation :-) With "legacy support" do you mean support for the legacy camera stack? This isn't supported on any platform with newer Raspberry Pi OS any more. May I ask why you cannot use Ubuntu 24.04 on the Raspberry Pi Compute Module 4? Is compiling from source also not an option for you? |
|
On second thought, if you are using the Camera Module v2 on Ubuntu, I assume you are already compiling libcamera from source. Or does the binary bloomed libcamera package in the ROS repo support the Camera Module v2? If you already compile libcamera from source, doing the same for the node should not be a problem. |
Yes. For some obscure reason the RPi4 / Ubuntu 22.04 combo supports Legacy Camera, so I can activate that and grab the pictures using a basic camera package provided by AWS. As we want to reduce the footprint of the solution we also want to support the CM4 with a custom carrier board, and for some strange reason Legacy Camera is not working with the CM4. I thought I had a solution when I found camera_ros, only to see that libcamera ends up cropping the picture...
We are looking to support that, as support for RPi5, CM5 and other cameras is desirable as well, but we have quite a bit of OS-level integration (network configuration, USB-OTG etc.) that will require work.
I suggest to do the following:
|
Ok. I will look at how |
|
More dependency complexity;
Getting the latter combination to work indeed requires custom build of libcamera, off the Raspberry Pi fork. Could you point me to where the building of the ros-*-libcamera happens? Some adjustments would probably be required there to make things work out of the box. |
90c2dec to
fc212f4
Compare
You are probably aware of the different "libcamera variants". The package in the ROS repo is built from the official upstream version at https://git.libcamera.org/libcamera/libcamera.git. But the development of the Raspberry Pi support happens in the @raspberrypi fork at https://github.com/raspberrypi/libcamera. That support is supposed to be merged into the upstream at some point, but this process seems to take a long time. See for example the patch series "Raspberry Pi: Add support for Pi 5 (PiSP)" by @naushir, which is still under review. That means that the upstream repo, and hence the bloomed package, usually only supports older Raspberry Pi models and camera modules.
That package is "bloomed" using ros-infrastructure/bloom#691 directly on the upstream repo. This generates a Debian package specification, stores it in the release repo at https://github.com/ros2-gbp/libcamera-release, and then the ROS build farm is generating the binary package from this specification. You can also use bloom locally to generate and build the Debian package: https://docs.ros.org/en/jazzy/How-To-Guides/Building-a-Custom-Deb-Package.html. But if you want Raspberry Pi 5 support out-of-the-box in the upstream repo and hence the ROS repo, you should nag @naushir to get the Raspberry Pi 5 patches merged upstream :-) |
Thanks for the references. I will have a look. Once I get serious about doing Jazzy + Pi 5 support I might just build a drop-in replacement package for ros-jazzy-libcamera and put it in our APT repository together with our other patched community work for DeepRacer. |
christianrauch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work. I am OK with the general idea and its implementation via the raw stream configuration. But there are still some ways to optimise the code to make this better maintainable in the future.
|
Updated as per request - left it for you to resolve the comments |
christianrauch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there. I just left comments about the wording in the documentation and the use of roles.front(). Also, can you squash and rebase your commits? I would like to keep the git history clean of "fixup" commits.
12a1c94 to
cb19959
Compare
|
All comments built in. Rebased (I normally do it via the built-in GitHub functionality when merging, this is why I did not do it manually). Final open question is #100 (comment) |
christianrauch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In get_sensor_format, we have to either handle all the exceptions and give meaningful messages to the users, or not handle them and let the process quit with the default message of that unhandled exception.
|
Looks good now. Thanks a lot. |
Work to resolve #99
It enables the raw role, and adjusts the size of it to match the desired input, this avoids cropping where libcamera by default selects a sensor mode that is not having the full FoV. This is a problem with RPi Camera V2 (see https://picamera.readthedocs.io/en/release-1.13/fov.html#sensor-modes).
Example:
Output: