Skip to content
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

Does this support libcamera? #39

Open
gurmukhp opened this issue Dec 25, 2021 · 5 comments
Open

Does this support libcamera? #39

gurmukhp opened this issue Dec 25, 2021 · 5 comments

Comments

@gurmukhp
Copy link

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?

@reselbob
Copy link

I am interested to learn the answer to this question too.

@gregnr
Copy link
Contributor

gregnr commented Mar 16, 2022

@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?

@sliterok
Copy link

sliterok commented Oct 1, 2022

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
image
image
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:
image

@adminy
Copy link

adminy commented May 23, 2023

any updates on this?

@SystemR
Copy link

SystemR commented Jan 27, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants