Android realizes Camera2 preview and photographing effects

brief introduction

There are many introductions to Camera2 on the Internet and many packaging libraries about Camera2 on GitHub, but for those libraries, the encapsulation is too strong. Sometimes we just need a simple photographing function. Therefore, it is very important to customize a camera to make it lightweight. (this article is not to build wheels repeatedly, but to learn the basic functions of camera2api. Take notes.)

Learning points:

Use the basic functions of Android Camera2 API. Iterate over the features of all cameras connected to the device. Show camera preview and take photos.

The Camera2 API provides an interface for each camera device connected to an Android device. It replaces the deprecated camera class.

When you're done, don't forget to unlock the focus.

Realization effect

SDK>21

Camera2 class diagram

code implementation

CameraPreview.java

MainActivity.java

activity_ main.xml

Resource file IC_ capture_ 200px.xml

other

Manifest permissions:

Android 6.0 runtime permissions are not posted. (Note: in order to facilitate readers to read on the mobile phone, the end of line annotation is used for the member variables in the code part of this article. In normal programming habits, please use / * / annotation.)

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>