Forum Discussion
meteorik
3 months agoHonored Guest
Spatial SDK and Passthrough Camera Access
Can I get a passthrough camera stream open while running the Spatial SDK? I modified the Starter Template (https://github.com/meta-quest/Meta-Spatial-SDK-Templates/tree/main/StarterTemplate/app) just to open the camera but it seems to cause the camera to disconnected immediately.
I added a startCamera method to run when one of the panels is selected (instead of running the video):
private fun startCamera() {
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
Log.i("MainActivity", "Camera permission not granted")
}
if (checkSelfPermission("horizonos.permission.HEADSET_CAMERA") != PackageManager.PERMISSION_GRANTED) {
Log.i("MainActivity", "horizonos.permission.HEADSET_CAMERA permission not granted")
}
val cameraManager: CameraManager = getSystemService(Context.CAMERA_SERVICE) as CameraManager
val cameraIds: Array = cameraManager.cameraIdList
var cameraId: String = ""
for (id in cameraIds) {
Log.i("MainActivity", "Camera ID: $id")
val cameraCharacteristics = cameraManager.getCameraCharacteristics(id)
if(cameraCharacteristics.get(Key("com.meta.extra_metadata.camera_source", Int::class.java)) == 0) {
cameraId = id
continue
}
}
cameraManager.openCamera(cameraId, cameraStateCallback, Handler(Looper.getMainLooper()))
}
All permissions are good but it just fails:
2025-09-12 14:36:20.269 11285-11285 MainActivity com...atial.samples.startertemplate I All permissions already granted
2025-09-12 14:36:20.271 11285-11285 MainActivity com...atial.samples.startertemplate I Camera ID: 1
2025-09-12 14:36:20.278 11285-11285 MainActivity com...atial.samples.startertemplate I Camera ID: 50
2025-09-12 14:36:20.279 11285-11285 MainActivity com...atial.samples.startertemplate I Camera ID: 51
2025-09-12 14:36:20.299 1402-1402 CameraAccessController system_server E Failed to injectCamera for cameraId:51 package:com.meta.spatial.samples.startertemplate (Ask Gemini)
android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): injectCamera:3274: No camera device with ID "" currently availableAm I missing something, can this work?
Hello!
I have a couple of resources I have been provided that may be able to help you with this.https://developers.meta.com/horizon/documentation/spatial-sdk/spatial-sdk-scanner-overview
https://github.com/meta-quest/Meta-Spatial-SDK-Samples/tree/main/Showcases/meta_spatial_scanner
Please let me know if this helps!
1 Reply
Replies have been turned off for this discussion
- VirtuallyARealDinosaurCommunity Manager
Hello!
I have a couple of resources I have been provided that may be able to help you with this.https://developers.meta.com/horizon/documentation/spatial-sdk/spatial-sdk-scanner-overview
https://github.com/meta-quest/Meta-Spatial-SDK-Samples/tree/main/Showcases/meta_spatial_scanner
Please let me know if this helps!
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 12 months ago
- 3 months ago
- 5 years ago