如何在android手机自动拍摄照片么?照片、如何在、手机、android

2023-09-04 13:22:28 作者:冷暖自知

我已经开发了一个Android应用程序。在这我已经使用前置摄像头功能。它工作正常,但我需要自动捕获。即不按快门按钮的声音,我想拍摄照片​​code ..

I have developed an android application. In that i have used front facing camera functionality. Its working fine but I need to auto capture. i.e. without click shutter button sound, I want to capture photocode..

我的相机活性 code是

 private Camera openFrontFacingCameraGingerbread() { 
    int cameraCount = 0; 
    Camera cam = null; 
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); 
    cameraCount = Camera.getNumberOfCameras(); 
    for ( int camIdx = 0; camIdx < cameraCount; camIdx++ ) { 
        Camera.getCameraInfo( camIdx, cameraInfo ); 
        if ( cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT  ) { 
            try { 
                cam = Camera.open( camIdx ); 
            } catch (RuntimeException e) { 
                Log.i("Camera failed to open: ",e.getLocalizedMessage()); 
            } 
        } 
    } 
    return cam; 
} 

在此先感谢。

Thanks in advance..

推荐答案

请在Android开发者所列的步骤的引用页面。有没有需要有一个'快门按钮。你可以创建一个虚拟SurfaceHolder,如果你不希望显示图像在屏幕上,如:

Follow the steps outlined in the Android Developer reference pages. There's no requirement to have a 'shutter button'. You can create a dummy SurfaceHolder if you don't want to show the image on the screen, e.g.

SurfaceView surface = new SurfaceView(context);
cam.setPreviewDisplay(surface.getHolder());
 
精彩推荐
图片推荐