การเปลี่ยนแปลงการกำหนดค่ากล้องและระบบ การเปลี่ยนแปลงการกำหนดค่ากล้องและระบบ

การจัดการและการใช้งานการกำหนดค่ากล้องและระบบได้รับการอัปเดตใน Extended View System (EVS) 1.1 เนื่องจาก EVS 1.0 ไม่มีวิธีการสืบค้นข้อมูลอุปกรณ์กล้องและการกำหนดค่าระบบ นักพัฒนาแอปจึงต้องรับข้อมูลดังกล่าวด้วยตนเอง ตัวอย่างเช่น ไคลเอนต์ต้องมีข้อมูลการปรับเทียบกล้อง หากใช้งานแอปคอมพิวเตอร์วิทัศน์บางตัว

เพื่อบรรเทาสถานการณ์นี้ EVS 1.1 ได้ขยายตัวอธิบายอุปกรณ์กล้องด้วยข้อมูลเมตาของกล้อง และจัดเตรียมวิธีการต่างๆ ที่ช่วยให้ไคลเอ็นต์สามารถรับข้อมูลอุปกรณ์กล้องและข้อมูลการกำหนดค่าระบบได้

import android.frameworks.cameraservice.device@2.0::CameraMetadata;
import android.frameworks.cameraservice.common@2.0::CameraMetadataType;

/**
 * Structure describing the basic properties of an EVS camera, extended
 * from its v1.0 declaration.
 *
 * The HAL is responsible for filling out this structure for each
 * EVS camera in the system.
 */
struct CameraDesc {
    @1.0::CameraDesc v1;
    /**
     * Store camera metadata such as lens characteristics.
     */
    CameraMetadata metadata;
};

CameraDesc ได้รับการขยายเพื่อให้มีข้อมูลเมตาของอุปกรณ์กล้อง และประเภทนี้นำเข้าจาก android.frameworks.cameraservice.device@2.0 ตัวเลือกการออกแบบนี้ช่วยให้ผู้จำหน่ายสามารถใช้ camera_metadata_t ในการใช้งานของตน และใช้ประโยชน์จาก API ที่กำหนดไว้ใน ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS ไดรเวอร์ EVS สามารถใช้ประเภทนี้เพื่อระบุว่าโมดูลกล้องแต่ละตัวรองรับการกำหนดค่าสตรีมใด นอกจากนี้ ผู้จำหน่ายไม่สามารถใช้ประเภทข้อมูลเมตาของตนเองเพื่อส่งข้อมูลอื่นที่ไม่ได้ กำหนดไว้ใน Android ตามที่อธิบายไว้ใน ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS ไดรเวอร์ EVS สามารถใช้ประเภทนี้เพื่อระบุว่าโมดูลกล้องแต่ละตัวรองรับการกำหนดค่าสตรีมใด

เปิดอุปกรณ์กล้องด้วยการกำหนดค่าสตรีมที่ต้องการ

import android.hardware.camera.device@3.2::Stream;

/**
 * Get the IEvsCamera associated with a cameraId from a CameraDesc
 *
 * Given a camera's unique cameraId from CameraDesc, returns the
 * IEvsCamera interface associated with the specified camera. When
 * done using the camera, the caller may release it by calling closeCamera().
 *
 * @param  cameraId  A unique identifier of the camera.
 * @param  streamCfg A stream configuration the client wants to use.
 * @return evsCamera EvsCamera object associated with a given cameraId.
 */
openCamera_1_1(string cameraId, Stream streamCfg) generates (IEvsCamera evsCamera);

หนึ่งในฟิลด์ข้อมูลเมตาที่ Android กำหนดคือ ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS ไดรเวอร์ EVS สามารถใช้ประเภทนี้เพื่อระบุว่าโมดูลกล้องแต่ละตัวรองรับการกำหนดค่าสตรีมใด ตัวอย่างเช่น การใช้งานอ้างอิงที่ให้ไว้ด้านล่างนี้จะแสดงข้อมูลของการกำหนดค่าสตรีมที่รองรับแต่ละรายการ:

  • รหัสสตรีม
  • ความกว้าง
  • ความสูง
  • ทิศทาง (อินพุตหรือเอาต์พุต)
  • อัตราเฟรม

ไคลเอนต์หลายตัวบนอินสแตนซ์ HW ของกล้องตัวเดียว

หากไคลเอนต์ร้องขอให้เปิดอุปกรณ์กล้องที่ใช้งานอยู่แล้ว ผู้จัดการ EVS จะเปรียบเทียบการกำหนดค่าสตรีมที่ร้องขอกับการกำหนดค่าที่ใช้งานอยู่ หากมีความแตกต่างกัน ตัวจัดการ EVS จะส่งกลับวัตถุ IEvsCamera เป็นโมฆะ ไคลเอ็นต์ ต้อง จัดการกับความล้มเหลวที่อาจเกิดขึ้นได้อย่างเหมาะสม

ไฟล์การกำหนดค่าอ้างอิง

ไฟล์การกำหนดค่าอ้างอิงที่รวมอยู่ใน EVS 1.1 เขียนในรูปแบบ XML และผู้จำหน่ายสามารถใช้ไฟล์ DTD ที่รวมไว้ (แสดงด้านล่าง) เพื่อตรวจสอบความถูกต้องของไฟล์การกำหนดค่าตัวอย่าง (แก้ไข) หรือใช้ไฟล์ของตนเองหากต้องการใช้รูปแบบเดียวกัน ไฟล์ DTD ยังให้คำอธิบายโดยละเอียดสำหรับแต่ละองค์ประกอบและคุณลักษณะ

<?xml version='1.0' encoding='utf-8'?>
<!-- Copyright (C) 2019 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- Author : changyeon@google.com Version: 1.0 --> <!ELEMENT configuration (system,camera,display)> <!-- System Configuration that contains below informations: - The dimension of the vehicle. - Number of cameras available to EVS. - List of predefined use cases. --> <!ELEMENT system (dimension,num_cameras,supported_use_case*)> <!-- The x, y, and z dimension of the vehicle in the unit of centimeters. Axes are defined at https://source.android.com/docs/core/interaction/sensors/sensor-types#auto_axes --> <!ELEMENT dimension EMPTY> <!ATTLIST dimension x CDATA '0' y CDATA '0' z CDATA '0' > <!-- The number of cameras that are available to EVS on the vehicle. This must be equal to the number of camera elements of the device element. --> <!ELEMENT num_cameras EMPTY> <!ATTLIST num_cameras value CDATA #REQUIRED > <!-- List of predefined use cases --> <!ELEMENT supported_use_case (use_case)*> <!-- Predefined configurations for each of listed use cases. @attr id : Unique string identifier of this use case. @attr camera : ID of either a single camera device or a camera group. @attr stream_id: Preferred stream configuration of camera device/group that is set by camera attribute. --> <!ELEMENT use_case EMPTY> <!ATTLIST use_case id CDATA #REQUIRED camera CDATA #REQUIRED stream_id CDATA #REQUIRED > <!-- Device descriptions --> <!ELEMENT camera (group|device)*> <!-- Camera group descriptor @attr group_id : Unique logical camera group identifier. Camera device use this to be a member of the group. @attr device_id : Comma-separated list of unique camera identifiers of member camera devices. @attr synchronized: Boolean field that tells whether or not this camera is synchronized with other cameras in the same group. This is ineffective if there is a single camera in the group or a group is invalid. --> <!ELEMENT group (caps)> <!ATTLIST group group_id CDATA #REQUIRED device_id CDATA #REQUIRED synchronized CDATA #REQUIRED > <!-- Please note that a camera may have stream configurations. If it has, all stream configurations must be supported by each camera device in the group. --> <!-- Camera device descriptor @attr id : Unique camera identifier. @attr position : Must be one of front, rear, left, or right. --> <!ELEMENT device (caps,characteristics*)> <!ATTLIST device id CDATA #REQUIRED position CDATA #REQUIRED > <!-- Camera metadata that contains: - A list of supported controls. - A list of supported stream configurations. --> <!ELEMENT caps (supported_controls|stream)*> <!-- A list of supported controls. This must be a subset of android.hardware.automotive.evs@1.1::CameraParam. --> <!ELEMENT supported_controls EMPTY> <!ATTLIST supported_controls value CDATA #REQUIRED > <!-- A list of supported output sizes. --> <!ELEMENT stream EMPTY> <!ATTLIST stream id CDATA #REQUIRED width CDATA #REQUIRED height CDATA #REQUIRED format CDATA #REQUIRED > <!-- Camera module characteristics including its optics and imaging sensor. --> <!ELEMENT characteristics (parameter)*> <!ELEMENT parameter EMPTY> <!-- A name of camera characteristic. This must be a subset of android.hardware.automotive.evs@1.1::CameraCharacteristics. --> <!ATTLIST parameter name CDATA #REQUIRED type CDATA #REQUIRED size CDATA #REQUIRED value CDATA #REQUIRED > <!-- Available display devices --> <!ELEMENT display (display_device)*> <!-- Display device descriptor @attr id : Unique display identifier. @attr position: Display mount location. --> <!ELEMENT display_device (supported_formats)*> <!ATTLIST display_device id CDATA #REQUIRED position CDATA #REQUIRED > <!-- A list of supported input data formats. @attr value: A comma separated list of input data formats --> <!ELEMENT supported_formats EMPTY> <!ATTLIST supported_formats value CDATA #REQUIRED >

ไฟล์การกำหนดค่าตัวอย่างแสดงอยู่ด้านล่าง (ตัวอย่างมีข้อมูลตัวเลขจำลอง)

<?xml version='1.0' encoding='utf-8'?>
<!-- Copyright (C) 2019 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- Extended View System Example Configuration

     Android Automotive axes are used to define coordinates.
     See https://source.android.com/docs/core/interaction/sensors/sensor-types#auto_axes

     Use evs_configuration.dtd with xmllint tool, to validate XML configuration file
-->

<configuration>
    <!-- system configuration -->
    <system>
        <!-- reference dimension of the vehicle in the unit of centimeters -->
        <dimension x='200' y='400' z='100' />

        <!-- number of cameras available to EVS -->
        <num_cameras value='2'/>

        <!-- list of supported use cases -->
        <supported_use_case>
            <!-- use case configuration -->
            <use_case
                id='rear_view'
                camera='/dev/video1'
                stream_id='1'
            />

            <!-- use case configuration -->
            <use_case
                id='surround_view'
                camera='group1'
                stream_id='0'
            />
        </supported_use_case>
    </system>

    <!-- camera device information -->
    <camera>
        <!-- camera group 0 -->
        <group group_id='group0'
               device_id='/dev/video1,/dev/video2'
               synchronized='false'
        >
            <caps>
                <stream id='0' width='640' height='360' format='V4L2_PIX_UYUV'/>
            </caps>
        </group>

        <!-- camera device starts -->
        <device id='/dev/video1' position='rear'>
            <caps>
                <!-- list of supported controls -->
                <supported_controls
                    value='BRIGHTNESS,
                           CONTRAST,
                           AUTO_WHITE_BALANCE,
                           WHITE_BALANCE_TEMPERATURE,
                           SHARPNESS,
                           AUTO_EXPOSURE,
                           ABSOLUTE_EXPOSURE,
                           AUTO_FOCUS,
                           ABSOLUTE_ZOOM'
                />

                <!-- list of supported stream configurations -->
                <stream id='0' width='1280' height='1080' format='V4L2_PIX_NV21'/>
                <stream id='1' width='1280' height='1080' format='V4L2_PIX_YUYV'/>
                <stream id='2' width='1280' height='1080' format='V4L2_PIX_UYUV'/>
                <stream id='3' width='640'  height='360'  format='V4L2_PIX_NV21'/>
                <stream id='4' width='640'  height='360'  format='V4L2_PIX_YUYV'/>
                <stream id='5' width='640'  height='360'  format='V4L2_PIX_UYUV'/>
                <stream id='6' width='320'  height='240'  format='V4L2_PIX_NV21'/>
                <stream id='7' width='320'  height='240'  format='V4L2_PIX_YUYV'/>
                <stream id='8' width='320'  height='240'  format='V4L2_PIX_UYUV'/>
            </caps>

            <!-- list of parameters -->
            <characteristics>
                <!-- Lens distortion information. See
                     https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#LENS_DISTORTION
                -->
                <parameter
                    name='LENS_DISTORTION'
                    type='float'
                    size='5'
                    value='0.0,0.0,0.0,0.0,0.0'
                />

                <!-- Camera intrinsic calibration matrix. See
                     https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#LENS_INTRINSIC_CALIBRATION
                -->
                <parameter
                    name='LENS_INTRINSIC_CALIBRATION'
                    type='float'
                    size='5'
                    value='0.0,0.0,0.0,0.0,0.0'
                />

                <!-- Camera pose translation and rotation. See
                     https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#LENS_POSE_TRANSLATION
                     https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#LENS_POSE_ROTATION
                -->
                <parameter
                    name='LENS_POSE_TRANSLATION'
                    type='float'
                    size='3'
                    value='0.0,0.0,0.0'
                />
                <parameter
                    name='LENS_POSE_ROTATION'
                    type='float'
                    size='4'
                    value='0.0,0.0,0.0,0.0'
                />
            </characteristics>
        </device>
        <device id='/dev/video2' position='front'>
            <caps>
                <!-- list of supported stream configurations -->
                <stream id='0' width='1280' height='1080' format='V4L2_PIX_NV21'/>
            </caps>
        </device>
    </camera>

    <!-- display device starts -->
    <display>
        <display_device id='display0' position='driver'>
            <!-- list of supported input formats
                 This must be a subset of android_pixel_format_t enum.
            -->
            <supported_formats
                value='RGBA_8888,
                       YUYV,
                       UYVY'
            />
        </display_device>
    </display>
</configuration>