isp 3a数据上报内容分析

一,内容简介

3a在isp处理过程中起着决定性的作用,感知现实环境,正确地配置相机,为其他的处理提供参考信息。

3a isp stat数据上报将ae awb af的统计信息上报到user层,并为3a算法提供数据参考。如图,3个so分别代表ae算法,awb算法和af算法,算法计算的基础就是3a stat metadata。

二,ISP统计信息介绍

典型的ISP Pipeline如下图所示

BLC(Black Level Correction)
NR(Noise Reduction)
LSC(Lens Shading Correction)
WB(White Balance Gain)
CSM(Color Space Matrix)
CCM(color corr matrix)

3A统计信息在ISP Pipeline中输出的位置

3A输出信息比较典型的配置如下

AE的统计信息

主要包括R、G、B直方图和亮度信息,ROI(Region Of Interest)

统计区域和ROI中R/G/B的256-bin直方图
统计区域和ROI中Y的256-bin直方图
统计区域和ROI中RGB combine直方图
对于不同测光(点测光、中心测光、矩阵测光),可以把全图分成M*N块,按照不同测光每一块的权重不一样。

AWB统计信息

选取统计区域并分成M*N个格子
统计每个格子的R/G/B均值与白点个数(白点可以有参数规定,根据一个像素点的{R/G, B/G}是否在特定区域来定
统计每个格子R/G和B/G的均值等

AF统计信息

选取统计区域并分成M*N个格子
统计每个格子Focus value

                        

三,rk3288 isp1的3a stats研究

3a stats数据上报在pipe流的具体位置,如图:

3a stats数据上报metadata整体内容,

/**
 * struct rkisp1_stat_buffer - Rockchip ISP1 Statistics Data
 *
 * @cifisp_awb_stat: statistics data for automatic white balance
 * @cifisp_ae_stat: statistics data for auto exposure
 * @cifisp_af_stat: statistics data for auto focus
 * @cifisp_hist_stat: statistics histogram data
 */
struct cifisp_stat {
    struct cifisp_awb_stat awb;
    struct cifisp_ae_stat ae;
    struct cifisp_af_stat af;
    struct cifisp_hist_stat hist;
    struct cifisp_embedded_data emd;
}

1,ae信息上报

相关函数 rkisp1_stats_get_bls_meas 和 rkisp1_stats_get_aec_meas_v10

结构体
struct cifisp_ae_stat {

/**统计亮度信息,9*9块曝光区域**/
    unsigned char exp_mean[81];
/**
 * struct cifisp_bls_meas_val - BLS measured values
 * @meas_r: Mean measured value for Bayer pattern R
 * @meas_gr: Mean measured value for Bayer pattern Gr
 * @meas_gb: Mean measured value for Bayer pattern Gb
 * @meas_b: Mean measured value for Bayer pattern B
 */
    struct cifisp_bls_meas_val bls_val;
}
exp_mean平均亮度值。感兴趣区域(ROI,region of interest),ROI区域用于指定计算统计亮度的区域,比如常见的取整个画面,也可以居中取一块区域,而在车载产品中可以居中偏下取一块区域,代码中采用居中取9*9块。亮度值统计需要配合曝光区域权重计算。曝光区域权重,又名ae分区权重,此版本 xml 权重个数必须为 9x9 个,一般情况下的曝光权重是与整个画面对应的。每一块的值代表了该区域参与最终计算最终统计亮度的权重值, 权重值越高表示该区域对整体画面亮度越大,权重为0表示画面亮度与该区域没有关系。
bls:黑电平校正信息。参数依次为 r、gr、gb、b 通道相应的黑电平值。isp param中blsData: 12bit,固定减模式,不同分辨率需对应不同 cell。

2,awb信息上报

/**
 * struct cifisp_bls_meas_val - AWB measured values
 *
 * @cnt: White pixel count, number of "white pixels" found during laster measurement
 * @mean_y_or_g: Mean value of Y within window and frames, Green if RGB is selected.
 * @mean_cb_or_b: Mean value of Cb within window and frames, Blue if RGB is selected.
 * @mean_cr_or_r: Mean value of Cr within window and frames, Red if RGB is selected.
 */
struct cifisp_awb_meas {
    unsigned int cnt;
    unsigned char mean_y_or_g;
    unsigned char mean_cb_or_b;
    unsigned char mean_cr_or_r;
}

cnt从寄存器CIF_ISP_AWB_WHITE_CNT_V10直接读取

mean_cr_or_r窗口和帧内Cr的平均值,如果选择了RGB,则为红色

mean_cb_or_b窗口和帧内Cb的平均值,如果选择RGB,则为蓝色

mean_y_or_g窗口和帧内Y的平均值,如果选择了RGB,则为绿色

ISP 内部硬件会根据白点条件统计出所有符合条件的白点的 RGB 三通道均值。软件上
AWB 会根据三通道的统计均值去判断当前为何种光源,该采用哪个光源的参数。所以白点
条件是影响白平衡最终结果以及选择光源的非常重要的影响因子。

3,af信息上报

/**
 * struct cifisp_af_stat - statistics auto focus data
 *
 * @window: AF measured value of window x
 *
 * The module measures the sharpness in 3 windows of selectable size via
 * register settings(ISP_AFM_*_A/B/C)
 */
struct cifisp_af_stat {
    struct cifisp_af_meas_val window[CIFISP_AFM_MAX_WINDOWS];
}

/**
 * struct cifisp_af_meas_val - AF measured values
 *
 * @sum: sharpness, refer to datasheet for definition
 * @lum: luminance, refer to datasheet for definition
 */
struct cifisp_af_meas_val {
    unsigned int sum;//锐利情形
    unsigned int lum;//明亮度
}

三个窗口通过param下发xy和size(iqfiles data)到driver层,驱动统计三个窗口的锐度和亮度通过stat上报到user层,实现af的硬件计算功能

Clarity/清晰度和Sharpness/锐度的区别在于,清晰对是提升整体照片边缘范围性的Contrast/对比度,而Sharpness/锐度则仅仅是针对边缘减少黑白色阶的过度,让过度更生硬从而边缘锐利。
口味重的初学者非常喜欢将Sharpness/锐度调整的很高,想让画面呈现刀锋一样的锐利,可是通常这么做的后果就是,照片看起来回非常辣眼睛,不耐看。
Sharpness/锐度的调整是基于物体边缘对比度的加强,本来过渡很自然,但加强锐度后,过渡就变得很生硬,所以边缘清晰度加强。
HSL Hue/色调 Saturation/饱和度 Luminance/明亮度
之前说过数码时代是把画面打散成单独的像素储存,相比胶片时代的Darkroom/暗房只能整体调色,数字时代的Lightroom就可以单独对每一块像素点进行调整。
于是HSL的功能就是可以针对不同的像素进行调整,可以单独调整某一个颜色的色相,比如红色可以调整为红偏黄,Aqua/浅绿可以向右调整为浅绿偏蓝,Magenta/洋红向左偏紫向右可以偏红。Hue/色相调整结束可以来调整Saturation/饱和度,同样也可以单独调整。然后再是单独调整每个色彩的Luminance/明亮度。

4,hist stat信息上报

/**
 * struct cifisp_hist_stat - statistics histogram data
 *
 * @hist_bins: measured bin counters
 *
 * Measurement window divided into 32 sub-windows, set
 * with ISP_HIST_XXX
 */
struct cifisp_hist_stat {
    unsigned int hist_bins[32];
}

histogram data直方图,又称质量分布图,是一种统计报告图

主要作用是将过曝的几个 hist 的百分比传给应用层。 从第几个 bin 开始为过曝 hist,累加计算到最大 bin 的过曝百分比传给上层应用。

5,ae hdr信息上报,rk3288不支持只有结构体形态

结构体定义

#define CIFISP_PREISP_GOC_CURVE_SIZE 34
typedef struct cifisp_preisp_hdr_ae_embeded_type {
    struct cifisp_preisp_dspmsg_head head;
    struct cifisp_preisp_hdrae_result result;

/*Gamma Out CurveGamma out 曲线*/
    unsigned short cifisp_preisp_goc_curve[CIFISP_PREISP_GOC_CURVE_SIZE];
} cifisp_preisp_hdr_ae_embeded_type_t;
struct cifisp_preisp_dspmsg_head {
    unsigned int mesg_total_size;
    unsigned int frame_id;
    unsigned int mesg_count;
};
#define CIFISP_PREISP_HDRAE_HIST_BIN_NUM    (1 << 8)
#define CIFISP_PREISP_HDRAE_MAXFRAMES        3
#define CIFISP_PREISP_HDRAE_MAXGRIDITEMS    (15 * 15)
struct cifisp_preisp_hdrae_result {
    unsigned int mesg_id;
    unsigned int mesg_size;
    struct cifisp_preisp_hdrae_oneframe_result oneframe[CIFISP_PREISP_HDRAE_MAXFRAMES];
    struct cifisp_preisp_hdrae_OE_meas_res OEMeasRes;
    struct cifisp_preisp_hdrae_DRIndex_res DRIndexRes;
    unsigned int reg_exp_time[3];
    unsigned int reg_exp_gain[3];
    unsigned int lgmean;
};
struct cifisp_preisp_hdrae_hist_meas_res {
    unsigned int hist_bin[CIFISP_PREISP_HDRAE_HIST_BIN_NUM];
};

struct cifisp_preisp_hdrae_mean_meas_res {
    unsigned short y_meas[CIFISP_PREISP_HDRAE_MAXGRIDITEMS];
};
struct cifisp_preisp_hdrae_oneframe_result {
    struct cifisp_preisp_hdrae_hist_meas_res hist_meas;
    struct cifisp_preisp_hdrae_mean_meas_res mean_meas;
};
struct cifisp_preisp_hdrae_OE_meas_res{
    unsigned int OE_Pixel;
    unsigned int SumHistPixel;
    unsigned int SframeMaxLuma; 
};
struct cifisp_preisp_hdrae_DRIndex_res{
    unsigned int fNormalIndex;
    unsigned int fLongIndex;
};

内容分析

cifisp_preisp_dspmsg_head携带的信息可能与DSP 人脸识别算法需要用的参数有关。未找到具体相关资料。现在很多pre-isp会内置一些npu(dsp)算法功能来达到ai-isp的功能。
cifisp_preisp_hdrae_result携带的信息为hdr模块数据,HDR 的术语是宽动态范围,非 HDR 相机拍摄的照片曝光范围有限,称为低动态范围 (LDR),会导致高光或阴影中的细节丢失。在摄影中,动态范围以曝光值(EV) 差异(称为光圈)来衡量。现代CMOS 图像传感器通常可以通过单次曝光捕获高动态范围

cifisp_preisp_goc_curve携带的信息为伽马曲线输出,

  • 17
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值