Posted by The Android Crew
CameraX is an Android Jetpack library that makes it straightforward to include digicam performance immediately in your Android app. That’s why we focus closely on machine compatibility out-of-the-box, so you’ll be able to concentrate on what makes your app distinctive.
On this publish, we’ll take a look at 3 ways CameraX makes builders’ lives simpler in terms of machine compatibility. First, we’ll take a peek into our CameraX Check Lab the place we check over 150 bodily telephones every single day. Second, we’ll take a look at Quirks, the mechanism CameraX makes use of to mechanically deal with machine inconsistencies. Third, we’ll focus on the methods CameraX makes it simpler to develop apps for foldable telephones.
CameraX Check Lab
|(Left) A single rack in our CameraX Check Lab. Every check enclosure comprises two similar Android telephones for testing back and front cameras. (Proper) A GIF displaying the within of a check inclosure, with a rotating cellphone mount (for testing portrait and panorama orientations) and a high-resolution check chart (not pictured).|
We constructed the CameraX Check Lab to make sure CameraX works on the Android units most individuals have of their pockets. The Check Lab opened in 2019 with 52 cellphone fashions. At the moment, the Check Lab has 150 cellphone fashions. We prioritize units with probably the most each day energetic customers over the previous 28 days (28DAUs) and units that leverage a various vary of methods on a chip (SoCs). The Check Lab at present covers over 750 million 28DAUs. We additionally check many various Android variations, going again to Android 5.1 (Lollipop).
To generate dependable check outcomes, every cellphone mannequin has its personal check enclosure to manage for gentle and different environmental components. Every enclosure comprises two telephones of the identical mannequin to simplify testing the back and front cameras. On the alternative facet of the check enclosure from the telephones, there’s a high-resolution check chart. This chart has many industry-standard checks for digicam attributes like colour correctness, decision, sharpness, and dynamic vary. The chart additionally has some particular components for purposeful checks like face detection.
While you undertake CameraX in your app, you get the peace of mind of this steady testing throughout many units and API ranges. Moreover, we’re repeatedly bettering the Check Lab, together with including new telephones based mostly on market tendencies to make sure that the vast majority of your customers are properly represented. See our present check machine checklist for the newest stock in our Check Lab.
Google offers a Digicam Picture Check Suite in order that OEM’s cameras meet a baseline of consistency. Nonetheless, when coping with the big selection of units that run Android, there will be variations in the long run consumer digicam expertise. CameraX contains an abstraction layer, referred to as Quirks, to take away these variations in habits in order that CameraX behaves constantly throughout all units with no effort from app builders.
We discover these quirks based mostly on our personal handbook testing, the Check Lab’s computerized testing, and bug stories filed in our public CameraX concern tracker. As of at present, CameraX has over 30 Quirks that mechanically repair habits inconsistencies for builders. Listed below are just a few examples:
- OnePixelShiftQuirk: Some telephones shift a column of pixels when changing YUV information to RGB. CameraX mechanically corrects for this on these units.
- ExtensionDisableQuirk: For telephones that don’t help extensions or have damaged habits with extensions, CameraX disables sure extensions.
- CameraUseInconsistentTimebaseQuirk: Some telephones don’t correctly timestamp video and audio. CameraX fixes the timestamps in order that the video and audio align correctly.
These are only a few examples of how CameraX mechanically handles quirky machine habits. We’ll proceed so as to add extra corrections as we discover them, so app builders gained’t should take care of these one-offs on their very own. When you discover inconsistent habits on a tool you’re testing, you’ll be able to file a problem within the CameraX part detailing the habits and the machine it’s taking place on.
Foldables proceed to be the quickest rising smartphone kind issue. Their flexibility in display measurement provides complexity to digicam growth. Listed below are just a few ways in which CameraX simplifies the event of digicam apps on foldables.
CameraX’s Preview use case handles variations between the side ratio of the digicam and the side ratio of the display. With conventional cellphone and pill kind components, this distinction must be small as a result of Part 7.5.5 of the Android Compatibility Definition Doc requires that the “lengthy dimension of the digicam aligns with the display’s lengthy dimension.” Nonetheless, with foldable units the display side ratio can change, so this relationship may not all the time maintain. With CameraX you’ll be able to all the time protect side ratio by filling the PreviewView (which can crop the preview picture) or becoming the picture into the PreviewView (which can end in letterboxing or pillarboxing). Set PreviewView.ScaleType to specify which methodology to make use of.
The rise in foldable units additionally will increase the chance that your app could also be utilized in a multi-window atmosphere. CameraX is ready up for multi-window help out-of-the-box. CameraX handles all facets of lifecycle administration for you, together with the multi-window case the place different apps can take precedence entry of singleton assets, such because the microphone or digicam. This implies no extra effort is required from app builders when utilizing CameraX in a multi-window atmosphere.
We’re all the time searching for extra methods to enhance CameraX to make it even simpler to make use of. With respect to foldables, for instance, we’re exploring methods to let builders name setTargetResolution() with out having to keep in mind the completely different configurations a foldable machine will be in. Control this weblog and our CameraX launch notes for updates on new options!
Getting began with CameraX
Now we have plenty of assets that will help you get began with CameraX. The perfect beginning place is our CameraX codelab. If you wish to dig a bit deeper with CameraX, take a look at our digicam code samples, starting from a primary app to extra superior options like digicam extensions. For an outline of every little thing CameraX has to supply, see our CameraX documentation. When you’ve got any questions, be happy to achieve out to us on our CameraX dialogue group.