Android相机预览很暗

我正在尝试创建一个自定义相机应用程序.我从这里跟随Android Developer示例进行了一些小调整.但是,我的相机预览结果相当暗.另一方面,照相机提供了更加明亮的预览.

我已经尝试了几种设置以使其更好地工作,但似乎它们都没有任何影响.相关代码发布在这里.

CameraActivity(主要)

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_camera);
    if(CameraHelper.checkCameraHardware(this)) {
        mHelper = new CameraHelper(this, getWindowManager().getDefaultDisplay());
    }

    FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
    mPreview = new CameraPreview(this, CameraHelper.camera);
    mPreview.setLayoutParams(new LayoutParams(CameraHelper.mSize.width, CameraHelper.mSize.height, Gravity.CENTER));

    preview.addView(mPreview);

}

CameraHelper类(初始化摄像头并设置默认参数)

    public CameraHelper(CameraListener listener, Display display){
        mListener = listener;
        camera = getCameraInstance();

        mParameters = camera.getParameters();
        initCameraParameters();

        mSize = getPreviewSize(display);
        mParameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
        mParameters.setPictureSize(2560, 1920);

        mParameters.setAutoExposureLock(false);
        mParameters.setAutoWhiteBalanceLock(false);
        mParameters.set("iso", "ISO800"); //Tried with 400, 800, 600 (values obtained from flatten())
        mParameters.setColorEffect("none");
        mParameters.setPictureSize(2560, 1920);
        mParameters.setPreviewFrameRate(20);
        mParameters.set("scene-mode", "auto");
        mParameters.setFocusMode("auto");
        mParameters.setExposureCompensation(4);     
        camera.setParameters(mParameters);
    }

相机将帧从上面的开发人员页面链接的示例发送到SurfaceHolder.Surface.

看到这里的区别:
相机应用程序
 
我的相机应用程序

尝试根据此处发布的摄像机的upack参数设置ISO等.它仍然无法正常工作.

Parameters(16369):
effect-values=none,mono,negative,sepia,aqua,sharpen,purple,green-tint,blue-tint,pink,yellow,red-tint,mono,antique;exposure-compensation-step=0.5;focal-length=3.43;focus-areas=(0,0,0,0,0);focus-distances=0.10,1.20,Infinity;focus-mode-values=auto,macro,facedetect;gps-altitude=0;gps-latitude=0;gps-longitude=0;gps-processing-method=GPS;gps-timestamp=0;horizontal-view-angle=51.2;iso=auto;iso-values=auto,ISO50,ISO100,ISO200,ISO400,ISO800,ISO1600;jpeg-quality=1;jpeg-thumbnail-height=480;jpeg-thumbnail-size-values=640×480,0x0;jpeg-thumbnail-width=640;max-exposure-compensation=4;max-num-focus-areas=1;max-zoom=12;min-exposure-compensation=-4;picture-format=jpeg;picture-format-values=jpeg;picture-size-values=2560×1920,2560×1536,2048×1536,2048×1232,1600×1200,1600×960,800×480,640×480;preview-format=yuv420sp;preview-format-values=yuv420sp;preview-fps-range=15000,30000;preview-fps-range-values=(15000,30000);preview-frame-rate=30;preview-frame-rate-values=30;preview-size=640×480;preview-size-values=1280×720,800×480,720×480,640×480,352×288;rotation=0;scene-mode=auto;scene-mode-values=auto,portrait,landscape,night,beach,snow,sunset,fireworks,sports,party,candlelight,asd,backlight,dusk-dawn,text,fall-color;vertical-view-angle=39.4;video-frame-format=yuv422i-yuyv;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;zoom=0;zoom-ratios=100,125,150,175,200,225,250,275,300,325,350,375,400;zoom-supported=true;focus-mode=auto;picture-size=2560×1920;exposure-compensation=4;

编辑:根据以下评论进行进一步测试后,看起来它的预览会变得比它应该更暗.实际捕获的图像光线充足,曝光补偿似乎工作正常.它只是让我头疼的预览.测试运行CM11和Nexus 10运行股票android的i9003.

解决方法:

根据我的实验,场景模式设置可以改变预览(与ISO或曝光补偿不同,它们都适用于拍摄的图像).不要使用汽车.尝试scene-mode-values = night或scene-mode = dusk-dawn.

场景的问题在于支持的值不是跨设备标准化的.但通常会出现某种夜晚.

上一篇:WPF Beginner - Preview Event & Bubble Event


下一篇:.NET 5.0 Preview 2发布