我是靠谱客的博主 伶俐高跟鞋,最近开发中收集的这篇文章主要介绍CTS测试中testYuvBurst[1]项,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

(1)源码分析

//cts/tests/camera/src/android/hardware/camera2/cts/BurstCaptureTest.java

/**
     * Test YUV burst capture with full-AUTO control.
     * Also verifies sensor settings operation if READ_SENSOR_SETTINGS is available.
     */
    @Test
    public void testYuvBurst() throws Exception {
        final int YUV_BURST_SIZE = 100;
        testBurst(ImageFormat.YUV_420_888, YUV_BURST_SIZE, true/*checkFrameRate*/,
                false/*testStillBokeh*/);
    }

    /**
     * Test JPEG burst capture with full-AUTO control.
     *
     * Also verifies sensor settings operation if READ_SENSOR_SETTINGS is available.
     * Compared to testYuvBurst, this test uses STILL_CAPTURE intent, and exercises path where
     * enableZsl is enabled.
     */
    @Test
    public void testJpegBurst() throws Exception {
        final int JPEG_BURST_SIZE = 10;
        testBurst(ImageFormat.JPEG, JPEG_BURST_SIZE, false/*checkFrameRate*/,
                false/*testStillBokeh*/);
    }

    /**
     * Test YUV burst capture with full-AUTO control and STILL_CAPTURE bokeh mode.
     * Also verifies sensor settings operation if READ_SENSOR_SETTINGS is available.
     */
    @Test
    public void testYuvBurstWithStillBokeh() throws Exception {
        final int YUV_BURST_SIZE = 100;
        testBurst(ImageFormat.YUV_420_888, YUV_BURST_SIZE, true/*checkFrameRate*/,
                true/*testStillBokeh*/);
    }
    
	//...
  1. 拿到previewSize (最大的preview size,不大于1080P),拿到stillSize (最大的YUV_420_888 Size);
  2. 拿到maxPipelineDepth (REQUEST_PIPELINE_MAX_DEPTH),拿到maxSyncLatency (SYNC_MAX_LATENCY);
  3. 拿到minStillFrameDuration(stillSize的OutputMinFrameDuration);
  4. 分别创建previewBuilder 和 burstBuilder (都是TEMPLATE_PREVIEW),并为burstBuilder设置CONTROL_AE_TARGET_FPS_RANGE 、CONTROL_AE_LOCK (true)、CONTROL_AWB_LOCK (true);
  5. 开始预览(用resultListener 监听预览结果),并创建100个burst request;
  6. while循环遍历每个resultListener 结果,并检查其CONTROL_AE_STATE 、 CONTROL_AWB_STATE,如果aeState 是 AE_STATE_CONVERGED或者AE_STATE_FLASH_REQUIRED ,且awbState 是AWB_STATE_CONVERGED算有效帧,检测:如果前150帧以内都没有检测到有效帧,报failed;
  7. lock住previewBuilder的 CONTROL_AE_LOCK 、CONTROL_AWB_LOCK 、CONTROL_AF_TRIGGER_START,重新预览;
  8. 检测此时的sensor setting (burstExposure / burstFrameDuration / burstSensitivity 都要大于0);
  9. 进行burst拍照,检测burstResult(SENSOR_EXPOSURE_TIME和SENSOR_SENSITIVITY),并计算每一侦的frameDurations;
  10. 检测平均frameDurations是否小于等于minStillFrameDuration;

简单看一下判断条件:

final float FRAME_DURATION_MARGIN_FRACTION = 0.1f;
//获取的metadata当中的frame duration
final long minStillFrameDuration = config.getOutputMinFrameDuration(fmt, stillSize);

//计算出frameDurationBound
final long frameDurationBound = (long) (minStillFrameDuration * (1 + FRAME_DURATION_MARGIN_FRACTION) );

//计算出平均frameDurations
float meanFrameDuration = (float) meanFrameSum / frameDurations.size();

//判断平均frameDurations是否小于frameDurationBound
assertTrue(
                String.format("Cam %s: Burst frame duration mean %.1f ns is larger than " +
                    "acceptable, expecting below %d ns, allowing below %d", cameraId,
                    meanFrameDuration, minStillFrameDuration, frameDurationBound),
                meanFrameDuration <= frameDurationBound);

(2)Failed Demo

03-10 09:39:52.590 19601 19630 E TestRunner: failed: testYuvBurst[1](android.hardware.camera2.cts.BurstCaptureTest)
03-10 09:39:52.590 19601 19630 E TestRunner: ----- begin exception -----
03-10 09:39:52.591 19601 19630 E TestRunner: junit.framework.AssertionFailedError: Cam 0: Burst frame duration mean 72727504.0 ns is larger than acceptable, expecting below 50000000 ns, allowing below 55000000
03-10 09:39:52.591 19601 19630 E TestRunner: 	at junit.framework.Assert.fail(Assert.java:50)
03-10 09:39:52.591 19601 19630 E TestRunner: 	at junit.framework.Assert.assertTrue(Assert.java:20)
03-10 09:39:52.591 19601 19630 E TestRunner: 	at android.hardware.camera2.cts.BurstCaptureTest.burstTestByCamera(BurstCaptureTest.java:417)
03-10 09:39:52.591 19601 19630 E TestRunner: 	at android.hardware.camera2.cts.BurstCaptureTest.testBurst(BurstCaptureTest.java:123)
03-10 09:39:52.591 19601 19630 E TestRunner: 	at android.hardware.camera2.cts.BurstCaptureTest.testYuvBurst(BurstCaptureTest.java:56)

可以看到实际的平均frameDurations = 72727504.0,而frameDurationBound = 50000000 * (1 + 0.1) = 55000000,从而导致frameDurations大于frameDurationBound,进而出现Failed项。

(3)修改方案

在metadata当中修改最大YUV_420_888 Size的frame duration。

		CONFIG_ENTRY_VALUE(HAL_PIXEL_FORMAT_BLOB, MINT64) //13mp 4:3
        CONFIG_ENTRY_VALUE(4160, MINT64)        // width
        CONFIG_ENTRY_VALUE(3120, MINT64)        // height
        CONFIG_ENTRY_VALUE(MTK_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, MINT64)   // output
        //CONFIG_ENTRY_VALUE(50000000, MINT64)    // frame duration
        CONFIG_ENTRY_VALUE(66666666, MINT64)    // frame duration
        CONFIG_ENTRY_VALUE(33333333, MINT64)    // stall duration

将metadata当中的最大YUV Size的 frame duration由原来的50000000修改成66666666,按照上面的计算公式可得:
72727504.0 < 66666666 * (1 + 0.1) = 73333332.6,进而得到frameDurations <= frameDurationBound,所以可以Pass。

最后

以上就是伶俐高跟鞋为你收集整理的CTS测试中testYuvBurst[1]项的全部内容,希望文章能够帮你解决CTS测试中testYuvBurst[1]项所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部