XR_EXT_spatial_object_tracking
Name String
XR_EXT_spatial_object_tracking
Tipo di estensione
Estensione dell'istanza
Numero di interno registrato
745
Revisione
1
Stato della ratifica
Non ratificato
Dipendenze di estensioni e versioni
XR_EXT_spatial_entity
Stato IP
Nessuna rivendicazione di PI nota.
Collaboratori
Nihav Jain, Google
Natalie Fleury, Meta
Yuichi Taguchi, Meta
Ron Bessems, Meta
Yin Li, Microsoft
Jimmy Alamparambil, ByteDance
Zhipeng Liu, ByteDance
Jun Yan, ByteDance
Andy Biar, Unity Technologies
Rebecca Nordhauser, Unity Technologies
Panoramica
Questa estensione si basa su XR_EXT_spatial_entity e definisce una funzionalità spaziale per il monitoraggio di un insieme di oggetti predefiniti senza richiedere un set di dati di input dall'applicazione.
Supporto di runtime
Se il runtime supporta il tracciamento degli oggetti, deve indicarlo enumerando XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT in xrEnumerateSpatialCapabilitiesEXT .
Configurazione
La struttura XrSpatialCapabilityConfigurationObjectTrackingEXT è definita come:
typedef struct XrSpatialCapabilityConfigurationObjectTrackingEXT {
XrStructureType type;
const void* next;
XrSpatialCapabilityEXT capability;
uint32_t enabledComponentCount;
const XrSpatialComponentTypeEXT* enabledComponents;
} XrSpatialCapabilityConfigurationObjectTrackingEXT;
Descrizioni dei membri
typeè l'XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture.capabilityè un XrSpatialCapabilityEXT e deve essereXR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT.enabledComponentCountè unuint32_tche descrive il conteggio degli elementi nell'arrayenabledComponents.enabledComponentsè un puntatore a un array di XrSpatialComponentTypeEXT .
Le applicazioni possono attivare la funzionalità spaziale XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT aggiungendo un puntatore alla struttura XrSpatialCapabilityConfigurationObjectTrackingEXT in XrSpatialContextCreateInfoEXT :: capabilityConfigs .
Il runtime deve restituire XR_ERROR_VALIDATION_FAILURE se capability non è XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT .
Utilizzo valido (implicito)
- L'estensione
XR_EXT_spatial_object_trackingdeve essere abilitata prima di utilizzare XrSpatialCapabilityConfigurationObjectTrackingEXT -
typedeve essereXR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_OBJECT_TRACKING_EXT -
nextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture . Vedi anche: XrSpatialFeatureObjectSemanticLabelSubsetEXT -
capabilitydeve essere un valore XrSpatialCapabilityEXT valido -
enabledComponentsdeve essere un puntatore a un array dienabledComponentCountvalori XrSpatialComponentTypeEXT validi - Il parametro
enabledComponentCountdeve essere maggiore di0
Componenti garantiti
Un runtime che supporta XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT deve supportare i seguenti componenti spaziali come componenti garantiti delle entità rilevate da questa funzionalità e deve enumerarli in xrEnumerateSpatialCapabilityComponentTypesEXT :
XR_SPATIAL_COMPONENT_TYPE_BOUNDED_3D_EXT- Almeno un tipo di componente che fornisce un insieme di etichette semantiche per gli oggetti monitorati. Una funzionalità di tracciamento degli oggetti non ha senso senza un componente di etichetta semantica. Sebbene questa estensione definisca
XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXTeXR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXTcome possibili componenti di etichette semantiche supportati dai runtime, altre estensioni potrebbero definire nuovi tipi di componenti per fornire diverse classi di etichette semantiche che descrivono un oggetto monitorato. Per informazioni dettagliate sui set di etichette semantiche e sulla progettazione dei tipi di componenti, consulta [ext_spatial_semantic_labels_guidelines]. I runtime possono non supportareXR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXToXR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXTper la funzionalità di tracciamento degli oggetti, ma devono supportare almeno un tipo di componente che fornisce un'etichetta semantica.
Componente 3D delimitato
Il componente 3D delimitato fornisce il centro e le estensioni dell'oggetto rappresentato dall'entità su cui si trova. Per ulteriori dettagli, consulta 3D delimitato.
Componenti facoltativi
Un runtime che supporta XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT può supportare componenti spaziali oltre a quelli elencati nella sezione Componenti garantiti. L'applicazione può utilizzare xrEnumerateSpatialCapabilityComponentTypesEXT per ottenere l'elenco completo dei componenti supportati da un runtime e può quindi configurare quelli di suo interesse durante la creazione del contesto spaziale.
Etichetta semantica dell'oggetto
Dati dei componenti
typedef enum XrSpatialObjectSemanticLabelEXT {
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_UNCATEGORIZED_EXT = 1,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_SOFA_EXT = 2,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_BED_EXT = 3,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_CHAIR_EXT = 4,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_TABLE_EXT = 5,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_LAMP_EXT = 6,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_PLANT_EXT = 7,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_DISPLAY_SCREEN_EXT = 8,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_WALL_ART_EXT = 9,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_CABINET_EXT = 10,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_MAX_ENUM_EXT = 0x7FFFFFFF
} XrSpatialObjectSemanticLabelEXT;
L'enumerazione XrSpatialObjectSemanticLabelEXT descrive un insieme di etichette semantiche per gli oggetti.
Per le entità con l'etichetta XR_SPATIAL_OBJECT_SEMANTIC_LABEL_DISPLAY_SCREEN_EXT, l'asse +Z del componente Bounded 3D deve corrispondere approssimativamente alla normale della superficie dello schermo.
Per le entità con l'etichetta XR_SPATIAL_OBJECT_SEMANTIC_LABEL_WALL_ART_EXT, l'asse +Z del componente Bounded 3D deve corrispondere alla normale della superficie della parete su cui viene rilevata l'opera d'arte.
Per le entità con l'etichetta XR_SPATIAL_OBJECT_SEMANTIC_LABEL_TABLE_EXT, l'asse +Z del componente Bounded 3D deve corrispondere alla normale della superficie del tavolo.
Per tutte le altre etichette in XrSpatialObjectSemanticLabelEXT , l'applicazione non deve fare alcuna supposizione su come XrBoxf :: center :: orientation fornito dal componente Bounded 3D sull'entità si allinea agli attributi fisici dell'oggetto.
I valori di enumerazione hanno i seguenti significati:
Descrizione enum
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_UNCATEGORIZED_EXT
Il runtime non è riuscito a classificare questa entità.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_SOFA_EXT
L'entità è un divano.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_BED_EXT
L'entità è un letto.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_CHAIR_EXT
L'entità è una sedia.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_TABLE_EXT
L'entità è una tabella.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_LAMP_EXT
L'entità è una lampada.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_PLANT_EXT
L'entità è una pianta.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_DISPLAY_SCREEN_EXT
L'entità è uno schermo, ad esempio un monitor o una TV.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_WALL_ART_EXT
L'entità è un'opera d'arte murale.
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_CABINET_EXT
L'entità è un armadietto.
Struttura dell'elenco dei componenti per eseguire query sui dati
La struttura XrSpatialComponentObjectSemanticLabelListEXT è definita come:
typedef struct XrSpatialComponentObjectSemanticLabelListEXT {
XrStructureType type;
void* next;
uint32_t semanticLabelCount;
XrSpatialObjectSemanticLabelEXT* semanticLabels;
} XrSpatialComponentObjectSemanticLabelListEXT;
Descrizioni dei membri
typeè l'XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture. Nessuna struttura di questo tipo è definita in OpenXR di base o in questa estensione.semanticLabelCountè unuint32_tche descrive il conteggio degli elementi nell'arraysemanticLabels.semanticLabelsè un array di XrSpatialObjectSemanticLabelEXT .
Per eseguire una query sul componente dell'etichetta semantica dell'oggetto delle entità spaziali in un XrSpatialSnapshotEXT , includi XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT in XrSpatialComponentDataQueryConditionEXT :: componentTypes e aggiungi XrSpatialComponentObjectSemanticLabelListEXT alla catena XrSpatialComponentDataQueryResultEXT :: next.
Il runtime deve restituire XR_ERROR_VALIDATION_FAILURE da xrQuerySpatialComponentDataEXT se XrSpatialComponentObjectSemanticLabelListEXT si trova nella catena XrSpatialComponentDataQueryResultEXT :: next, ma XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT non è incluso in XrSpatialComponentDataQueryConditionEXT :: componentTypes .
Il runtime deve restituire XR_ERROR_SIZE_INSUFFICIENT da xrQuerySpatialComponentDataEXT se semanticLabelCount è inferiore a XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput .
Utilizzo valido (implicito)
- L'estensione
XR_EXT_spatial_object_trackingdeve essere attivata prima di utilizzare XrSpatialComponentObjectSemanticLabelListEXT -
typedeve essereXR_TYPE_SPATIAL_COMPONENT_OBJECT_SEMANTIC_LABEL_LIST_EXT -
nextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture -
semanticLabelsdeve essere un puntatore a un array di valorisemanticLabelCountXrSpatialObjectSemanticLabelEXT - Il parametro
semanticLabelCountdeve essere maggiore di0
Configurazione
Se XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT è enumerato in XrSpatialCapabilityComponentTypesEXT :: componentTypes per una funzionalità, un'applicazione può attivarla includendo l'enumerante nell'elenco XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents della struttura derivata XrSpatialCapabilityConfigurationBaseHeaderEXT della funzionalità che supporta questo componente.
Questo componente non richiede alcuna configurazione speciale per essere incluso nella catena XrSpatialCapabilityConfigurationBaseHeaderEXT :: next, ma offre una configurazione facoltativa che le applicazioni possono fornire.
La struttura XrSpatialFeatureObjectSemanticLabelSubsetEXT è definita come:
typedef struct XrSpatialFeatureObjectSemanticLabelSubsetEXT {
XrStructureType type;
const void* next;
uint32_t semanticLabelCount;
const XrSpatialObjectSemanticLabelEXT* semanticLabels;
} XrSpatialFeatureObjectSemanticLabelSubsetEXT;
Descrizioni dei membri
typeè l'XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture.semanticLabelCountè unuint32_tche descrive il conteggio degli elementi nell'arraysemanticLabels.semanticLabelsè un array di XrSpatialObjectSemanticLabelEXT .
Se il runtime enumera XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT da xrEnumerateSpatialCapabilityComponentTypesEXT per una determinata funzionalità, deve anche enumerare XR_SPATIAL_CAPABILITY_FEATURE_OBJECT_SEMANTIC_LABEL_SUBSET_EXT da xrEnumerateSpatialCapabilityFeaturesEXT per la stessa funzionalità. Se un'applicazione attiva XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT durante la configurazione di questa funzionalità, può concatenare XrSpatialFeatureObjectSemanticLabelSubsetEXT alla struttura di configurazione corrispondente di questa funzionalità per fornire al runtime un sottoinsieme di etichette definite in XrSpatialObjectSemanticLabelEXT . Il runtime può utilizzare questo sottoinsieme di etichette per ottimizzare le pipeline di monitoraggio.
Il runtime deve restituire XR_ERROR_VALIDATION_FAILURE da xrCreateSpatialContextAsyncEXT se semanticLabels contiene un'etichetta non definita in XrSpatialObjectSemanticLabelEXT o se semanticLabels contiene XR_SPATIAL_OBJECT_SEMANTIC_LABEL_UNCATEGORIZED_EXT .
Il runtime deve restituire XR_ERROR_SPATIAL_COMPONENT_NOT_ENABLED_EXT da xrCreateSpatialContextAsyncEXT se l'applicazione fornisce un elenco valido di etichette in semanticLabels, ma XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT non è incluso nell'array XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents della struttura di configurazione a cui è concatenato XrSpatialFeatureObjectSemanticLabelSubsetEXT.
Se l'applicazione configura una funzionalità con un XrSpatialFeatureObjectSemanticLabelSubsetEXT valido, il runtime non deve includere entità con etichette semantiche non elencate in semanticLabels in nessuno snapshot di rilevamento creato per il contesto spaziale configurato.
Utilizzo valido (implicito)
- L'estensione
XR_EXT_spatial_object_trackingdeve essere attivata prima di utilizzare XrSpatialFeatureObjectSemanticLabelSubsetEXT -
typedeve essereXR_TYPE_SPATIAL_FEATURE_OBJECT_SEMANTIC_LABEL_SUBSET_EXT -
nextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture -
semanticLabelsdeve essere un puntatore a un array disemanticLabelCountvalori XrSpatialObjectSemanticLabelEXT validi - Il parametro
semanticLabelCountdeve essere maggiore di0
Etichetta semantica della tastiera
Dati dei componenti
typedef enum XrSpatialKeyboardSemanticLabelEXT {
XR_SPATIAL_KEYBOARD_SEMANTIC_LABEL_UNCATEGORIZED_EXT = 1,
XR_SPATIAL_KEYBOARD_SEMANTIC_LABEL_KEYBOARD_EXT = 2,
XR_SPATIAL_KEYBOARD_SEMANTIC_LABEL_MAX_ENUM_EXT = 0x7FFFFFFF
} XrSpatialKeyboardSemanticLabelEXT;
L'enumerazione XrSpatialKeyboardSemanticLabelEXT descrive un'etichetta semantica per una tastiera.
Le estensioni e l'orientamento di XR_SPATIAL_KEYBOARD_SEMANTIC_LABEL_KEYBOARD_EXT rappresentati dal componente Bounded 3D sulla stessa entità sono mostrati nell'immagine seguente (con xyz = rgb) che ha origine al centro dell'oggetto.
Figura 30. Orientamento della tastiera.
Descrizione enum
XR_SPATIAL_KEYBOARD_SEMANTIC_LABEL_UNCATEGORIZED_EXT
Il runtime non è riuscito a classificare questa entità.
XR_SPATIAL_KEYBOARD_SEMANTIC_LABEL_KEYBOARD_EXT
L'entità è una tastiera.
Componente List Struct per eseguire query sui dati
La struttura XrSpatialComponentKeyboardSemanticLabelListEXT è definita come:
typedef struct XrSpatialComponentKeyboardSemanticLabelListEXT {
XrStructureType type;
void* next;
uint32_t semanticLabelCount;
XrSpatialKeyboardSemanticLabelEXT* semanticLabels;
} XrSpatialComponentKeyboardSemanticLabelListEXT;
Descrizioni dei membri
typeè l'XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture. Nessuna struttura di questo tipo è definita in OpenXR di base o in questa estensione.semanticLabelCountè unuint32_tche descrive il conteggio degli elementi nell'arraysemanticLabels.semanticLabelsè un array di XrSpatialKeyboardSemanticLabelEXT .
Per eseguire una query sul componente dell'etichetta semantica della tastiera delle entità spaziali in un XrSpatialSnapshotEXT , includi XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXT in XrSpatialComponentDataQueryConditionEXT :: componentTypes e aggiungi XrSpatialComponentKeyboardSemanticLabelListEXT alla catena XrSpatialComponentDataQueryResultEXT :: next.
Il runtime deve restituire XR_ERROR_VALIDATION_FAILURE da xrQuerySpatialComponentDataEXT se XrSpatialComponentKeyboardSemanticLabelListEXT si trova nella catena XrSpatialComponentDataQueryResultEXT :: next, ma XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXT non è incluso in XrSpatialComponentDataQueryConditionEXT :: componentTypes .
Il runtime deve restituire XR_ERROR_SIZE_INSUFFICIENT da xrQuerySpatialComponentDataEXT se semanticLabelCount è inferiore a XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput .
Utilizzo valido (implicito)
- L'estensione
XR_EXT_spatial_object_trackingdeve essere abilitata prima di utilizzare XrSpatialComponentKeyboardSemanticLabelListEXT -
typedeve essereXR_TYPE_SPATIAL_COMPONENT_KEYBOARD_SEMANTIC_LABEL_LIST_EXT -
nextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture -
semanticLabelsdeve essere un puntatore a un array di valorisemanticLabelCountXrSpatialKeyboardSemanticLabelEXT - Il parametro
semanticLabelCountdeve essere maggiore di0
Configurazione
Se XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXT è enumerato in XrSpatialCapabilityComponentTypesEXT :: componentTypes per una funzionalità, un'applicazione può attivarla includendo l'enumerante nell'elenco XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents della struttura derivata XrSpatialCapabilityConfigurationBaseHeaderEXT della funzionalità che supporta questo componente.
Questo componente non richiede alcuna configurazione speciale per essere incluso nella catena XrSpatialCapabilityConfigurationBaseHeaderEXT :: next.
Etichetta semantica del mouse
Dati dei componenti
typedef enum XrSpatialMouseSemanticLabelEXT {
XR_SPATIAL_MOUSE_SEMANTIC_LABEL_UNCATEGORIZED_EXT = 1,
XR_SPATIAL_MOUSE_SEMANTIC_LABEL_MOUSE_EXT = 2,
XR_SPATIAL_MOUSE_SEMANTIC_LABEL_MAX_ENUM_EXT = 0x7FFFFFFF
} XrSpatialMouseSemanticLabelEXT;
L'enumerazione XrSpatialMouseSemanticLabelEXT descrive un'etichetta semantica per un mouse.
Descrizione enum
XR_SPATIAL_MOUSE_SEMANTIC_LABEL_UNCATEGORIZED_EXT
Il runtime non è riuscito a classificare questa entità.
XR_SPATIAL_MOUSE_SEMANTIC_LABEL_MOUSE_EXT
L'entità è un mouse.
Componente List Struct per eseguire query sui dati
La struttura XrSpatialComponentMouseSemanticLabelListEXT è definita come:
typedef struct XrSpatialComponentMouseSemanticLabelListEXT {
XrStructureType type;
void* next;
uint32_t semanticLabelCount;
XrSpatialMouseSemanticLabelEXT* semanticLabels;
} XrSpatialComponentMouseSemanticLabelListEXT;
Descrizioni dei membri
typeè l'XrStructureType di questa struttura.nextèNULLo un puntatore alla struttura successiva in una catena di strutture. Nessuna struttura di questo tipo è definita in OpenXR di base o in questa estensione.semanticLabelCountè unuint32_tche descrive il conteggio degli elementi nell'arraysemanticLabels.semanticLabelsè un array di XrSpatialMouseSemanticLabelEXT .
Per eseguire una query sul componente dell'etichetta semantica del mouse delle entità spaziali in un XrSpatialSnapshotEXT , includi XR_SPATIAL_COMPONENT_TYPE_MOUSE_SEMANTIC_LABEL_EXT in XrSpatialComponentDataQueryConditionEXT :: componentTypes e aggiungi XrSpatialComponentMouseSemanticLabelListEXT alla catena XrSpatialComponentDataQueryResultEXT :: next.
Il runtime deve restituire XR_ERROR_VALIDATION_FAILURE da xrQuerySpatialComponentDataEXT se XrSpatialComponentMouseSemanticLabelListEXT si trova nella catena XrSpatialComponentDataQueryResultEXT :: next, ma XR_SPATIAL_COMPONENT_TYPE_MOUSE_SEMANTIC_LABEL_EXT non è incluso in XrSpatialComponentDataQueryConditionEXT :: componentTypes .
Il runtime deve restituire XR_ERROR_SIZE_INSUFFICIENT da xrQuerySpatialComponentDataEXT se semanticLabelCount è inferiore a XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput .
Utilizzo valido (implicito)
- L'estensione
XR_EXT_spatial_object_trackingdeve essere attivata prima di utilizzare XrSpatialComponentMouseSemanticLabelListEXT -
typedeve essereXR_TYPE_SPATIAL_COMPONENT_MOUSE_SEMANTIC_LABEL_LIST_EXT -
nextdeve essereNULLo un puntatore valido alla struttura successiva in una catena di strutture -
semanticLabelsdeve essere un puntatore a un array di valorisemanticLabelCountXrSpatialMouseSemanticLabelEXT - Il parametro
semanticLabelCountdeve essere maggiore di0
Configurazione
Se XR_SPATIAL_COMPONENT_TYPE_MOUSE_SEMANTIC_LABEL_EXT è enumerato in XrSpatialCapabilityComponentTypesEXT :: componentTypes per una funzionalità, un'applicazione può attivarla includendo l'enumerante nell'elenco XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents della struttura derivata XrSpatialCapabilityConfigurationBaseHeaderEXT della funzionalità che supporta questo componente.
Questo componente non richiede alcuna configurazione speciale per essere incluso nella catena XrSpatialCapabilityConfigurationBaseHeaderEXT :: next.
Esempio di codice
Configura la funzionalità di tracciamento degli oggetti
Il seguente codice di esempio mostra come configurare la funzionalità di tracciamento degli oggetti durante la creazione di un contesto spaziale.
// Check if object tracking capability is supported
uint32_t capabilityCount;
CHK_XR(xrEnumerateSpatialCapabilitiesEXT(instance, systemId, 0, &capabilityCount, nullptr));
std::vector<XrSpatialCapabilityEXT> capabilities(capabilityCount);
CHK_XR(xrEnumerateSpatialCapabilitiesEXT(instance, systemId, capabilityCount, &capabilityCount, capabilities.data()));
if (std::find(capabilities.begin(), capabilities.end(), XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT) == capabilities.end()) {
return;
}
// Enumerate supported components for object tracking capability
XrSpatialCapabilityComponentTypesEXT objectComponents{XR_TYPE_SPATIAL_CAPABILITY_COMPONENT_TYPES_EXT};
CHK_XR(xrEnumerateSpatialCapabilityComponentTypesEXT(instance, systemId, XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT, &objectComponents));
std::vector<XrSpatialComponentTypeEXT> objectCapabilityComponents(objectComponents.componentTypeCountOutput);
objectComponents.componentTypeCapacityInput = objectCapabilityComponents.size();
objectComponents.componentTypes = objectCapabilityComponents.data();
CHK_XR(xrEnumerateSpatialCapabilityComponentTypesEXT(instance, systemId, XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT, &objectComponents));
// Check if the object & keyboard semantic labels component is supported
const auto supportsComponent = [&objectCapabilityComponents](XrSpatialComponentTypeEXT component) {
return std::find(objectCapabilityComponents.begin(), objectCapabilityComponents.end(), component) != objectCapabilityComponents.end();
};
const bool supportsObjectSemanticLabel = supportsComponent(XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT);
const bool supportsKeyboardSemanticLabel = supportsComponent(XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXT);
// Enumerate supported features for object tracking capability
uint32_t featureCount;
CHK_XR(xrEnumerateSpatialCapabilityFeaturesEXT(instance, systemId, XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT, 0, &featureCount, nullptr));
std::vector<XrSpatialCapabilityFeatureEXT> features(featureCount);
CHK_XR(xrEnumerateSpatialCapabilityFeaturesEXT(instance, systemId, XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT, featureCount, &featureCount, features.data()));
const bool supportsObjectSemanticLabelSubsetFeature = std::find(features.begin(), features.end(), XR_SPATIAL_CAPABILITY_FEATURE_OBJECT_SEMANTIC_LABEL_SUBSET_EXT) != features.end();
// Create a spatial context
XrSpatialContextEXT spatialContext{};
// Enable the guaranteed components of the object tracking capability
std::vector<XrSpatialComponentTypeEXT> enabledComponents = {
XR_SPATIAL_COMPONENT_TYPE_BOUNDED_3D_EXT,
};
// Optionally enable the supported semantic labels
if (supportsObjectSemanticLabel) {
enabledComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT);
}
if (supportsKeyboardSemanticLabel) {
enabledComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXT);
}
// We only want to track sofa and table.
std::vector<XrSpatialObjectSemanticLabelEXT> objectSemanticLabelSubset = {
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_SOFA_EXT,
XR_SPATIAL_OBJECT_SEMANTIC_LABEL_TABLE_EXT
};
XrSpatialFeatureObjectSemanticLabelSubsetEXT subsetFeature{XR_TYPE_SPATIAL_FEATURE_OBJECT_SEMANTIC_LABEL_SUBSET_EXT};
subsetFeature.semanticLabelCount = objectSemanticLabelSubset.size();
subsetFeature.semanticLabels = objectSemanticLabelSubset.data();
XrSpatialCapabilityConfigurationObjectTrackingEXT objectTrackingConfig{XR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_OBJECT_TRACKING_EXT};
objectTrackingConfig.capability = XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT;
objectTrackingConfig.enabledComponentCount = enabledComponents.size();
objectTrackingConfig.enabledComponents = enabledComponents.data();
if (supportsObjectSemanticLabelSubsetFeature) {
objectTrackingConfig.next = &subsetFeature;
}
std::array<XrSpatialCapabilityConfigurationBaseHeaderEXT*, 1> capabilityConfigs = {
reinterpret_cast<XrSpatialCapabilityConfigurationBaseHeaderEXT*>(&objectTrackingConfig),
};
XrSpatialContextCreateInfoEXT spatialContextCreateInfo{XR_TYPE_SPATIAL_CONTEXT_CREATE_INFO_EXT};
spatialContextCreateInfo.capabilityConfigCount = capabilityConfigs.size();
spatialContextCreateInfo.capabilityConfigs = capabilityConfigs.data();
XrFutureEXT createContextFuture;
CHK_XR(xrCreateSpatialContextAsyncEXT(session, &spatialContextCreateInfo, &createContextFuture));
waitUntilReady(createContextFuture);
XrCreateSpatialContextCompletionEXT completion{XR_TYPE_CREATE_SPATIAL_CONTEXT_COMPLETION_EXT};
CHK_XR(xrCreateSpatialContextCompleteEXT(session, createContextFuture, &completion));
if (completion.futureResult != XR_SUCCESS) {
return;
}
spatialContext = completion.spatialContext;
// ...
// Discovery entities with the spatial context
// ...
CHK_XR(xrDestroySpatialContextEXT(spatialContext));
Scopri le entità spaziali ed esegui query sui dati dei componenti
Il seguente codice di esempio mostra come rilevare entità spaziali per un contesto configurato con XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT ed eseguire query sui dati dei relativi componenti.
XrFutureEXT future = XR_NULL_FUTURE_EXT;
// We want to look for entities that have the following components.
std::vector<XrSpatialComponentTypeEXT> snapshotComponents = {
XR_SPATIAL_COMPONENT_TYPE_BOUNDED_3D_EXT,
};
if (supportsKeyboardSemanticLabel) {
snapshotComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXT);
}
auto discoverSpatialEntities = [&](XrSpatialContextEXT spatialContext, XrTime time) {
XrSpatialDiscoverySnapshotCreateInfoEXT snapshotCreateInfo{XR_TYPE_SPATIAL_DISCOVERY_SNAPSHOT_CREATE_INFO_EXT};
snapshotCreateInfo.componentTypeCount = snapshotComponents.size();
snapshotCreateInfo.componentTypes = snapshotComponents.data();
CHK_XR(xrCreateSpatialDiscoverySnapshotAsyncEXT(spatialContext, &snapshotCreateInfo, &future));
waitUntilReady(future);
XrCreateSpatialDiscoverySnapshotCompletionInfoEXT completionInfo{XR_TYPE_CREATE_SPATIAL_DISCOVERY_SNAPSHOT_COMPLETION_INFO_EXT};
completionInfo.baseSpace = localSpace;
completionInfo.time = time;
completionInfo.future = future;
XrCreateSpatialDiscoverySnapshotCompletionEXT completion{XR_TYPE_CREATE_SPATIAL_DISCOVERY_SNAPSHOT_COMPLETION_EXT};
CHK_XR(xrCreateSpatialDiscoverySnapshotCompleteEXT(spatialContext, &completionInfo, &completion));
if (completion.futureResult == XR_SUCCESS) {
// Query for the semantic label component data
XrSpatialComponentDataQueryConditionEXT queryCond{XR_TYPE_SPATIAL_COMPONENT_DATA_QUERY_CONDITION_EXT};
queryCond.componentTypeCount = snapshotComponents.size();
queryCond.componentTypes = snapshotComponents.data();
XrSpatialComponentDataQueryResultEXT queryResult{XR_TYPE_SPATIAL_COMPONENT_DATA_QUERY_RESULT_EXT};
CHK_XR(xrQuerySpatialComponentDataEXT(completion.snapshot, &queryCond, &queryResult));
std::vector<XrSpatialEntityIdEXT> entityIds(queryResult.entityIdCountOutput);
std::vector<XrSpatialEntityTrackingStateEXT> entityStates(queryResult.entityIdCountOutput);
queryResult.entityIdCapacityInput = entityIds.size();
queryResult.entityIds = entityIds.data();
queryResult.entityStateCapacityInput = entityStates.size();
queryResult.entityStates = entityStates.data();
std::vector<XrBoxf> bounded3D(queryResult.entityIdCountOutput);
XrSpatialComponentBounded3DListEXT bounded3DList{XR_TYPE_SPATIAL_COMPONENT_BOUNDED_3D_LIST_EXT};
bounded3DList.boundCount = bounded3D.size();
bounded3DList.bounds = bounded3D.data();
queryResult.next = &bounded3DList;
std::vector<XrSpatialKeyboardSemanticLabelEXT> semanticLabels;
XrSpatialComponentKeyboardSemanticLabelListEXT semanticLabelsList{XR_TYPE_SPATIAL_COMPONENT_KEYBOARD_SEMANTIC_LABEL_LIST_EXT};
if (supportsKeyboardSemanticLabel) {
semanticLabels.resize(queryResult.entityIdCountOutput);
semanticLabelsList.semanticLabelCount = semanticLabels.size();
semanticLabelsList.semanticLabels = semanticLabels.data();
semanticLabelsList.next = queryResult.next;
queryResult.next = &semanticLabelsList;
}
CHK_XR(xrQuerySpatialComponentDataEXT(completion.snapshot, &queryCond, &queryResult));
for (int32_t i = 0; i < queryResult.entityIdCountOutput; ++i) {
if (entityStates[i] != XR_SPATIAL_ENTITY_TRACKING_STATE_TRACKING_EXT) {
continue;
}
// 3D bounds for entity entityIds[i] is bounded3D[i].extents centered on bounded3D[i].center.
if (supportsKeyboardSemanticLabel) {
// semantic label for entity entityIds[i] is semanticLabels[i].
}
}
CHK_XR(xrDestroySpatialSnapshotEXT(completion.snapshot));
}
};
while (1) {
// ...
// For every frame in frame loop
// ...
XrFrameState frameState; // previously returned from xrWaitFrame
const XrTime time = frameState.predictedDisplayTime;
// Poll for the XR_TYPE_EVENT_DATA_SPATIAL_DISCOVERY_RECOMMENDED_EXT event
XrEventDataBuffer event = {XR_TYPE_EVENT_DATA_BUFFER};
XrResult result = xrPollEvent(instance, &event);
if (result == XR_SUCCESS) {
switch (event.type) {
case XR_TYPE_EVENT_DATA_SPATIAL_DISCOVERY_RECOMMENDED_EXT: {
const XrEventDataSpatialDiscoveryRecommendedEXT& eventdata =
*reinterpret_cast<XrEventDataSpatialDiscoveryRecommendedEXT*>(&event);
// Discover spatial entities for the context that we received the "discovery
// recommended" event for.
discoverSpatialEntities(eventdata.spatialContext, time);
break;
}
}
}
// ...
// Finish frame loop
// ...
}
Nuove strutture
- XrSpatialCapabilityConfigurationObjectTrackingEXT
Estensione di XrSpatialCapabilityConfigurationObjectTrackingEXT :
Estensione di XrSpatialComponentDataQueryResultEXT :
Nuovi enum
Nuove costanti enum
XR_EXT_SPATIAL_OBJECT_TRACKING_EXTENSION_NAMEXR_EXT_spatial_object_tracking_SPEC_VERSIONEstensione di XrSpatialCapabilityEXT :
XR_SPATIAL_CAPABILITY_OBJECT_TRACKING_EXT
Estensione di XrSpatialCapabilityFeatureEXT :
XR_SPATIAL_CAPABILITY_FEATURE_OBJECT_SEMANTIC_LABEL_SUBSET_EXT
Estensione di XrSpatialComponentTypeEXT :
XR_SPATIAL_COMPONENT_TYPE_KEYBOARD_SEMANTIC_LABEL_EXTXR_SPATIAL_COMPONENT_TYPE_MOUSE_SEMANTIC_LABEL_EXTXR_SPATIAL_COMPONENT_TYPE_OBJECT_SEMANTIC_LABEL_EXT
Estensione di XrStructureType :
XR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_OBJECT_TRACKING_EXTXR_TYPE_SPATIAL_COMPONENT_KEYBOARD_SEMANTIC_LABEL_LIST_EXTXR_TYPE_SPATIAL_COMPONENT_MOUSE_SEMANTIC_LABEL_LIST_EXTXR_TYPE_SPATIAL_COMPONENT_OBJECT_SEMANTIC_LABEL_LIST_EXTXR_TYPE_SPATIAL_FEATURE_OBJECT_SEMANTIC_LABEL_SUBSET_EXT
Problemi
Cronologia delle versioni
Revisione 1, 3 giugno 2025 (Nihav Jain, Google)
- Descrizione iniziale dell'estensione