Libcamera v0.0.1
git.libcamera.org
git.libcamera.org
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.
If you need to use a camera that's supported by libcamera, but not natively by v4l2, and prefer to use the v4l2 API, then libcamera's v4l2 compatability layer will let you do that.
But it seems the goals of libcamera are quite different than v4l2. v4l2 (which I used to use years ago) seems more about supporting the minimum common feature set of cameras - basic video streaming, while libcamera appears more about supporting the greatest common feature set - with CPU implementation of features where necessary (hence the Mesa comparison).
The compatibility layer simply makes applications which use video4linux in the "find the /dev/videoX device and throw ioctls at it" way work even with cameras which are much more complicated to set up and configure. But it just replaces one usage pattern of the video4linux kernel interface with a different, more complex usage pattern of the video4linux kernel interface (and the media controller kernel interface) + potential userspace processing.
So libcamera is absolutely "on top of" video4linux is my point.
[1] https://www.kernel.org/doc/html/latest/userspace-api/media/i...
I hadn't heard of libcamera until reading this story/thread, and it seems to provide useful functionality, so I'm trying to understand the amount of apparent hostility there seems to be towards it.. saying it should be part of v4l2. It certainly seems to provide added functionality "over and above" v4l2, and makes sense if it uses v4l2 for lower level camera access, although from a user perspective that really makes no difference.
But in the embedded/phone world, and with some recent laptops, this can't work. There is simply no single device which is "the" camera. The camera system is a complex pipeline of different image processing nodes. Here's how the graph looks on the hardware I usually work with: https://i.imgur.com/NSmu4Tj.png. The actual camera is the ov5645 node at the top, but that's not really useful in itself. You need to configure the media graph; in this case, I have set it up as ov5645 -> csiphy1 -> csid1 -> ispif1 -> vfe0_pix, and finally, /dev/video3 is a video4linux device (as opposed to a "subdev", which the others are) which an application can interact with using the video4linux IOCTLs. And importantly, you can't configure things like resolution, cropping, etc. on /dev/video3; you have to use the media control API to configure the ov5645 node's resolution, then you can additionally configure scaling and cropping and other forms of image processing on the vfe0_pix node. If you want to access your frames without doing any processing, you can instead link up the ispif1 node to a vfe0_rdiX node (RDI = Raw Dump Interface). My graph is relatively simple because only the vfe0_pix node does actual configurable image processing, but there's no reason the hardware couldn't be structured in a way where different nodes do different kinds of processing.
This is the stuff libcamera understands, and the stuff which normal "open a /dev/videoX device and throw ioctls at it" style application doesn't understand. The goal is for libcamera to figure out what graph it has to build to do what you want, to figure out what image processing operations are available at your various nodes, maybe apply various post-processing steps such as debayering if that's not handled by the image processing hardware, etc.
So the value of the compatibility layer is that an application which expects to just care about a /dev/videoX device can have its API calls intercepted, and libcamera will basically try to make it look to the application as if it's talking to a simple device where framerate/resolution/pixel format control/post processing/etc is all handled by the /dev/videoX device. In the background, libcamera will build the media graph, configure the graph nodes, do post processing, and whatever else is necessary to make the camera work. It basically makes a complex camera system look to the application as if it is a simple USB webcam.
I hope some of this makes the problem that's being solved here a bit more clear.
As to why people are hostile to it, I'd just chock that up to the general culture in Hacker News being of making fun of and demeaning other people's work, especially when they don't understand it.
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
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.
Says the person blaming the creators for their name.
Searching for "lib camera", "libcamera", or "camera lib" returns this project as the top result.
"Apple" does not return the fruit in the top results, but I wouldn't say it's a good name for a new project in 2022. Same for "word", I wouldn't advise you call your project like this, even if the top results are "Microsoft Word" and nothing related to the actual meaning of the word.
I come from an industry where everyone uses the same prefixes/suffixes (related to the industry) together with names that "mean something". As a result, it's never really unique, and the only way to differentiate them is to always name them together with the company name. There is one in particular where the company name says what their product does, and it is similar to another product. For that one I _always_ need to Google it and go check the geographical location of both companies, because that's how I differentiate them: the names (and in this case the company name) do not help me.
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.
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".
People complaining about influence of the name of a project on its success should publish unbiased statistics to base their arguments on.
- 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?)