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

Project Status #688

Open
wallarug opened this issue Nov 3, 2023 · 8 comments
Open

Project Status #688

wallarug opened this issue Nov 3, 2023 · 8 comments

Comments

@wallarug
Copy link

wallarug commented Nov 3, 2023

Hi there,

I just wanted to check in on the status of this project?

I have noticed there has been no updates in 12 months. Does someone need to pick up this project to keep it going?

I really really love this project and have used it whenever I fire up a Pi Cam. Would be sad to see it decay away.

@roberttidey
Copy link
Collaborator

As the sole developer I still use the software extensively myself and will investigate issues that are raised.

The main issue is that it currently relies on the camera support built into the GPU via the MMAL interface. This is no longer directly supported by the Raspberry OS although it can be turned on by turning on the legacy camera support. Unfortunately this also means the range of cameras supported is limited.

To switch to using the libCamera method used in the OS for all cameras now is a fairly significant undertaking needing quite a lot of effort on coding of the main raspimjpeg process which supports the camera interface and all the video processing. There are also some technical challenges around the motion detection as that uses the h264 vectors available in the MMAL interface. That gives very efficient motion detection and there is no direct equivalent in libCamera.

Currently, this not a development I can undertake on my own. If there are other developers who are interested then I would be very willing to contribute to this effort.

@wallarug
Copy link
Author

wallarug commented Nov 3, 2023

Hello @roberttidey ,

Good to hear from you so quickly! I'm happy to help out a little bit.

I did understand that there was a significant rework required since the OS changed in c. 2021. I probably need to have a more in-depth look at the inner workings before asking questions, but I'll ask anyway.

  1. Is there an alternative to using raspimjpeg to get the stream out of the camera and into the web process?
  2. Is there a way to use the RPI supported methods to get the footage out of the camera (libCamera) and into the web?
  3. Is the core problem that the libCamera suite is not GPU optimised (hence using alternatives)?

I'm trying to understand where someone would start. There seems to be lots happening here that needs attention.

I have not found any alterative to RPi_Cam_Web_Interface that is nearly as feature rich or easy to deploy. It would be great to help fix it up and see it restored to it's former glory.

@roberttidey
Copy link
Collaborator

raspimjpeg (source at https://github.com/roberttidey/userland/tree/master/host_applications/linux/apps/raspicam, files starting with RaspiM) was originally based around the original raspberry camera support raspivid. It was compiled within the userland repository as that provided all the necessary MMAL references.

1 & 2) raspimjpeg exploits the pipelining process in MMAL to get several streams out of the camera simultaneously and process them in different ways. One provides the resized mjpeg stream to feed the main preview. Another stream is used for full resolution video recording to h264 /mp4. A third stream allows for still image capture. A fourth stream provides h264 motion vectors for use in the motion detection. As well as the main camera / video processing. raspimjpeg supports a number of commands fed into command pipelines. The web interface uses these commands to provide the overall functionality.

So the approach I would take is to modify the camera / processing in RaspiMCam.c and the motion detection in RaspiMMotion.c while leaving all the main control / command fairly intact. The source code would then be compiled separate from userland but linking with libCamera instead.

The camera settings that the web interface exposes would also need to change as these are specific to those defined in MMAL and would need to change to those that libCamera uses. The web side would need to change to reflect that but that part would be fairly straightforward.

  1. libCamera does use GPU for some of the intensive tasks so I don't think that is a fundamental problem. I suspect porting to this environment would be more cpu intensive as I think the pipelining / stream splitting will involve more of the cpu in data movement. This was originally developed to run well even on Pi Zero v1 and it still does with quite low cpu usage. I also wanted it to very efficient so the pi could do other stuff. Later models including Zero v2 are much more powerful so this becomes less of a problem. The one area that would need thinking about is the motion detection. Originally an external "motion" process was used for this which worked by comparing frame buffers for pixel differences. This works OK but can use quite a bit of cpu. Getting the motion vectors used as part of the h264 encoding allowed the use of the internal motion detection method which is more effective and very efficient.

Getting into this requires understanding the RaspiM files. In particular, RaspiMCam.c which would need almost a complete rewrite.

Even with a new libCamera version, I think I would archive the original raspimjpeg based version using MMAL particularly for any Zero v1 uses if the new version strained that platform too much.

@wallarug
Copy link
Author

wallarug commented Nov 6, 2023

Thanks for the reply!

Look, I am not expert in this area, but happy to do some more reading and collaboration to help with making this work.

The new libcamera suite seems pretty friendly based on the documentation.

There is a motion detection "stage" built into it (if you build it). Not sure how useful that is to replace the existing motion library currently used here.

The V4L2 driver looks pretty interesting for having multiple streams. It maybe the way to build a new raspimjpeg with the original functionality of the video output, video record and taking images at the same time.

Functionality

  1. Provides the resized mjpeg stream to feed the main preview
  2. full resolution video recording to h264 /mp4.
  3. allows for still image capture
  4. provides h264 motion vectors for use in the motion detection

I'll keep having a read of the existing raspimjpeg code and see if I can wrap my head around it over the next week.

@wallarug
Copy link
Author

Do you know if @silvanmelchior is still around to help on this project?

@silvanmelchior
Copy link
Owner

Hi there, still around, but unfortunately no capacity here

@SamVimes78
Copy link

Just want to let you guys know that I'm really excited to read there's still some hope for this project to support libcamera maybe sometime in the future.

I bought a camera module v3 because i thought i could just replace my v2 module and keep using the RPI-Cam web interface. Was really sad when I found out it doesn't just work that way...

Wouldn't even need motion detection. Just a simple web interface to manually record videos and take photos with the v3 module would be so much appreciated!

@wallarug
Copy link
Author

Just want to let you guys know that I'm really excited to read there's still some hope for this project to support libcamera maybe sometime in the future.

I bought a camera module v3 because i thought i could just replace my v2 module and keep using the RPI-Cam web interface. Was really sad when I found out it doesn't just work that way...

Wouldn't even need motion detection. Just a simple web interface to manually record videos and take photos with the v3 module would be so much appreciated!

Hey @SamVimes78. Great to see interest.

I've actually put this in as a research project for Semester 1 with some University Students to help kick start progress. Hopefully they are up for the challenge to help bring this project back!

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

4 participants