215 points · by hasheddan · 4y ago · 78 comments
For example v4l2 has an ioctl to send raw read/write commands to a camera module. Having a datasheet one can then check which registers do what and one can set various features, but this requires using different registers and values for different camera modules.
Then we have ISP controls that v4l2 doesn't touch at all and to let's say change color correction, or automatic gain or autofocus one has to use (usually proprietary) tools from the Soc manufacturer. Some of those tools are open source and very powerful (on rockchip for example), but still developing apps one has to use a completely different method to adjust a rockchip's ISP vs let's say raspberry pi's.
So libcamera is a great idea to abstract all those hardware interfaces. Last time I checked they supported raspberry pi, and had a very minimal rockchip support.
Imagine there is a time when libcamera supports all kinds of Soc ISPs (rockchip, broadcom, allwinner, hisilicon and many others). Traditionally getting a directly connected camera to work (under mainline Linux) has been quite difficult on various embedded devices. Then getting hardware encoding to work is the second hurdle. Most often manufacturers distribute sdk's with their proprietary binary blobs built against ancient Linux kernels and one has to live with it if one wants to reuse various cheap Ip camera boards.
That touches a nerve. I worked on an embedded system which used one of these camera modules and the datasheet was probably accurate at some point in time during the development of the module, but clearly as the module was developed the data sheet did not keep up. Eventually it was necessary to employ a bus sniffer to capture all traffic between a demonstration kit and module and reproduce the streams byte for byte to get the camera to do what was needed. It was clear from the streams that the demonstration code was using device registers not described in the data sheet.
I suppose that a big customer for the module (such as a cell phone manufacturer) would get access to an engineer who could provide the necessary information, but that was not us.
> ... has been quite difficult on various embedded devices.
Agreed.
When v4l2 came out, the main target were TV cards (analog TV cards, digital / satellite / cable TV was just starting for most western countries) and video capture cards. We did have webcams, but they were rare, basic, and only worked properly in movies. The top resolution was 640×480. I'd know, I had one of the best models back then, Creative Go Plus!
I've supported v4l2 across a few flamewars. In Windows back then you needed a closed source driver with a proprietary API for each TV card. It was impossible for a 3rd party application to support more than a few cards and usually you would only be able to use the software that came with the card. For Linux, if your hardware was supported, a common API was exposed. Thus any 3rd party application could take advantage of any TV card. This is why projects like MythTV were made possible and accessible to many.
Alas, I can see why a system designed over 20 years earlier, might not fit the needs for modern cameras and computational photography.
We have seen so many changes in these 20 years, that having a new library to interface with camera sensors, hardly seems something to fret over. ;)
Products of the era would provide 30fps at 176x144, over the parallel port [1].
https://linuxtv.org/wiki/index.php/Brooktree_Bt848
https://www.linuxtv.org/wiki/index.php/Bttv_devices_(bt848,_...
For example, almost everything in this graph is green, except for the camera column:
https://wiki.postmarketos.org/wiki/Devices
It's a complicated problem:
https://blog.brixit.nl/pinephone-camera-part-2/
But, in a world where open source almost always exceeds the commercial offerings, I'm surprised this is the case. It seems like the parent article and the LWN article posted (https://lwn.net/Articles/904776/) are suggesting that the trend is to just dump raw data and let software process it. I'm doubly surprised there aren't good libraries in the open source world that do this so much better than the commercial ones.
This is the main reason I feel stuck inside the duopoly of Android (barely tolerable and hostile) and iOS (completely unusable and unhackable). I need a good camera on my phone and there aren't good options for that at all.
Maybe extracting this code outside of gstreamer is a good idea if this takes us closer to that goal.
FOSS smartphones such as the Pinephone would then need a whole bunch of accelerators to perform such computations because the general purpose CPU would be too slow for that, and image could take seconds to finish processing and get saved in the gallery. But at that point Pinephone itself would not have enough expertise for such a design and everything would crumble.
This is an area where FLOSS has an opportunity to shine. I think many of these algorithms are described in scientific papers and considering FLOSS is much more collaboration-prone, I'd really expect the best algorithms (except for the ones that require much training data) to soon be implemented. An example of a success case: AV1.
>An open source camera stack and framework for Linux, Android, and ChromeOS
Slides: https://elinux.org/images/6/60/Application_support_with_libc...
tl;dr: many OEM vendors are moving toward creating "dumber" cameras, with the hardware just exporting a raw data stream and all the image processing logic is done in software. The existing v4l2 stack in Linux is limited and not ready for such a change; also it would be unpractical to put all this new logic, often proprietary and with restrictive patents, into the kernel.
Quoting Laurent Pinchart referenced in the article:
> "Given the direction the industry is taking, this situation will become increasingly common in the future. With the notable exception of Raspberry Pi who is leading the way in open-source camera support, no SoC vendor is willing today to open their imaging algorithms."
So it's WinModem [0] time again, but with AndCam?
I wouldn't be surprised if we'll have the same situation again, with some laptop cameras that just won't work at all under Linux.
weird, I understood it the total opposite - with vendors shipping more and more sophisticated solutions with embedded dedicated processors doing everything inside a black box (IPU6). You dont get ANY access to raw data stream, and no access at all if you cant talk to those black boxes.
From the faq: "We see libcamera as a continuation of V4L2." Ok, why not just contine v4l2?
Or why not work with gstreamer?
And they already work with gsteramer. Libcamera provides a gstreamer plug-in. But because libcamera is also a separate library, people who don't want to add all of gstreamer as a dependency can still get the benefits.
I'd love it if people who are more involved could correct me if anything I said is inaccurate.
Libcamera is a glue framework between proprietary IPA-packaged code and v4l2 subsystem. Many of the tasks you'd want to use libcamera for are outside the scope of v4l2.
API glue: https://libcamera.org/api-html/namespacelibcamera.html
The empty-set / no-code state is what the project starts with and it has no versioning as it is inherited by all projects.
And then 0.0.1 is a change that introduces no backwards incompatibilities.
But we are slicing the cheese pretty thin at this point.
And this could not have come up on HN at a better time. Just a few days ago I bought my first ever new laptop (!) for research, an X1 Nano Gen2. I've been a Linux user on old Thinkpads my entire life so I naively bought this hardware on a lark because it filled a very specific niche for me. I zfs sent my OS from my old Thinkpad and tweaked a few things and everything worked phenomenally well. Then I went to try out the fancy webcam... I still haven't managed to get the mish-mash of code they offer to work for the Nano2 OV2740 camera sensor that's being read through Intel's new Alder Lake integrated "IPU", although some people have had more success on Dells [2]. Which is sad given how necessary a webcam is these days.
In the spirit of hackernews, if anyone can point me in the right direction for getting the camera working. I'm all ears. Currently the module/firmware refuses to load after compiling the six different libraries necessary for support. I've been working on getting enough information together to open an issue on the github [3]
[1] https://www.spinics.net/lists/kernel/msg4467429.html
> a camera stack that is open-source-friendly while still protecting vendor core IP
What is a "camera stack"?
A software library (perhaps with some binary modules)? Or does it extend to hardware as well? Like some sort of spec "here's what each IO PIN number should do".
Also, what type of cameras are we talking about? Is this for built-in cameras on embedded devices (such as phones or laptops)? Is this for people connecting their reflex camera through USB in order to download their high quality pictures? For all of them?
The Raspberry Pi Foundation replaced the MMAL (another camera framework) stack with a libcamera stack.
https://www.raspberrypi.com/news/an-open-source-camera-stack...
Besides, make alone can't do the things that they're using meson for. They'd need at least a configure script, or autotools. Meson is preferable to that.
Anyway, good idea of a project !
Anyone understands the difference with Apertus AXIOM ? https://www.apertus.org/fr/en
Searching for "lib camera", "libcamera", or "camera lib" returns this project as the top result.
It's also not just FOSS, Apple for instance has many ThingKits(HealthKit, UIKit) but also TextEdit.
“Fanciful” names don’t squat on valuable namespace and allow different approaches to duke it out without one of them getting the advantage of sounding like the “official” one.
I do concede that all else being equal people will gravitate towards the more "official" sounding library, but if all else's equal, it's not really an issue.
Choices like libname2, libname3, libname-ng and plenty of others have been used by projects before.
If anything the poor state of search on the internet is a problem.
People complaining about influence of the name of a project on its success should publish unbiased statistics to base their arguments on.
The only place where this convenience fails is for google searches.
"Is Calendar the one I just installed, or is it the one Apple is forcing me to use?"
"Wait, so there is an app called Mail that I cannot remove, but my e-mail app is called Thunderbird? Let me note that."
1) People will learn the name of the apps they use, it's not that hard 2) Not all browsers can be called "browser".
- libpipi (why such a boring name for a library that I'm guessing helps you take a piss?)
- libcaca (why such a boring name for a library that helps you take a shit?)
- Thunar (what an utterly uninspired name for software that 100% accurately behaves like a Norse god)
- Flameshot (Another fire shooting application with a boring name)
- Zathura (I hate that from the name alone I can tell that I'm gonna be pulled into an intergalactic space adventure. Why not something random?)
You identified a problem with ALL names. If someone developing a new library in the same general area (library for cameras) chops three letters off the end of an existing library to name their project, that is the second project's fault, not the first project's.