Skip to content

Commit

Permalink
🎉 feat(PiGear): Add official support for new Picamera2 API (Fixes #342)
Browse files Browse the repository at this point in the history
✨ 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.
  • Loading branch information
abhiTronix committed Apr 9, 2024
1 parent a4efa4b commit 83aee85
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 53 deletions.
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ignore:
- "scripts"
- "vidgear/gears/__init__.py" #trivial
- "vidgear/gears/asyncio/__main__.py" #trivial
- "vidgear/gears/pigear.py" #HW limits
- "setup.py"
- "**/*.md"
- "**/*.html"
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
limitations under the License.
===============================================
"""

# import the necessary packages
import json
import platform
Expand Down Expand Up @@ -115,7 +116,6 @@ def latest_version(package_name):
"mss{}".format(latest_version("mss")),
"pyscreenshot{}".format(latest_version("pyscreenshot")),
]
+ (["picamera"] if ("arm" in platform.uname()[4][:3]) else [])
+ (
["dxcam{}".format(latest_version("dxcam"))]
if (platform.system() == "Windows") # windows is only supported
Expand All @@ -136,7 +136,6 @@ def latest_version(package_name):
"aiortc{}".format(latest_version("aiortc")),
"uvicorn{}".format(latest_version("uvicorn")),
]
+ (["picamera"] if ("arm" in platform.uname()[4][:3]) else [])
+ (
["dxcam{}".format(latest_version("dxcam"))]
if (platform.system() == "Windows") # windows is only supported
Expand Down
Loading

0 comments on commit 83aee85

Please sign in to comment.