android–Camera2 API设置自定义白平衡和温度颜色

android–Camera2 API设置自定义白平衡和温度颜色,第1张

概述我正在尝试为白平衡&设置自定义值.我相机应用程序中的温度颜色.我正在使用camera2API,我正在尝试不同的方法来设置此值.我从excel文件中找到了一个方法,从白平衡值到100到100.000之间获得正确的RGB温度矩阵[红色,绿色,蓝色].我将此方法附加到Seekbar并且其工作正常,当我尝试将某

我正在尝试为白平衡&设置自定义值.我相机应用程序中的温度颜色.我正在使用camera2 API,我正在尝试不同的方法来设置此值.我从excel文件中找到了一个方法,从白平衡值到100到100.000之间获得正确的RGB温度矩阵[红色,绿色,蓝色].

我将此方法附加到Seekbar并且其工作正常,当我尝试将某些东西聚焦时,我的问题出现,然后它变成粉红色.屏幕上任何一种灯都像粉红色的火炬.

我正在以这种方式设置值:

mPrevIEwRequestBuilder.set(CaptureRequest.color_CORRECTION_MODE, CaptureRequest.color_CORRECTION_MODE_transform_MATRIX);RggbChannelVector rggb = getTemperatureVector(seekBackSelectedTemperature);mPrevIEwRequestBuilder.set(CaptureRequest.color_CORRECTION_GAINS, myRggbChannelVector);

换句话说,我获取矩阵的方法是这样的:

 public static RggbChannelVector getTemperatureVector (int WhiteBalanceValue){    float InsertTemperature = WhiteBalanceValue;    float temperature = InsertTemperature / 100;    float red;    float green;    float blue;    //Calculate red    if (temperature <= 66)        red = 255;    else {        red = temperature - 60;        red = (float) (329.698727446 * (Math.pow((double) red, -0.1332047592)));        if (red < 0)            red = 0;        if (red > 255)            red = 255;    }    //Calculate green    if (temperature <= 66) {        green = temperature;        green = (float) (99.4708025861 * Math.log(green) - 161.1195681661);        if (green < 0)            green = 0;        if (green > 255)            green = 255;    } else        green = temperature - 60;    green = (float) (288.1221695283 * (Math.pow((double) red, -0.0755148492)));    if (green < 0)        green = 0;    if (green > 255)        green = 255;    //calculate blue    if (temperature >= 66)        blue = 255;    else if (temperature <= 19)        blue = 0;    else {        blue = temperature - 10;        blue = (float) (138.5177312231 * Math.log(blue) - 305.0447927307);        if (blue < 0)            blue = 0;        if (blue > 255)            blue = 255;    }    RggbChannelVector finalTemperatureValue = new RggbChannelVector(red/255,(green/255)/2,(green/255)/2,blue/255);    return finalTemperatureValue;}

也许是因为我的CaptureRequest方法不正确,但我找不到解决方法.

解决方法:

将模板更改为Still_capture或手动模板后,它可以使用下一个方法:

 captureBuilder.set(CaptureRequest.CONTRol_AWB_MODE, CaptureRequest.CONTRol_AWB_MODE_OFF);        // adjust color correction using seekbar's params        captureBuilder.set(CaptureRequest.color_CORRECTION_MODE, CaptureRequest.color_CORRECTION_MODE_transform_MATRIX);        captureBuilder.set(CaptureRequest.color_CORRECTION_GAINS, CameraCapabilitIEs.colorTemperature(Integer.parseInt(awbMode)));public static RggbChannelVector colorTemperature(int whiteBalance) {    float temperature = whiteBalance / 100;    float red;    float green;    float blue;    //Calculate red    if (temperature <= 66)        red = 255;    else {        red = temperature - 60;        red = (float) (329.698727446 * (Math.pow((double) red, -0.1332047592)));        if (red < 0)            red = 0;        if (red > 255)            red = 255;    }    //Calculate green    if (temperature <= 66) {        green = temperature;        green = (float) (99.4708025861 * Math.log(green) - 161.1195681661);        if (green < 0)            green = 0;        if (green > 255)            green = 255;    } else {        green = temperature - 60;        green = (float) (288.1221695283 * (Math.pow((double) green, -0.0755148492)));        if (green < 0)            green = 0;        if (green > 255)            green = 255;    }    //calculate blue    if (temperature >= 66)        blue = 255;    else if (temperature <= 19)        blue = 0;    else {        blue = temperature - 10;        blue = (float) (138.5177312231 * Math.log(blue) - 305.0447927307);        if (blue < 0)            blue = 0;        if (blue > 255)            blue = 255;    }    Log.v(TAG, "red=" + red + ", green=" + green + ", blue=" + blue);    return new RggbChannelVector((red / 255) * 2, (green / 255), (green / 255), (blue / 255) * 2);}
总结

以上是内存溢出为你收集整理的android – Camera2 API设置自定义白平衡和温度颜色全部内容,希望文章能够帮你解决android – Camera2 API设置自定义白平衡和温度颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1116476.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存