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

[Proposal]: Support Picamera2 #342

Open
4 tasks done
roaldarbol opened this issue Dec 9, 2022 · 14 comments · May be fixed by #392
Open
4 tasks done

[Proposal]: Support Picamera2 #342

roaldarbol opened this issue Dec 9, 2022 · 14 comments · May be fixed by #392
Assignees
Labels
ENHANCEMENT ⚡ New Feature/Addition/Improvement PROPOSAL 📩 A proposal/proposition WORK IN PROGRESS 🚧 currently been worked on.
Milestone

Comments

@roaldarbol
Copy link

Issue guidelines

Issue Checklist

  • I have searched open or closed issues and found nothing related to my idea.
  • I have read the Documentation and it doesn't mention anything about my idea.
  • To my best knowledge, my idea wouldn't break something for other users.

Describe your Idea

With Bullseye, Raspberry Pi moved away from the legacy camera support to their own libcamera-fuelled picamera2. It aims at being a slot-in replacement for picamera. It is still possible to use the legacy picamera, but it's being deprecated and is slowly starting to break things.

Although picamera2 is still in beta, I'd propose beginning to implement it.

Use Cases

Anyone using Raspberry Pi cameras, especially newer custom cameras (e.g. from Arducam).

Any other Relevant Information?

The picamera2repo: https://github.com/raspberrypi/picamera2
Documentation: https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf

I can begin slowly and create a pull request, hoping that it really is mostly a slot-in replacement. Would you prefer having an additional PiGear2 class inside pigear.py, or a new pigear2.py?

@roaldarbol roaldarbol added the PROPOSAL 📩 A proposal/proposition label Dec 9, 2022
@welcome
Copy link

welcome bot commented Dec 9, 2022

Thanks for opening this issue, a maintainer will get back to you shortly!

In the meantime:

  • Read our Issue Guidelines, and update your issue accordingly. Please note that your issue will be fixed much faster if you spend about half an hour preparing it, including the exact reproduction steps and a demo.
  • Go comprehensively through our dedicated FAQ & Troubleshooting section.
  • For any quick questions and typos, please refrain from opening an issue, as you can reach us on Gitter community channel.

@abhiTronix abhiTronix added ENHANCEMENT ⚡ New Feature/Addition/Improvement WORK IN PROGRESS 🚧 currently been worked on. labels Dec 10, 2022
@abhiTronix abhiTronix self-assigned this Dec 10, 2022
@dante-biase
Copy link

Hi, we're eagerly waiting on PiCamera2 support. Any progress updates on this/is there any development code we can look at or contribute to?

@abhiTronix
Copy link
Owner

@dante-biase I just got time to work on this project again. I'll start shortly after pending commits are pushed.

@dante-biase
Copy link

Fantastic!

@iandol
Copy link
Contributor

iandol commented Jul 3, 2023

I hope this is still in scope, the new pi camera modules are really nice (autofocus, wideangle etc), so it would be great to see picamera2 integrated here...

@roaldarbol
Copy link
Author

It would also be a major selling point, as they are still not supported in OpenCV natively yet (opencv/opencv#21653).

@abhiTronix
Copy link
Owner

@iandol yeah its on priority, I'm right now busy with my studies and job. But I've planned this for upcoming weeks and looking at Picamera2 documentation its not that hard to implement. Stay tuned.

@sourabmaity
Copy link

Waiting for Picamera2 update

@abhiTronix
Copy link
Owner

@sourabmaity Yeah I'm swamped with a ton of work right now and my schedule's pretty tight. However, I'm committed to work on this, so as soon as I get a breather, I'll definitely circle back and address this.

@abhiTronix abhiTronix added this to To do in VidGear v0.3.3 via automation Sep 10, 2023
@abhiTronix abhiTronix added this to the v0.3.3 milestone Sep 10, 2023
@abhiTronix
Copy link
Owner

Okay I've finally started working on this. Expect a update in few days.

@dante-biase
Copy link

Any update on this?

abhiTronix added a commit that referenced this issue Apr 9, 2024
✨ This update brings official support for the new Picamera2 API, unlocking powerful features for Raspberry Pi Camera Modules and limited USB camera support.

Key improvements:
- 🚸 Seamless Python wrapper: A robust wrapper around Picamera2 API library simplifies integration with minimal code changes for existing PiGear users.
- ⚡️ Enhanced camera control: Leverages libcamera API under the hood for Raspberry Pi Camera Modules.
- ⚡️ Existing compatibility: Maintains compatibility with PiGear's existing super-charged multi-threaded and colorspace manipulation framework.
- ⚡️ Resource management: Ensures proper resource release during PiGear termination.
- ✨ USB camera support (limited): Provides basic functionality for USB webcams. PiGear could accurately differentiates between USB and Raspberry Pi cameras using metadata.
- 🧑‍💻 Backward compatibility: Seamlessly switches to the legacy PiCamera library if Picamera2 is unavailable.
- 🧑‍💻 Standalone functionalities: Separates functionalities for both legacy and newer APIs for clarity.
- ⚡️ Automatic configuration management: Handles common configuration parameters and non-standard settings for various camera types.
- New internal parameters:
  - 🚩 auto_align_output_config: Optimizes output frame configuration for the camera sensor.
  - 🚩 enable_verbose_logs: Enables more detailed logging through Picamera2.
- Unified `format` parameter:
  - 🥅 Defaults to RGB888 (24-bit BGR) for Raspberry Pi cameras.
  - 🦺 Validates formats for USB cameras before handling.
  - 🥅 Requires explicit `colorspace` definition if `format` is not MPEG (USB cameras) or for specific formats in Raspberry Pi cameras.
- Raspberry Pi camera exclusive parameters:
  - 🚩 Currently Supports `"controls," "queue," "transform," "bit_depth," "buffer_count," "sensor," and "stride"` with type checks.
- ⚡️ Framerate handling: Tailored framerate handling based on camera type.
- 🦺 Logging optimization: Added a warning advising users to disable common libcamera messages when logging is disabled.

Additional Changes:
- 💥 Dropped legacy `picamera` dependency in `Setup.py`.
- 💡 Improved code efficiency with short-circuiting and formatting.
- 🔊 Updated logging practices.

CI:
- 🏗️ Temporarily removed PiGear API from code coverage due to hardware limitations.
@abhiTronix
Copy link
Owner

@dante-biase It's here finally. :)

@dante-biase
Copy link

Alright!

@roaldarbol
Copy link
Author

Awesome to hear!🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENHANCEMENT ⚡ New Feature/Addition/Improvement PROPOSAL 📩 A proposal/proposition WORK IN PROGRESS 🚧 currently been worked on.
Projects
Development

Successfully merging a pull request may close this issue.

5 participants