Skip to content

Commit d802117

Browse files
committed
Replace the ZXing camera sample with native MRUK QR tracking
1 parent 0740f30 commit d802117

60 files changed

Lines changed: 26 additions & 12790 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ Assets/Plugins/** linguist-vendored
119119
# Exceptions for .asset files such as lightning pre-baking
120120
LightingData.asset binary
121121

122-
# Small runtime dependency is checked in so QR tracking works on a fresh clone.
123-
Unity-QuestVisionKit/Assets/Plugins/ZXing/zxing.dll binary -filter
124-
125122
# Pin the small development-only Quak release without another LFS download.
126123
Unity-QuestVisionKit/Packages/com.xrdevrob.quak-0.4.0-alpha.1.tgz binary -filter
127124

‎README.md‎

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ QuestCameraKit is a collection of template and reference projects demonstrating
1616

1717
# Running all samples
1818

19-
Build and Run now includes all seven headset samples in one app. Press **Y** to open or close the menu, move the **left thumbstick** to choose, and press **X** to load a sample. In the Editor use **M**, **↑/↓**, and **Enter**. This menu currently uses Touch controllers; the samples retain their existing hand interactions. The desktop WebRTC receiver remains a separate scene.
19+
Build and Run now includes all six headset samples in one app. Press **Y** to open or close the menu, move the **left thumbstick** to choose, and press **X** to load a sample. In the Editor use **M**, **↑/↓**, and **Enter**. This menu currently uses Touch controllers; the samples retain their existing hand interactions. The desktop WebRTC receiver remains a separate scene.
2020

21-
For QR tracking without an extra decoder, start with **QR tracking (Meta native)**, sample 7. It uses the MRUK package already required by this project. Sample 3 demonstrates raw camera decoding using the bundled ZXing library; no manual NuGet installation is needed. Native tracking still depends on headset runtime support and spatial-data permission.
21+
**QR tracking (Meta native)** uses the MRUK package already required by this project. No separate decoder, NuGet installation, or QR scripting define is needed. Native tracking still depends on headset runtime support and spatial-data permission.
2222

2323
# PCA Samples
2424

@@ -69,22 +69,23 @@ For QR tracking without an extra decoder, start with **QR tracking (Meta native)
6969

7070
![Object Detection](https://media.githubusercontent.com/media/xrdevrob/QuestCameraKit/befec3b/Media/ObjectDetection.gif)
7171

72-
## 3. 📱 QR Code Tracking with ZXing
72+
## 3. 📱 Native QR Code Tracking
7373

74-
- **Purpose:** Detect and track QR codes in real time. Open webviews or log-in to 3rd party services with ease.
75-
- **Description:** Similarly to the object detection sample, get QR code coordinated and projects them into 3D space. Detect QR codes and call their URLs. You can select between a multiple or single QR code mode. The sample is running at around `70 fps` for multiple QR codes and a stable `72 fps` for a single code. Users are able to choose between CenterOnly and PerCorner raycasting modes via an enum in the inspector. This enables more accurate rotation tracking for use cases that require it (PerCorner), while preserving a faster fallback (CenterOnly).
74+
- **Purpose:** Detect and track QRCodes without having to use a third-party library.
75+
- **Description:** As this feature is still in experimental state, make sure to use experimental mode on your Quest3 when testing. Unity usually asks for enabling that, before building. You can activate it via command line command using Meta Quest Hub too. More information can be found here - [MR Utility Kit QRCode Detection](https://developers.meta.com/horizon/documentation/unity/unity-mr-utility-kit-qrcode-detection) and here - [Mobile Experimental Features](https://developers.meta.com/horizon/documentation/native/android/mobile-experimental-features/)
7676

7777
<details>
7878
<summary>How to run this sample</summary>
7979

80-
- Open the `QRCodeTracking` scene.
81-
- ZXing.Net 0.16.11 is included; the editor script maintains the `ZXING_ENABLED` define.
82-
- Choose Single or Multiple detection mode and the raycast mode (CenterOnly vs PerCorner).
83-
- Build to Quest, point the headset toward QR codes, and interact with the spawned markers.
80+
- Install **TextMeshPro Essentials** if prompted.
81+
- Enable Experimental Mode on your Quest 3/3S (headset UI or Quest Hub CLI).
82+
- Open the **QRCodeDetection** scene.
83+
- Build and deploy to your device, then use the controllers to interact with the UI (hand tracking is not yet supported).
8484

8585
</details>
8686

87-
![QR Code Tracking](https://media.githubusercontent.com/media/xrdevrob/QuestCameraKit/befec3b/Media/QRCodeTracking.gif)
87+
![Native QR tracking](https://media.githubusercontent.com/media/xrdevrob/QuestCameraKit/befec3b/Media/QrCodeDetection.png)
88+
8889

8990
## 4. 🪟 Shader Samples
9091

@@ -239,29 +240,12 @@ https://github.com/user-attachments/assets/a4cfbfc2-0306-40dc-a9a3-cdccffa7afea
239240

240241
![PCA WebRTC](https://media.githubusercontent.com/media/xrdevrob/QuestCameraKit/befec3b/Media/PCA_WebRTC.gif)
241242

242-
## 7. 📅 Experimental QR Code detection
243-
244-
- **Purpose:** Detect and track QRCodes without having to use a third-party library.
245-
- **Description:** As this feature is still in experimental state, make sure to use experimental mode on your Quest3 when testing. Unity usually asks for enabling that, before building. You can activate it via command line command using Meta Quest Hub too. More information can be found here - [MR Utility Kit QRCode Detection](https://developers.meta.com/horizon/documentation/unity/unity-mr-utility-kit-qrcode-detection) and here - [Mobile Experimental Features](https://developers.meta.com/horizon/documentation/native/android/mobile-experimental-features/)
246-
247-
<details>
248-
<summary>How to run this sample</summary>
249-
250-
- Install **TextMeshPro Essentials** if prompted.
251-
- Enable Experimental Mode on your Quest 3/3S (headset UI or Quest Hub CLI).
252-
- Open the **QRCodeDetection** scene.
253-
- Build and deploy to your device, then use the controllers to interact with the UI (hand tracking is not yet supported).
254-
255-
</details>
256-
257-
![Shader Samples](https://media.githubusercontent.com/media/xrdevrob/QuestCameraKit/befec3b/Media/QrCodeDetection.png)
258-
259243
# Update Notes
260244

261245
## Maintenance update
262246

263247
- Unity **6000.3.12f1**, Meta XR Core/MRUK **205.0.0**, Inference Engine **2.6.1**, OpenXR **1.18.0**, Meta OpenXR **2.6.1**, and URP **17.3.0**. Other direct dependencies are pinned in the manifest.
264-
- QR and WebRTC dependencies install with the project. All eight sample scenes are checked for missing scripts.
248+
- QR tracking uses Meta MRUK; WebRTC dependencies install with the project. All seven sample scenes are checked for missing scripts.
265249
- Camera/inference lifecycle fixes, capture-pose detection placement, reusable detection markers, safer voice requests, and corrected stereo WAV encoding.
266250
- API credentials must be supplied privately for ImageLLM; never commit a real key to a prefab or scene.
267251
- **Build and Run** defaults to ColorPicker. Use the per-sample build command and Quak device tests in [Testing](docs/testing.md) for the other scenes.
@@ -311,7 +295,7 @@ Allow Package Manager to resolve the pinned dependencies, then follow the select
311295

312296
# Troubleshooting & Known Issues
313297

314-
- For sample 7 QR Code Detection, make sure experimental mode is active. You can find more information about the necessary steps [here](https://developers.meta.com/horizon/documentation/unity/unity-mr-utility-kit-qrcode-detection).
298+
- For sample 3 QR Code Detection, make sure experimental mode is active. You can find more information about the necessary steps [here](https://developers.meta.com/horizon/documentation/unity/unity-mr-utility-kit-qrcode-detection).
315299
- Object Detection uses `Unity.InferenceEngine` with `com.unity.ai.inference@2.6.1`.
316300
- If switching between Unity 6 and other versions such as 2023 or 2022 it can happen that your Android Manifest is getting modified and the app won't run anymore. Should this happen to you make sure to go to `Meta > Tools > Update AndroidManifest.xml` or `Meta > Tools > Create store-compatible AndroidManifest.xml`. After that make sure you add back the `horizonos.permission.HEADSET_CAMERA` manually into your manifest file.
317301

@@ -401,7 +385,6 @@ large files are removed from the current checkout. See
401385

402386
- Thanks to **Meta** for the Passthrough Camera API and [**Passthrough Camera API Samples**](https://github.com/oculus-samples/Unity-PassthroughCameraApiSamples/).
403387
- Thanks to shader wizard [Daniel Ilett](https://www.youtube.com/@danielilett) for helping me in the shader samples.
404-
- Thanks to **[Michael Jahn](https://github.com/micjahn/ZXing.Net/)** for the ZXing.Net library used for the QR code tracking samples.
405388
- Special thanks to [Markus Altenhofer](https://www.linkedin.com/in/markus-altenhofer-176453155/) from [FireDragonGameStudio](https://www.youtube.com/@firedragongamestudio) for contributing the WebRTC sample scene.
406389
- Special thanks to [Thomas Ratliff](https://x.com/devtom7) for contributing his [shader samples](https://x.com/devtom7/status/1902033672041091453) to the repo.
407390

‎Unity-QuestVisionKit/.gitignore‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ Assets/Nuget.config.meta
129129
**/RuntimeActionBindings.json.meta
130130
.editorconfig
131131

132-
# Checked-in QR runtime dependency.
133-
!Assets/Plugins/ZXing/zxing.dll
134-
135132
# Machine-local SDK configuration and test/build output.
136133
Assets/Resources/DevAgentSettings.asset
137134
Assets/Resources/DevAgentSettings.asset.meta

‎Unity-QuestVisionKit/Assets/Diagnostics/CameraKitState.cs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public sealed class CameraKitState : MonoBehaviour, IQuakStateProvider
1616
private int[] _frames;
1717
private float[] _lastFrameTimes;
1818
private ObjectDetector _detector;
19-
private QrCodeScanner _scanner;
2019
private int _errors;
2120
public string ProviderId => "quest-camera-kit";
2221

@@ -37,7 +36,6 @@ private void Awake()
3736
_frames = new int[_cameras.Length];
3837
_lastFrameTimes = new float[_cameras.Length];
3938
_detector = FindAnyObjectByType<ObjectDetector>();
40-
_scanner = FindAnyObjectByType<QrCodeScanner>();
4139
}
4240

4341
private void OnEnable()
@@ -80,10 +78,6 @@ public string CaptureStateJson()
8078
nativeQrSupported = MRUK.Instance && MRUK.Instance.QRCodeTrackingSupported,
8179
nativeQrTrackingEnabled = MRUK.Instance && MRUK.Instance.SceneSettings.TrackerConfiguration.QRCodeTrackingEnabled
8280
};
83-
#if ZXING_ENABLED
84-
state.qrScanCount = _scanner ? _scanner.CompletedScanCount : 0;
85-
state.qrDecodedCount = _scanner ? _scanner.DecodedCodeCount : 0;
86-
#endif
8781
for (var i = 0; i < _cameras.Length; i++)
8882
{
8983
if (_cameras[i] && _cameras[i].IsPlaying) state.playingCameraCount++;
@@ -102,8 +96,6 @@ private sealed class Snapshot
10296
public int minFramesObserved;
10397
public float maxFrameAgeSeconds;
10498
public int inferenceCount;
105-
public int qrScanCount;
106-
public int qrDecodedCount;
10799
public int errorCount;
108100
public bool nativeQrSupported;
109101
public bool nativeQrTrackingEnabled;

‎Unity-QuestVisionKit/Assets/Editor/MaintenanceChecks.cs‎

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public static void Run()
3939
{
4040
Require(typeof(QuestCameraKit.WebRTC.WebRTCController).GetField("_webRTCConnection",
4141
BindingFlags.NonPublic | BindingFlags.Instance) != null, "WEBRTC_ENABLED must compile the streaming controller.");
42-
Require(SampleMenu.Label("Assets/Samples/7 QRCodeDetection/QRCodeDetection.unity") == "QR tracking (Meta native)",
42+
Require(SampleMenu.Label("Assets/Samples/3 QRCodeDetection/QRCodeDetection.unity") == "QR tracking (Meta native)",
4343
"Native QR must be clearly distinguished from the raw-camera sample.");
44-
Require(SampleMenu.AvailableScenes().Length == 7 && !SampleMenu.AvailableScenes().Any(path => path.Contains("WebRTC-SingleClient")), "The combined build must contain all seven headset samples.");
44+
Require(SampleMenu.AvailableScenes().Length == 6 && !SampleMenu.AvailableScenes().Any(path => path.Contains("WebRTC-SingleClient")), "The combined build must contain all six headset samples.");
4545
CheckWavStereo();
4646
CheckModelContract();
4747
var escape = typeof(ImageOpenAIConnector).GetMethod("EscapeJson", BindingFlags.NonPublic | BindingFlags.Instance);
@@ -57,44 +57,9 @@ public static void Run()
5757
Require((string)escape.Invoke(connector, new object[] { null }) == "", "Null command must serialize safely.");
5858
}
5959
finally { Object.DestroyImmediate(owner); }
60-
#if ZXING_ENABLED
61-
CheckQr();
62-
#else
63-
throw new InvalidOperationException("ZXing must be present and ZXING_ENABLED set; QR sample would otherwise do nothing.");
64-
#endif
6560
Debug.Log("PASS: QuestCameraKit maintenance regression checks.");
6661
}
6762

68-
#if ZXING_ENABLED
69-
private static void CheckQr()
70-
{
71-
var method = typeof(QrCodeScanner).GetMethod("GetFinderCorners", BindingFlags.NonPublic | BindingFlags.Static);
72-
Require(method != null, "QR finder points need a consistent four-corner conversion.");
73-
var points = new[] { new ZXing.ResultPoint(10, 90), new ZXing.ResultPoint(10, 10), new ZXing.ResultPoint(90, 10) };
74-
var corners = (Vector3[])method.Invoke(null, new object[] { points, 100, 100 });
75-
Require(corners.Length == 4 && Vector3.Distance(corners[3], new Vector3(0.9f, 0.9f, 0f)) < 0.0001f,
76-
"Version-one QR finder points must produce a fourth corner.");
77-
var invalid = (Vector3[])method.Invoke(null, new object[] { new ZXing.ResultPoint[0], 100, 100 });
78-
Require(invalid.Length == 0, "Incomplete finder points must be rejected.");
79-
var matrix = new ZXing.QrCode.QRCodeWriter().encode("QuestCameraKit regression", ZXing.BarcodeFormat.QR_CODE, 128, 128);
80-
var pixels = new byte[128 * 128];
81-
for (var y = 0; y < 128; y++)
82-
for (var x = 0; x < 128; x++) pixels[y * 128 + x] = matrix[x, y] ? (byte)0 : (byte)255;
83-
var bitmap = new ZXing.BinaryBitmap(new ZXing.Common.HybridBinarizer(
84-
new ZXing.RGBLuminanceSource(pixels, 128, 128, ZXing.RGBLuminanceSource.BitmapFormat.Gray8)));
85-
var result = new ZXing.QrCode.QRCodeReader().decode(bitmap);
86-
Require(result != null && result.Text == "QuestCameraKit regression", "Bundled ZXing must decode a generated QR.");
87-
var go = new GameObject("qr-no-camera-check");
88-
try
89-
{
90-
var scanner = go.AddComponent<QrCodeScanner>();
91-
var task = scanner.ScanFrameAsync();
92-
Require(task.IsCompleted && task.Result.Length == 0, "Absent camera must return immediately, not leave a pending scan.");
93-
}
94-
finally { Object.DestroyImmediate(go); }
95-
}
96-
#endif
97-
9863
private static void CheckModelContract()
9964
{
10065
var asset = AssetDatabase.LoadAssetAtPath<Unity.InferenceEngine.ModelAsset>(

‎Unity-QuestVisionKit/Assets/Plugins/ZXing.meta‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)