Complete Custom Camera2 example - android

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.

Related

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.

Which Android Camera API should a new project use?

I am developing a new app, and I want to support all the way back to Jelly Bean/Ice Cream Sandwich. I need to use the video camera in my app - just to shoot some 15 second footage and no processing.
Do I have to write two camera Activities, one with the camera api and the other with the camera2 api, and somehow pick one based on the api level of the device?
Or, should I just use the camera api?
Which camera api would you use if you were developing a new camera based app today?
Thanks!
Mark
For the near future, the deprecated Camera API will not disappear, even on the cutting-edge new devices. I would recommend to switch to Camera2 if one of the following causes applies:
your app makes good use of some of the new features, e.g. capture-while-recording.
your app has other reasons not to be backwards-compatible under API v.21 (Lollipop), e.g. it only runs on ARM64.
you want to practice or demonstrate your skills with the new API.
PS and I support the first suggestion from SAg: use the Camera Intent if you only need what such intent can provide. A short unprocessed video clip is a good example.
First of all, you need to decide whether you really want to build a customized camera app, or you can use an existing camera app. From your question, I feel that yours is the latter case, and you can simply use an intent to invoke an existing Android camera application.
https://developer.android.com/guide/topics/media/camera.html#intents
If you really want to build your own customized camera app, I suggest that you refer this link:
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
And read the following sections:
Application forward compatibility
Application backward compatibility
Selecting a platform version and API Level

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

Android Camera: setSceneMode() has no effect on android V21

I am working on custom camera and using deprecated Camera api's instead of Camera2 api's in Android L but I am facing lots issues in preview. One of them is, It is showing dark preview and another problem is setSceneMode and setColorEffects making no effect. Please let me know the workaround if any one out there used deprecated camera api's in v21.
Setting a high FPS which may produce a dark preview in some devices, because a high FPS lowers the exposure compensation. Setting it to a variable range instead of a fixed one can solve the problem for the devices that present such issue.
A device may return a set of supported ranges such as for example: [10-15, 15-30, 30-30]. In this example you would pick up any of the variable ones, and avoid the fixed one [30-30]. Note that fixed ranges are meant to be for video only.
Turns out Camera.Parameters is deprecated.
This class was deprecated in API level 21.
We recommend using the new android.hardware.camera2 API for new applications.
Android Developer - Camera.Parameters
You should use this instead for devices with API level > 21:
Android Developer - android.hardware.camera2

Categories

Resources