simple, fast camera2 access for unreal engine projects on android and meta quest. streams camera frames into a ue texture for realtime use in games and xr apps. this is a fork of the original by @tark146 but since they are not seeming to be merging pull requests - this is now where i will be maintaining and pushing changes.
- allows you to quickly access your quest passthrough camera
- camera2 frame path wired to a ue
texture2dwith bgra8 updates on the render thread - camera intrinsics exposed (fx, fy, cx, cy, skew)
- lens distortion coefficients retrieved and mapped for ue usage
- camera characteristics json dump available for diagnostics
- original, pixel-array, and active-array sizes reported
- blueprint getters for texture, intrinsics, distortion, and resolutions
- enable the plugin in your project
- call
start camera preview(blueprint) or the c++ equivalent - get the camera texture and apply it to a material/mesh or ui image
- call
stop camera previewwhen done
- unreal engine 5.0+
- android sdk 21+
- camera permissions enabled on device
- works on standalone android (including meta quest 2/3/pro) [obviously won't work on windows because JNI is the base of it all]
- windows editor: returns null texture (for workflow only)
- color calibration may vary across devices
- resolution selection is fixed in code for now
- out the box setup could have a pawn for a quick turnkey experience
- ensure camera permissions are granted (first launch may require a restart)
- if you see a black texture, wait for auto-exposure and check logcat
- Copy the
AndroidCamera2Pluginfolder to your project'sPluginsdirectory - Regenerate project files
- Enable the plugin in your project settings or .uproject file
-
start camera preview:
SimpleCamera2Test::StartCameraPreview() -> boolreturns true if camera started successfully
-
get camera texture:
SimpleCamera2Test::GetCameraTexture() -> Texture2Dreturns the camera feed texture (can be null if not started)
-
stop camera preview:
SimpleCamera2Test::StopCameraPreview()stops the camera and releases resources
-
using the provided sample:
- place
BP_CameraImageactor (found in the plugin content) into your level - this actor contains a widget with complete blueprint implementation
- refer to the widget blueprint for implementation details
- place
-
manual blueprint implementation:
- create a new actor blueprint
- add a plane or ui image component
- in beginplay:
- call
StartCameraPreview - get the camera texture using
GetCameraTexture - create a dynamic material instance
- set the texture parameter to the camera texture
- apply the material to your plane/image
- call
USimpleCamera2Test::StartCameraPreview() -> bool- start camera previewUSimpleCamera2Test::StopCameraPreview()- stop camera previewUSimpleCamera2Test::GetCameraTexture() -> UTexture2D*- current camera texture (null if not started)USimpleCamera2Test::GetCameraFx() -> floatUSimpleCamera2Test::GetCameraFy() -> floatUSimpleCamera2Test::GetPrincipalPoint() -> FVector2DUSimpleCamera2Test::GetCameraSkew() -> floatUSimpleCamera2Test::GetCalibrationResolution() -> FIntPointUSimpleCamera2Test::GetLensDistortion() -> TArray<float>USimpleCamera2Test::GetLensDistortionUE() -> TArray<float>USimpleCamera2Test::GetOriginalResolution() -> FIntPointUSimpleCamera2Test::GetCameraCharacteristics(bool bRedump, FString& OutJson, FString& OutFilePath)- fetch cached or freshly dumped JSON + save path
android will display a permission request dialog for camera access. grant all camera permissions and restart the application to enable camera functionality.
The plugin automatically adds the following permissions to your Android manifest:
android.permission.CAMERAhorizonos.permission.HEADSET_CAMERA(Meta Quest)horizonos.permission.AVATAR_CAMERA(Meta Quest)
- JNI > c++ > bp
- frames have YUV_420_888 to RGBA conversion
- original resolution received: 1280x960
- pixel array size: 1280x960
- intrinsics received: fx=868.31 fy=868.31 cx=640.18 cy=482.07 skew=0.000 1280x960
- original resolution received: 1280x960
- camera ids: 50, 51
- no distortion array available on this device through Camera2Api
please note that these values would also differ depending on the Camera2 JNI configuration you have setup.
make changes, PR and contribute! :)