pi-camera-connect
pi-camera-connect copied to clipboard
Does this support libcamera?
The link in the documentation points to a page on Raspberry Pi's official site saying only libcamera is supported in the latest Raspbian.
Does this library support libcamera?
Also does it support camera with lights? I.e. turn the lights on and off?
I am interested to learn the answer to this question too.
@gurmukhp I apologize for such a late reply to your question and @reselbob thanks for the bump. Currently this library does not support libcamera
, but now that the old Raspicam stack is deprecated and libcamera
is installed by default, we certainly need to update pi-camera-connect
to use this instead.
pi-camera-connect
works by calling raspistill
and raspivid
as sub-processes and piping the camera data directly into Node. I see that Raspberry Pi has developed libcamera-apps
which includes libcamera-still
and libcamera-vid
. Based on my research so far (without actually testing), it appears these apps were designed to be very similar to the old raspistill
and raspivid
. Assuming that is the case, there shouldn't be a huge level of effort to convert pi-camera-connect
to use libcamera
instead. The majority of work will be regression testing to ensure everything we currently support still works with libcamera
.
Is this something you guys would be interested in seeing?
@gurmukhp With regard to lights, this library does not currently support turning lights on and off as up until now the raspistill
/raspivid
APIs did not support that (to my knowledge). I'd love to learn more about this though - is there a certain camera board you are using that has LEDs? How would you trigger them normally?
I've tried to run first test in stream-camera.test file after replacing raspivid with libcamera-vid but it looks like output format has changed
At least that's what I'm thinking of why the test fails because I haven't seen raw raspivid out :) Also it isn't closing the stream properly because of the errors and all of the subsequent tests are failing.
I'll try to further investigate the changes and maybe open a PR if I succeed with accounting for all of the changes (or at least video ones, because that's the main purpose for rpi that I have in my mind)
UPD: I've edited this line in stream-camera.ts as below and example 5s video capture from readme works fine
this.childProcess.stderr.on('data', data => {
const str = data.toString()
if(str.includes('ERROR')) this.emit('error', new Error(str))
});
I've tried to run tests but with no success, libcamera-vid doesn't seem to support multiple streams:
any updates on this?
For my case, I've tried just replacing raspivid call to libcamera-vid and it mostly works. The only thing I had to change was the jpeg signature on StreamCamera
to just 0xff, 0xd8, 0xff
:
static readonly jpegSignature = Buffer.from([0xff, 0xd8, 0xff]);
StillCamera seems to work as well but I noticed the libcamera output's jpeg signature was also different on the 0xe1
. Fortunately it doesn't rely on the signature to capture a frame.
It shouldn't be hard to port this to use libcamera and fix a few deprecation warnings for node 21 and the latest typescript.
Thanks for the library @gregnr!