android可以通过Intent来调用摄像头,那样调用的系统提供的摄像头程序,如果想直接调用摄像头的硬件,也可以直接访问摄像头.
具体可以参考[url]http://developer.android.com/guide/topics/media/camera.html[/url]里"Building a Camera App"这一节
关键的两个步骤是
创建SurfaceView用来绘制摄像头的预览
创建layout确定SurfaceView的位置,比如在这里可以在摄像头预览上加上自己定制的组件
要注意的几点是
camera要及时的在onPause方法中release掉
activity要加上 android:screenOrientation="landscape"否则预览和实际图像往往有90度角的偏转
[quote]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.
[/quote]
比如加上瞄准镜的效果 :D
[img]http://dl.iteye.com/upload/picture/pic/123280/1d8447df-b8ec-39db-8278-90c0a7630655.jpg[/img]
具体可以参考[url]http://developer.android.com/guide/topics/media/camera.html[/url]里"Building a Camera App"这一节
关键的两个步骤是
创建SurfaceView用来绘制摄像头的预览
创建layout确定SurfaceView的位置,比如在这里可以在摄像头预览上加上自己定制的组件
要注意的几点是
camera要及时的在onPause方法中release掉
activity要加上 android:screenOrientation="landscape"否则预览和实际图像往往有90度角的偏转
[quote]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.
[/quote]
比如加上瞄准镜的效果 :D
[img]http://dl.iteye.com/upload/picture/pic/123280/1d8447df-b8ec-39db-8278-90c0a7630655.jpg[/img]