Android SDK Camera2 API Example?

Unity Editor version: 2022.3.10
Unity Package version / Examples: 1.12.0
ML2 OS version: 1.4.0 (secure)
MLSDK version: 1.4.0
Host OS: (Windows/MacOS) - Windows

In the release notes for Unity - 1.12.0 MLCamera API is Deprecated.

Is there a plan to have an Android SDK Camera2 API Magic leap Unity example? And if so, how can we get it?

@nicholas.tenn We do not have a Camera 2 API example yet but we are working on updating the Unity Examples to use the new APIs. We will share more information one it becomes availably.

Thank you for the follow-up.

What API would you recommend we use for capturing images with the Camera in Unity?

I would recommend continuing to use the MLCamera API as we prepare additional documentation on how to migrate to the Camera 2 API.

Thank you. We will start in that direction.

While waiting for sample code from Magic Leap, I've switched my (native, not Unity) app from MLCamera module to my own Android NDK Camera2-based implementation. I don't know if it's worth reporting it, but just in case, logcat outputs the following messages in Debug build type when parsing the camera characteristics for Camera Id 0 (I didn't try the other Camera Ids):

2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638402! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638403! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835009! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835010! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638407! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638408! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638402! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638403! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835009! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835010! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638407! count 0, type 0
2023-12-21 18:30:22.193 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638408! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638402! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638403! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835009! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835010! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638407! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638408! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638402! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638403! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835009! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835010! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638407! count 0, type 0
2023-12-21 18:30:22.194 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638408! count 0, type 0
2023-12-21 18:30:22.199 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638402! count 0, type 0
2023-12-21 18:30:22.199 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638403! count 0, type 0
2023-12-21 18:30:22.199 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835009! count 0, type 0
2023-12-21 18:30:22.199 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1835010! count 0, type 0
2023-12-21 18:30:22.199 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638407! count 0, type 0
2023-12-21 18:30:22.199 11368-11532 ACameraMetadata         com.mycompany.myapp    E  filterDurations: malformed duration key 1638408! count 0, type 0

I didn't noticed any problem using the camera then.

Hello,

when did you plan to release a sample Camera2 with Unity ?

The ability to obtain camera frames via the Android NDK should become available in the upcoming 2.2.0 Unity SDK release. That said, MLCamera APIs will remain in the SDK so Unity developers can continue to use the Magic Leap Camera API until further notice. We will post more information about transitioning to the new API and it's functionality well in advance of the MLCamera API removal.

Hi!
Any updates about Camera2 Unity examples?
2.2.0 Unity SDK was released yesterday.

1 Like

Hi Lukasz, we are still working on the examples. Right now my recommendation is to continue using the MLCamera API instead.

Are you having any specific issues with the MLCamera API? Is something specific you would like to do with the Android Camera API ?