android直接调用摄像头

android可以通过Intent来调用摄像头,那样调用的系统提供的摄像头程序,如果想直接调用摄像头的硬件,也可以直接访问摄像头.
具体可以参考 http://developer.android.com/guide/topics/media/camera.html里"Building a Camera App"这一节
关键的两个步骤是
创建SurfaceView用来绘制摄像头的预览
创建layout确定SurfaceView的位置,比如在这里可以在摄像头预览上加上自己定制的组件
要注意的几点是
camera要及时的在onPause方法中release掉
activity要加上 android:screenOrientation="landscape"否则预览和实际图像往往有90度角的偏转
引用
On most devices, the default orientation of the camera preview is landscape. This example layout specifies a horizontal (landscape) layout and the code below fixes the orientation of the application to landscape. For simplicity in rendering a camera preview, you should change your application's preview activity orientation to landscape by adding the following to your manifest.


比如加上瞄准镜的效果

猜你喜欢

转载自kabike.iteye.com/blog/1786636