I am working on an application where I am trying to scan barcode with the help of mobile vision API. I am creating TextureView
in my activity, so I need camera to render on `TextureView.
I have been using old camera API, just came across new camera2 API. Can anyone help me what are the differences between them ?
This article provides a lot of information about how to set up a project with the Camera2 API. From the first few paragraphs:
DSLR-like levels of customization, such as native control over exposure and raw sensor capture are finally possible. And while this new approach requires a little more thought and legwork, the level of control you get in return is well worth the effort.
So the main difference is that you have more control over what you can do with the phone's camera. It is also likely that there is an improvement in performance and photo quality, but I haven't found any mentions of it anywhere.
If you don't want to use the Camera2 API as it is somewhat more complicated, the deprecated version seems to work fine on most devices, however it is more than likely that it will eventually be removed, which will cause your app to... not work. So regardless of which API you prefer using, it is always going to be better to go with the one that isn't deprecated.
To help with implementing the API, there's a nice and simple library I like here, or if you don't like libraries or have a more specific use for it you could take a look at this sample project.