This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

如何使用H3A自动调整白平衡?

Other Parts Discussed in Thread: TVP5146, TVP7002

我有看到以下信息:

linux-driver-examples-psp03.01.01.38/h3a/dm365/

aew_example
This executable is used to verify the functionalities of the AEW.
af_example
This executable is used to verify the functionalities of the AF.

我执行  ./aew_example -t f -c 4 -n 1

其结果为:

root@dm368-evm:~/test# ./aew_example -t f -c 4 -n 1 
input.name = Comdm365evm_enable_pca9543a
posite
input.nadm365evm_enable_pca9543a, status = -121
me = S-Video
input.name = CompoEVM: switch to HD imager video input
nent
input.name = Camera
Calling S_INPUT with index = 3
InitDevice:ioctl:VIDIOC_S_INPUT, selected input index = 3
InitDevice:ioctl:VIDIOC_G_INPUT, selected input, Camera
Following stvpfe-capture vpfe-capture: width = 640, height = 480, bpp = 1
andards availablvpfe-capture vpfe-capture: adjusted width = 640, height = 480, bpp = 1, bytesperline = 640, sizeimage = 307200
e at the input
standard.index = 0
standard.id = b000
standard.frameperiod.numerator = 1001
standard.frameperiod.denominator = 30000
standard.framelines = 525
standard.index = 1
standard.id = 1000
standard.frameperiod.numerator = 1001
standard.frameperiod.denominator = 30000
standard.framelines = 525
standard.index = 2
standard.id = 2000
standard.frameperiod.numerator = 1001
standard.frameperiod.denominator = 30000
standard.framelines = 525
standard.index = 3
standard.id = 8000
standard.frameperiod.numerator = 1001
standanes = 525
standard.index = 4
standard.id = 4000
standard.frameperiod.numerator = 1001
standard.frameperiod.denominator = 30000
standard.framelines = 525
standard.index = 5
standard.id = ff
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 6
standard.id = 7
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 7
standard.id = 8
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 8
standard.id = 10
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 9
standard.id = e0
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 10
standard.id = 100
standard.frameperiod.numerator = 1001
standard.frameperiod.denominator = 30000
standard.framelines = 525
standard.index = 11
standard.id = 200
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 12
standard.id = 400
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 13
standard.id = 800
standard.frameperiod.numerator = 1001
standard.frameperiod.denominator = 30000
standard.framelines = 525
standard.index = 14
standard.id = ff0000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 15
standard.id = 10000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 16
standard.id = 40000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 17
standard.id = 80000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 18
standard.id = 320000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 19
standard.id = 400000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
standard.index = 20
standard.id = 800000
standard.frameperiod.numerator = 1
standard.frameperiod.denominator = 25
standard.framelines = 625
SetDataFormat:setting data format
SetDataFormat:requesting width:640 height:480
SetDataFormat:finally negotiated width:640 height:480
SetDataFormat:driver reports bytes_per_line:640(bug)
SetDataFormat:driver reports size:307200(bug)
SetDataFormat:Finally negitaited width:640 height:480
device buffers:3
buffer:0 phy:0 mmap:0x40184000 length:307200
buffer:1 phy:4b000 mmap:0x401cf000 length:307200
buffer:2 phy:96000 mmap:0x4021a000 length:307200
Queing buffer:0
Queing buffer:0 done 
Queing buffer:1
Queing buffer:1 done 
Queing buffer:2
Queing buffer:2 done 
type = f, test case = 4, number = 1
f
Before SEt Params
Buffer size s 2048
Allocating the buffer
RESULT OF READ 2048
Output File : aew_samp_dm365.txtroot@dm368-evm:~/test#

问:

执行完产生的信息是什么意思?

aew_example是如何自动白平衡?

如果我想实现自动白平衡怎么做?

  • 我使用的是dvsdk4.02软件包,不是IPNC方案。 

    我用的encode来捕获视频图像的。 现在基于RTSP可以实现实时播放。

    我用的sender为 MT9P031。    

  • Juke,

    DM36x内部的H3A是一个数据统计模块,需要用户利用自己的AWB算法,基于统计数据做相应的调节。在DVSDK上没有AWB的算法,需要你自己开发。

  • Chris Meng ,

    那我再DVSDK上该怎么调节白平衡呢??

    我有看到一篇毕业论文,上面有一些介绍:

    3.1.1影响成像质量的因素
    对于本智能监控系统来说,由于上位机需对采集到的图像进行目标检测和跟踪处
    理,所以要求很高的图像质量。对于本设计算法来说,色度、亮度和饱和度为最关心的
    因素,这使得曝光和白平衡为影响成像质量的关键因素。CMOS传感器曝光时间越长,
    采集到的图像越亮,但由于每帧成像时间长,使得帧率下降:曝光时间越短,采集到的
    图像越暗,但帧率也会随之增大。物体的色温会随着光线的变化而变化,这使得即使同
    一物体在不同色温下采集到的图像颜色也不一样。白平衡又叫色彩平衡,它能够告诉传
    感器当前的“白色”看起来像何种颜色并通过传感器记录该色彩。由于白光是其他所有
    颜色的总和,所以CMOS就可以准确的采集到所有颜色信息。在本设计中,通过改变
    RGB三个分量的色彩增益来调节色彩的平衡,同时RGB分量的增加也会影响到图像的
    亮度。


    曝光时间影响到帧率的大小,帧率越大,采集到的视频图像越流畅,帧率越小,视
    频图像越卡。一般帧率为20fps时,人眼就可以看到清晰流畅的图像。在mt9p031.c文
    件中,设置ctrl->value的值为0x4C2,表示设置的曝光时间约为50ms,帧率为20fps。
    在设置白平衡时,使用DM368自带的预览设备Previewer,该设备可以在图像的显示过
    程中对其进行对比度、亮度、RGB增益、白平衡等微调。打开Previewer后,获得设
    备描述符preview_fd,通过ioctl(preview fd,PREV_ENUM_CAP,&c印)查询预览功能,
    找出哪些模块适合用来调整图像。然后通过上位机的指令来确定当前需要设置的参数及
    其大小,最后通过ioctl(preview fd,PREV—SjlARAM,&mod_param)来将模块参数设置
    到预览引擎中,完成图像的微调功能。同时,结合DM368自带的自动白平衡AWB功
    能,完成在不同光线照射下准确采集图像色彩的功能。

    这个Previewer是什么?? 

    如果只是改变RGB分量的增益。  

    mt9p031.c 下有RGB的值

    unsigned int reg[][2] = {
    /* PLL Control */
    { 0x0010, 0x0051}, /*PLL_CONTROL */
    { 0x0011, 0x1C01}, /*PLL Config1 = 0x1701*/
    { 0x0012, 0x0005}, /*PLL Config2 = 0x5*/
    { 0x0010, 0x0053}, /*PLL Control = 0x53*/
    { 0x0007, 0x1F82}, /*(3) GREEN2_GAIN_REG = 0x8*/
    { 0x002B, 0x0008}, /*(3) GREEN1_GAIN_REG = 0x8*/
    { 0x002C, 0x0012}, /*(3) BLUE_GAIN_REG = 0x12*/
    { 0x002D, 0x000A}, /*(3) RED_GAIN_REG = 0xA*/
    { 0x002E, 0x0008}, /*(3) GREEN2_GAIN_REG = 0x8*/


    问题是: RGB的值应该修改为什么??   这个难道需要自己一点点调吗???  

  • Juke,

    白平衡需要知道当前环境的色温,然后进行调节。黄色部分提到的previewer就是DM36x的IPIPE。

    在IPNC的软件里面有TI的2A算法,并且有ISP调试工具ITT来对AWB/RGB2RGB进行调节。

  • Chris Meng ,

    你说的应该是 ImageTuningTool_DM36x_Version2.1.0这个工具吧。

    在DVSDK上该怎么进行调节呢??  

  • 打开Previewer后,获得设备描述符preview_fd,通过ioctl(preview fd,PREV_ENUM_CAP,&c印)查询预览功能,

    找出哪些模块适合用来调整图像。然后通过上位机的指令来确定当前需要设置的参数及

    其大小,最后通过ioctl(preview fd,PREV—SjlARAM,&mod_param)来将模块参数设置

    到预览引擎中,完成图像的微调功能。

    我通过上面的描述的找到了  linux-driver-examples-psp03.01.01.38/imp-prev-rsz/dm365/文件夹

    我grep 了一下发现有几个文件是符合我的测试要求的。

      

    我编译OK,还未实验。

    请问这些文件是不是可以调节白平衡呢??

    NAME
    capture_prev_rsz_onthe_fly_bayer: Capture, preview, Resize &
    Display loopback from Bayer RGB
    source
    capture_prev_rsz_onthe_fly_yuv: Capture, preview, Resize &
    Display loopback from YUV source

    capture_prev_rsz_ss_raw_yuv: Capture, de-interlace using
    Resizer and display loopback
    from composite input (TVP5146)

    do_preview_resize: Application to preview & resize

    do_resize_420_420: Application to resize a YUV 420
    Semi Planar image (NV12)

    do_resize Application to resize and do
    format conversion from UYVY to
    YUV420 Semi Planar (NV12)

    do_resize_420_420 Application to resize a YUV420
    Semi Planar (NV12) image to
    another YUV420 Semi Planar
    (NV12) image of smaller size.

    display application to streamon and
    streamoff

    SYNOPSIS
    capture_prev_rsz_onthe_fly_bayer
    capture_prev_rsz_onthe_fly_yuv
    capture_prev_rsz_ss_raw_yuv
    do_preview_resize
    do_resize_420_420
    do_resize
    display

    DESCRIPTION

    capture_prev_rsz_onthe_fly_bayer
    --------------------------------

    This a loopback application that does capture from a Bayer RGB source such as
    MT9T031 and do On the fly mode processing on the data using IPIPE and Resizer
    and finally save data to SDRAM on a per frame basis. The Resizer is capable of
    doing conversion from UVVY to NV12 format. Appication uses V4L2 API to
    configure the capture device and queue/dequeue buffers in a loop.

    capture_prev_rsz_onthe_fly_yuv
    ------------------------------

    This a loopback application that does capture from a YUV source such as
    TVP5146 or TVP7002 and do On the fly mode processing on the data using IPIPE
    and Resizer and finally save data to SDRAM on a per frame basis. There is no
    processing done in IPIPE for this type of data, but the capture driver design
    requires this to be in the data path of the image. The Resizer is capable of
    doing conversion from UVVY to NV12 format. Appication uses V4L2 API to
    configure the capture device and queue/dequeue buffers in a loop.

    capture_prev_rsz_ss_raw_yuv
    ---------------------------

    This application shows how to de-interlace a YUV interlaced image using Resizer.
    This application captures from TVP5146 composite input, pass the video data to
    Resizer (one shot or single shot mode). The Resizer input is configured to have
    a line length of 4 * width to allow skipping of alternate lines. The height is
    configured to be 1/2 of original image height, resulting in the image scaled up
    vertically by 2x. This is to support the smooth function at application layer
    on a interlaced data.

    do_preview_resize
    -----------------

    This application reads a set of options from the user including the input image
    file and then do Preview and Resize on a Bayer RGB data. The example shows how
    to use the tuning modules in IPIPE to fine tune the image.

    do_resize
    ---------

    This application takes an UYVY image as input and do Resize and format
    conversion from UYVY to NV12 (a.k.a YUV 420 Semi planar)

    do_resize_420_420
    -----------------

    This application shows how to Resize the Y-Plane and C-Plane of a YUV 420 SP
    (NV12) image using the Resizer hardware. The Resize happens in two stages.
    First stage does Resize of Y-Plane and then configure the Resizer driver for
    C-plane and does one more Resize operation for C-Plane Resize. This application
    takes a 720p NV12 image and resize it to half. ie. the image is resized from
    1280x720 to 640x360.

    OPTIONS

    capture_prev_rsz_onthe_fly_bayer
    -t <0/1> 0 - disable Gamma correction, 1 - enable gamma correction
    -f <0/1> 0 - UYVY, 1 - NV12 (YUV 420 Semi planar) output format
    -i <0/1> 0 - input from MT9T031, 1 - input from MT9P031 (TBD)
    -p <0/1> 0 - disable printing frame number, 1 - enable
    -c <0/1> 0 - disable crop, 1 - enable crop

    capture_prev_rsz_onthe_fly_yuv
    -f <0/1> 0 - UYVY, 1 - NV12 (YUV 420 Semi planar) output format
    -p <0/1> 0 - disable printing frame number, 1 - enable
    -h <0/1> 0 - disable frame division, 1 - enable frame division (only
    for TVP7002 to reduce the fps to 30
    -x <0/1> 0 - display from Resizer-A output, 1 - display from Resizer
    B output
    -c <0/1> 0 - disable crop, 1 - enable crop
    -i <0/1> 0 - input from TVP5146 Composite, 1 - TVP5146 S-Video and 2
    TVP7002 Component input
    -r <0/1> 0 - disable resize, 1 - enable resize. Use -w and -u options
    as well
    -w <width> - width of resized image from resizer output
    -u <height> - height of resized image from resizer output

    capture_prev_rsz_ss_raw_yuv
    -f <0/1> - 0 - UYVY , 1 - NV12

    do_preview_resize
    This is an interractive application.

    do_resize_420_420
    Resize a NV12 image using two stages of Resize. First the Y-Plane Resize
    and then the C-Plane Resize.
    -i <input file> - Must be a 1280x720 NV12 image
    -o <output file> - Gets a 640x360 NV12 image
    The output file can be viewed using display utility (with -t option)
    given below.

    do_resize
    -i <input file> - file to read. Should be 720p resolution
    -w <width> of the output image
    -h <height> of the output image
    -t <0/1> 0 - UYVY, 1 - NV12 format
    display
    -c <channel number> 0 - video2 and 1 - video3
    -f <file> to display
    -w <width> of the input image
    -h <height> of the input image
    -f <input file name>

    EXAMPLE USAGE

    for MT9T031 capture-display
    capture_prev_rsz_onthe_fly_bayer -i0 -f0 -i0 -p1 -c0

    for TVP7002 capture-display - no resize
    capture_prev_rsz_onthe_fly_yuv -i2 -f0 -p1

    for TVP7002 capture-display - Resize 1080i/720p to NTSC resolution and display on
    composite output
    capture_prev_rsz_onthe_fly_yuv -i2 -r1 -w720 -u480

    For TVP5146 capture-display using NV12 format
    capture_prev_rsz_ss_raw_yuv -f1

    for doing upscale of 720p to 1080p and format conversion of UYVY to NV12
    do_resize -i video_720p -w 1920 -h 1080 -t1

    for displaying a UYVY image to VID0
    display -c0 -w720 -h480 -t0

    COPYRIGHT
    Refer to source headers

    KNOWN ISSUES

    VERSION
    LSP 2.10

    CHANGELOG
    2.0

    SEE ALSO

  • JUKE CHEN 说:

    Chris Meng ,

    你说的应该是 ImageTuningTool_DM36x_Version2.1.0这个工具吧。

    在DVSDK上该怎么进行调节呢??  

    在ipnc软件里面会有运行一个itt sever,可以采集RAW/YUV数据传给ITT工具。这个RAW/YUV数据是有一个TI的header的格式。

    dvsdk里面没有AWB的算法,无法进行自动白平衡的支持。

    ITT工具安装后会有文档,里面与使用该工具的方法介绍。