Android developers are set to benefit from an update to the CameraX library that improves its Dual Concurrent Camera feature. The enhancement, introduced in the 1.5.0-alpha01 release, simplifies the implementation of simultaneous streaming from two different cameras.
Donovan McMurray, Developer Relations Engineer at Google, wrote in a blog post: “CameraX will now handle the composition of the two camera streams as well.”
This expanded functionality builds upon the original Dual Concurrent Camera feature released in CameraX 1.3.0, which McMurray described as “already a huge leap in making this feature easier to implement.”
The latest iteration maintains backwards compatibility, ensuring that existing Dual Concurrent Camera code remains unaffected. Developers can take advantage of the new composition handling by utilising the updated SingleCameraConfig constructor, which now includes a parameter for a CompositionSettings object.
To implement the feature, developers must first confirm concurrent camera support on the device. McMurray provided a code snippet demonstrating how to set up primary and secondary camera selectors, emphasising the importance of consistent constructor usage when creating SingleCameraConfigs.
The update introduces enhanced flexibility in camera stream composition. McMurray showcased two example layouts: a picture-in-picture configuration and a side-by-side arrangement. In the picture-in-picture example, the front camera stream is scaled down to fit into the lower right corner of the frame:
“You are not constrained to a picture-in-picture layout,” McMurray explained. “For instance, you could define a side-by-side layout by setting the offsets and scaling factors accordingly. You want to keep both dimensions scaled by the same amount to avoid a stretched preview.”
The CompositionSettings feature in Dual Concurrent Camera is currently in alpha, allowing developers to provide feedback and request improvements before the API is finalised. Google encourages developers to share their thoughts in the CameraX Discussion Group.
This update paves the way for more sophisticated and user-friendly camera interfaces in future applications. As mobile devices increasingly rely on multi-camera setups, tools like the enhanced CameraX library will prove invaluable to developers seeking to leverage these hardware capabilities fully.
Google has released the full CameraX 1.5.0-alpha01 release notes, detailing additional updates and fixes to the library. As the feature moves towards stable release, it will be interesting to observe how developers incorporate dual camera functionality into their applications.
See also: Entry points threaten multiple open-source ecosystems
Looking to revamp your digital transformation strategy? Learn more about Digital Transformation Week taking place in Amsterdam, California, and London. The comprehensive event is co-located with AI & Big Data Expo, Cyber Security & Cloud Expo, and other leading events.
Explore other upcoming enterprise technology events and webinars powered by TechForge here.
Tags: android, camerax, coding, development, google, library, mobile, programming