How do I open the “front camera” on the Android platform?

前端 未结 9 2134
挽巷
挽巷 2020-11-22 15:00

More generally, if a device has more than one embedded camera, is there a way to initialize one of them in particular?

I didn\'t find it in Android reference documen

9条回答
  •  无人及你
    2020-11-22 15:42

    build.gradle

     dependencies {
           compile 'com.google.android.gms:play-services-vision:9.4.0+'
        }
    

    Set View

    CameraSourcePreview mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    
    GraphicOverlay mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay);
    
    CameraSource mCameraSource = new CameraSource.Builder(context, detector)
                                .setRequestedPreviewSize(640, 480)
                                .setFacing(CameraSource.CAMERA_FACING_FRONT)
                                .setRequestedFps(30.0f)
                                .build();
    
               mPreview.start(mCameraSource, mGraphicOverlay);
    

提交回复
热议问题