Android摄像头preVIEW暗 [英] Android camera preview is dark

查看:1612
本文介绍了Android摄像头preVIEW暗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个自定义的相机应用。我跟着从这里稍作调整的Andr​​oid开发者的例子。然而,我的相机preVIEW真可谓是相当黑暗的。另一方面,股价相机给出亮得多的preVIEW

I am trying to create a custom camera app. I followed the Android Developer example from here with minor tweaks. However, my camera preview turns out to be rather dark. On the other hand, the stock camera gives a much brighter preview.

我已经尝试了几种设置,使之更好地工作,但似乎没有人是有任何的影响。相关code被张贴在这里。

I have tried several settings to make it work better but it seems none of them are having any impact. Relevant code is posted here.

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类(初始化相机并设置默认参数)

CameraHelper class (initialize the camera and set the default parameters)

    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。

The Camera sends the frames to SurfaceHolder.Surface from the example linked from developer pages above.

在这里看到区别: 股票相机应用 我的相机应用

See the difference here: Stock Camera App My Camera App

尝试设置ISO等的基础上,从作为这里张贴相机upack参数。它仍然没有奏效。

Tried setting the ISO, etc based on upack parameters from the camera as posted here. It still didn't work.

参数(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=640x480,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=2560x1920,2560x1536,2048x1536,2048x1232,1600x1200,1600x960,800x480,640x480;$p$pview-format=yuv420sp;$p$pview-format-values=yuv420sp;$p$pview-fps-range=15000,30000;$p$pview-fps-range-values=(15000,30000);$p$pview-frame-rate=30;$p$pview-frame-rate-values=30;$p$pview-size=640x480;$p$pview-size-values=1280x720,800x480,720x480,640x480,352x288;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=2560x1920;exposure-compensation=4;

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=640x480,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=2560x1920,2560x1536,2048x1536,2048x1232,1600x1200,1600x960,800x480,640x480;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=640x480;preview-size-values=1280x720,800x480,720x480,640x480,352x288;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=2560x1920;exposure-compensation=4;

编辑:在基于以下意见进行进一步的测试,看来它只是preVIEW已转向了暗比它应该是。实际拍摄的图像比较明亮和曝光compensatiion似乎是工作的罚款。它只是preVIEW是让我头疼。测试在i9003的运行CM11和Nexus 10上运行的股票机器人。

Upon further testing based on comments below, it appears that its just the preview that is turning out darker than it should be. The actual captured image is well lit and exposure compensatiion seems to be working fine. Its just the preview that is giving me a headache. Tested on i9003 running CM11 and Nexus 10 running stock android.

推荐答案

即使我面对这个问题,我通过向摄像机给可变fps的解决了这个问题。 第一次调用 Camera.getParameter.getSupported previewFpsRange(); 在我来说,我得到了(15000至15000),(24000至24000),(30000至30000)及(15000 ,30000)。我试图从设置范围15000至30000 。请确保你传递给不同的数字。

Even I faced this issue, I solved it by giving variable fps to the Camera. First call Camera.getParameter.getSupportedPreviewFpsRange(); In my case I got (15000 to 15000),(24000 to 24000),(30000 to 30000) and (15000,30000). I tried setting range from 15000 to 30000. Make sure that you are passing to different number.

这篇关于Android摄像头preVIEW暗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆