{"id":345,"date":"2019-11-01T05:32:15","date_gmt":"2019-11-01T05:32:15","guid":{"rendered":"https:\/\/www.tech-battery.com\/batteriesblog\/?p=345"},"modified":"2019-11-01T05:32:15","modified_gmt":"2019-11-01T05:32:15","slug":"camerax-googles-new-weapon-in-the-photography-wars","status":"publish","type":"post","link":"https:\/\/www.tech-battery.com\/batteriesblog\/camerax-googles-new-weapon-in-the-photography-wars\/","title":{"rendered":"CameraX: Google\u2019s New Weapon in the Photography Wars"},"content":{"rendered":"\n<p>Ever since it introduced Android, Google has struggled to provide a camera framework for developers that allows them to both build camera-enabled apps quickly and take advantage of the advanced capabilities being offered by phone makers. Its first Camera API was limited, and the second version is complicated. Neither has a vendor-independent way to activate some of the advanced modes that have been added to phones for improving image quality and adding stylistic effects. Now, Google is launching CameraX, a library that provides not just a simplified way for developers to access Android\u2019s Camera2 functionality, but provides extensions for additional capabilities.<\/p>\n\n\n\n<p>CameraX Is a Simpler Way to Harness the Power of Camera2<\/p>\n\n\n\n<p>CameraX is provided as a Jetpack support library, and the basic portion of its capability is usable on Android OS versions back to Android 5.0 (API level 21). Its wrappers provide a use-case-centric set of interfaces to Camera2, and add lifecycle awareness to help reduce programming overhead. Google also says it reduces device dependencies, so CameraX code should run across all types of hardware (there are also calls to ask whether a device has a particular capability like a front camera).<\/p>\n\n\n\n<p>To work with CameraX a developer specifies a desired use case with configuration options. Listeners are then added to handle the data output by the CameraX library \u2014 which can be either in the form of a data stream or written directly to a file. Finally, the use cases are bound to Android Architecture Lifecycles, so that CameraX can handle some of the housekeeping associated with setup and teardown of resources for the application. One nice feature of CameraX is that multiple use cases can be run simultaneously, so a preview can remain live while images or video are analyzed and perhaps captured, for example.<\/p>\n\n\n\n<p>CameraX supports several use cases: Preview, to get an image on the display; Image analysis, to get direct access to the image buffer; and Image capture, to save a fully-processed image or video. Google provides several&nbsp;sample applications&nbsp;for various use cases. As is the recent trend, the ones I looked at are written in Kotlin with alternate Java versions.<\/p>\n\n\n\n<p>After a few lines of setup, CameraX commands are fairly straightforward. For example, to simply capture an image from the camera, there is a takePicture() method. Prior to calling it, another simple call lets an application select which camera to use, or to set other parameters. As you\u2019d expect, CameraX requires the app to have CAMERA permissions, and WRITE_EXTERNAL_STORAGE permission on versions of Android prior to Q if you want to capture directly to the file system.<\/p>\n\n\n\n<p>Extending RAW Image Capture to Multi-frame Scenarios<\/p>\n\n\n\n<p>It was a big advance in capability when Android phones started offering the option to save RAW images for later post-processing, instead of only allowing access to their pre-processed JPEG versions. But with smartphones increasingly relying on the sophisticated merging of multiple frames to create a single output, post-processing a single RAW frame isn\u2019t always the best option. With CameraX, app developers can directly read the stream of frames coming from the camera. That\u2019s important for applications like machine learning and artificial reality (AR). However, it is also a potential boon for those wanting to provide their own image processing pipelines \u2014 either on the device or later on a desktop computer or in the cloud.<\/p>\n\n\n\n<p>CameraX Offers Extensions for HDR, Night, Portrait, and Beauty<\/p>\n\n\n\n<p>One area that has made third-party camera apps less attractive is the difficulty they have harnessing the advanced computational imaging capabilities of newer-model smartphones. For devices that support CameraX extensions, applications can access their advanced modes including HDR, Night photography, Portrait mode, and Beauty enhancements with the simple addition of a few lines of code to an existing Camera2 application.<\/p>\n\n\n\n<p>For an app to have access to an extension, the phone maker needs to add a hook to the CameraX library to the vendor\u2019s own API. If a vendor doesn\u2019t provide an implementation of a capability, CameraX just reports it as being unavailable. Currently, developers using the alpha version of CameraX can make use of extensions on the following phones:<\/p>\n\n\n\n<p>Samsung (HDR, Night, Beauty, Auto): Galaxy Note 10 series (pictured, top)<br>\n  (demonstrated at Samsung\u2019s SDC19)<\/p>\n\n\n\n<p>Huawei (HDR, Portrait): Mate 20 series, P30 series, Honor Magic 2, Honor View 20<\/p>\n\n\n\n<p>CameraX Rollout<\/p>\n\n\n\n<p>CameraX is currently in alpha, but it\u2019s expected to get to beta status \u2014 meaning final APIs according to Google \u2014 in December. Samsung showcased its support for CameraX this week at its Software Developer Conference, and it co-hosted a session with Google on how developers can take advantage of both CameraX and its extensions on the latest Samsung phones.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever since it introduced Android, Google has struggled to provide a camera framework for developers that allows them to both build camera-enabled apps quickly and take advantage of the advanced capabilities being offered by phone makers. Its first Camera API was limited, and the second version is complicated. Neither has a vendor-independent way to activate &hellip; <a href=\"https:\/\/www.tech-battery.com\/batteriesblog\/camerax-googles-new-weapon-in-the-photography-wars\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;CameraX: Google\u2019s New Weapon in the Photography Wars&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[310,4],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-cell-phone","tag-camerax","tag-google"],"_links":{"self":[{"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":1,"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":346,"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/posts\/345\/revisions\/346"}],"wp:attachment":[{"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech-battery.com\/batteriesblog\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}