कैमरा कॉन्फ़िगर किया जा रहा है

CameraConfig मुख्य कैमरा सेंसर की खूबियों के बारे में बताता है. इनमें ये चीज़ें शामिल हैं:

  • कैमरा आईडी
  • उपलब्ध होने पर, चाहे डेप्थ सेंसर इस्तेमाल किया जाएगा या नहीं
  • कैमरा किस दिशा में है:
    • सामने वाला हिस्सा (सेल्फ़ी)
    • रियर-फ़ेसिंग (वर्ल्ड)
  • FPS (फ़्रेम प्रति सेकंड) की रेंज
  • सीपीयू इमेज के डाइमेंशन
  • जीपीयू टेक्सचर डाइमेंशन
  • मौजूद होने पर, डिवाइस के स्टीरियो मल्टी-कैमरा का इस्तेमाल किया जाएगा या नहीं

नया ARCore सेशन बनाते समय, ARCore setCameraConfig का इस्तेमाल करके, कैमरा कॉन्फ़िगरेशन सेट करता है. यह कॉन्फ़िगरेशन getSupportedCameraConfigs(CameraConfigFilter) के दिए गए उपलब्ध कॉन्फ़िगरेशन की सूची से सबसे सही तरीके से मेल खाता है. आपका ऐप्लिकेशन, अपनी ज़रूरतों के हिसाब से फ़िल्टर करके, रनटाइम के दौरान किसी डिवाइस के लिए उपलब्ध कैमरा कॉन्फ़िगरेशन को कम करने के लिए, CameraConfigFilter का इस्तेमाल कर सकता है.

फ़िल्टर करने के सामान्य इस्तेमाल के उदाहरण:

  • कैमरा कैप्चर फ़्रेम रेट को 30 FPS (फ़्रेम प्रति सेकंड) तक सीमित किया जा रहा है. जिन डिवाइसों पर 60 FPS (फ़्रेम प्रति सेकंड) की सुविधा काम करती है, उन पर ARCore उन कैमरा कॉन्फ़िगरेशन को प्राथमिकता देगा जो फ़्रेम रेट पर काम करते हैं. 60 FPS (फ़्रेम प्रति सेकंड) पर काम करने वाले सभी कैमरा कॉन्फ़िगरेशन को फ़िल्टर करने के लिए, TargetFps.TARGET_FPS_30 का इस्तेमाल करके setTargetFps वाला फ़िल्टर लगाएं.

    Java

    // Return only camera configs that target 30 FPS camera capture frame rate.
    filter.setTargetFps(EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30));

    Kotlin

    // Return only camera configs that target 30 FPS camera capture frame rate.
    filter.targetFps = EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30)

  • ARCore को डेप्थ सेंसर का इस्तेमाल करने से रोकें. जिन डिवाइस में डेप्थ सेंसर काम करता है, उन पर ARCore उन कैमरा कॉन्फ़िगरेशन को प्राथमिकता देता है जो डेप्थ सेंसर का इस्तेमाल करते हैं. डेप्थ सेंसर का इस्तेमाल करने वाले सभी कैमरा कॉन्फ़िगरेशन को फ़िल्टर करने के लिए, DepthSensorUsage.DO_NOT_USE का इस्तेमाल करके setDepthSensorUsage फ़िल्टर का इस्तेमाल करें.

    Java

    // Return only camera configs that will not use the depth sensor.
    filter.setDepthSensorUsage(EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE));

    Kotlin

    // Return only camera configs that will not use the depth sensor.
    filter.depthSensorUsage = EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE)

  • कोई दूसरा जीपीयू टेक्सचर रिज़ॉल्यूशन चुनना. काम करने वाले डिवाइस पर, ARCore, ज़्यादा जीपीयू टेक्सचर रिज़ॉल्यूशन दे सकता है. कम रिज़ॉल्यूशन वाला जीपीयू टेक्सचर चुनने से, जीपीयू के लोड और मेमोरी बैंडविथ की ज़रूरत को कम करके ऐप्लिकेशन की परफ़ॉर्मेंस बेहतर हो सकती है. हालांकि, सभी मामलों में इससे परफ़ॉर्मेंस बेहतर होने की गारंटी नहीं है.

कैमरा कॉन्फ़िगरेशन के फ़िल्टर इस्तेमाल करना

अपने ऐप्लिकेशन को कैमरा कॉन्फ़िगरेशन फ़िल्टर करने देने के लिए, यह तरीका अपनाएं.

Java

// Create a camera config filter for the session.
CameraConfigFilter filter = new CameraConfigFilter(session);

// Return only camera configs that target 30 fps camera capture frame rate.
filter.setTargetFps(EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30));

// Return only camera configs that will not use the depth sensor.
filter.setDepthSensorUsage(EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE));

// Get list of configs that match filter settings.
// In this case, this list is guaranteed to contain at least one element,
// because both TargetFps.TARGET_FPS_30 and DepthSensorUsage.DO_NOT_USE
// are supported on all ARCore supported devices.
List<CameraConfig> cameraConfigList = session.getSupportedCameraConfigs(filter);

// Use element 0 from the list of returned camera configs. This is because
// it contains the camera config that best matches the specified filter
// settings.
session.setCameraConfig(cameraConfigList.get(0));

Kotlin

// Create a camera config filter for the session.
val filter = CameraConfigFilter(session)

// Return only camera configs that target 30 fps camera capture frame rate.
filter.targetFps = EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30)

// Return only camera configs that will not use the depth sensor.
filter.depthSensorUsage = EnumSet.of(CameraConfig.DepthSensorUsage.DO_NOT_USE)

// Get list of configs that match filter settings.
// In this case, this list is guaranteed to contain at least one element,
// because both TargetFps.TARGET_FPS_30 and DepthSensorUsage.DO_NOT_USE
// are supported on all ARCore supported devices.
val cameraConfigList = session.getSupportedCameraConfigs(filter)

// Use element 0 from the list of returned camera configs. This is because
// it contains the camera config that best matches the specified filter
// settings.
session.cameraConfig = cameraConfigList[0]

फ़ोकस मोड

सेशन कॉन्फ़िगरेशन में भी फ़ोकस मोड को सेट किया जा सकता है. ट्रैकिंग के लिए, फ़िक्स्ड फ़ोकस की सुविधा आम तौर पर बेहतर होती है. साथ ही, ज़्यादातर डिवाइसों पर यह ARCore डिफ़ॉल्ट तौर पर मौजूद होता है. रिकॉर्डिंग, फ़ोटोग्राफ़ी, वीडियोग्राफ़ी, और जब आस-पास की ऑब्जेक्ट पर फ़ोकस किया जाना हो, तब ऑटो-फ़ोकस ज़रूरी है.

ज़्यादा जानकारी के लिए, Config.FocusMode पर जाएं.