What is Android CameraX? - android

What is Android CameraX?
There is a session about CameraX planned in Google I/O 2019. What is it? Is it a new framework API? Is it a new library?
https://events.google.com/io/schedule/events/8d400240-f31f-4ac2-bfab-f8347ef3ab3e
Does it mean that Camera2 API is deprecated?
https://github.com/googlesamples/android-Camera2Basic

What is Android CameraX?
CameraX is a new Jetpack library that lets developers control a device's camera and focuses on compatibility across devices going back to API level 21 (Lollipop). It was announced at Google I/O 2019 and has a dedicated documentation page alongside an official sample.
Does it mean that Camera2 API is deprecated?
Camera2 API is not deprecated; in fact, it is the foundation that CameraX is built on. CameraX also provides a Camera2 interop API that lets developers extend their CameraX implementation with Camera2 code.
For more information, the official documentation is available at https://developer.android.com/camerax

In Google IO 2019, Google added another powerful tool for camera development in Android development called CameraX as part of Jetpack
Few Features of CameraX
It is backwards compatible till Android 5.0 / Lollipop (API 21) and
it works with at least 90% devices in the market.
Under the hood, it uses and leverages the Camera 2 APIs. It
basically, provide the same consistency as Camera 1 API via Camera 2
Legacy layer and it fixed a lot of issues across the device.
It also has a lot of awesome advanced features like Portrait, HDR,
Night mode etc (Provided your Device supports that).
CameraX has also introduced use cases which allow you to focus on the
the task you need to get it done and not waste your time with specific devices. Few of them are Preview, Image Analysis, Image Capture.
CameraX doesn't have specific call/stop methods in onResume() and
onPause() but it binds to the lifecycle of the View with the help of
CameraX.bindToLifecycle()
The following is the few lists of known issues fixed with CameraX,
what more you can do with CameraX
You can also create Video Recorder App using CameraX
Add multiple extensions like Portrait Mode, HDR etc.
We can also use Image Analysis to perform Computer Vision, ML. So it
implements Analyzer method to run on each and every frame.
To read more about CameraX refer here
for Getting Started with CameraX

You can check the official doc:
CameraX is an addition to Android Jetpack that makes it easier to add camera capabilities to your app. The library provides a number of compatibility fixes and workarounds to help make the developer experience consistent across many devices.
You can use cameraX to interface with a device’s camera through an abstraction called a use case. The following use cases are currently available:
Preview: prepares a preview SurfaceTexture
Image analysis: provides CPU-accessible buffers for analysis, such as for machine learning
Image capture: captures and saves a photo
Use cases can be combined and active concurrently.
Just add the dependencies:
dependencies {
// CameraX core library
def camerax_version = "1.0.0-alpha01"
implementation "androidx.camera:camera-core:$camerax_version"
// If you want to use Camera2 extensions
implementation "androidx.camera:camera-camera2:$camerax_version"
}
For information on how to use the CameraX library check here.

Related

CameraX recorded video analysis graphics error

Android CameraX, prompt when VideoCapture and ImageAnalysis are used at the same time:
java.lang.IllegalArgumentException: No supported surface combination is found for camera device-Id: 1. May be attempting to bind too many use cases. Existing surfaces: [] New configs: [androidx.camera.core.impl.ImageAnalysisConfig#7ea65ca , androidx.camera.core.impl.VideoCaptureConfig#e0d133b, androidx.camera.core.impl.PreviewConfig#20f5a58]
CameraX does not support this combination for most of the devices.
Here you can find the supported combinations: Source
Notice that video capture use case is not even in supported combinations. However, as far as I know, CameraX team is working on this.
For now, I would suggest you to use Camera2 Api. Here is a very well documented library that would allow you to do what you want to achieve.

Writing a customized looking camera in minSdk 17

I've been working on a customized camera app, it only changes the layout of how the camera is shown but it doesn't change any core feature of the camera.
As I searched, I found these libraries: hardware.camera2 , hardware.camera and cameraX.
And my app should work properly on minSdk 17. so my question is: is camera api deprecated so I can use camera2 on my app?
As I saw in documents you could only use camera2 with cameraManager on API 21 and higher.
Can anyone help me with what library I should use and how I could implement it?
hardware.camera (also known as Camera1) was deprecated in API level 21.
hardware.camera2 (also known as Camera2) was introduced in API level 21.
camerax is part of the Jetpack suite of libraries, and is built on top on Camera2, so is backward compatible to API level 21.
If your app has a minSdk version of 17, you can define a single Camera interface to use in your app, then provide 2 implementations for it using camera1 on API levels below 21, and CameraX/Camera2 on API levels starting at 21. Whether you choose Camera2 or CameraX depends mostly on your camera features. CameraX provides fairly easy to use APIs for preview, image analysis and image capture, and resolves device compatibility issues. You can take a look at its official documentation to see whether it meets your app's requirements, if it does, you can get started on it with this codelab. Camera2 provides a more fine grained control over the camera, but come with more complexity to handle it, you can take a look at what it provides through its official documentation.

Difference Between Camera and Camera2 in Android

I'm building an App which is similar to social media where people can share photos and videos like Instagram. That's why Camera is very important for my app. Now camera2 API is confusing me. I want to run my app on API level 11+ . I know camera2 is only available in API level 21+ So, I need to design two APIs one(camera) for older version and second(camera2) for higher version. Problem is that I just started to learn Android and I do not know what is the main difference between these two APIs.
What main features are available in Camera2 API ?
Or Is there any drawback of Old Camera API ?
I need three things in my App.
1- Simple capture photos
2- Burst pictures (To create GIF Image)
3- Simple video recording.
Which Camera API is good for me ?
The old camera API will work fine for #1 and #3; if you're OK with video-resolution GIFs, you can do #2 as well.
You'll need camera2 (and then devices that support fast, full-resolution capture - see the BURST_CAPTURE capability, or any device that supports the FULL hardware level.), if you want bursts at resolutions above ~1080p.
You can probably start with the CameraView unofficial support library, and modify it as needed. It has support for both APIs, selected based on API level of the device.

Complete Custom Camera2 example

I need to create a custom camera in Android that supports both higher and lower version.I am new to android.I have research a lot I have the code ready for hardware camera i.e. for the api less than 21.But I am finding hard time searching the code that supports camera hardware 2.
The old deprecated camera API still works on Android 21 and above. But you are right, using the new API is preferable, and gives you more options and better performance.
You can start with the official Camera2Basic sample.

Android Camera with Surfaceview

I want to built my own camera app in android including the following options pinch to zoom and autofocus without using camera intent. I already gone through some samples from Git hub but I couldn't make use of them.So, I decided to start learning Camera API from Google developers. Here I need a complete steps to develop my app and what to learn like camera, surface view and anything else.
Thanks in advance
I have done what you want to be done recently.
For android, there are 2 camera APIs
the camera api
and the camera2 api
camera api is deprecated on android api 21. starting from android api 21, you have to use camera2 api. so you have to learn both of them.
Camera api brother with SurfaceView.
Camera2 api brother with TextureView.
Camera2 api is quit alot different from Camera api, and also is much more complicated than Camera api.
You may want to take a look at my project SimpleCameraView, it is much clear than other projects. I just created this repository yesterday.
Things to Need to Learn to Build Custom Camera APP
Setting Camera,FlashLight and FILE_STORAGE Permissions in Manifest
SurfaceView and How to Use it.
Manual Control of Flash Light.
Lazy Loader for Displaying Images Taken without Memory Leaking.
And you can go through this for Sample : Build Custom Camera

Categories

Resources