You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新手求助:HoloLens 2 AR应用中如何访问相机流实现标记识别?

Hey there! Let’s work through your HoloLens 2 marker recognition issue together— I’ve tackled similar problems with MRTK and camera streams, so here’s a step-by-step breakdown to get things working:

1. Double-Check HoloLens Camera Permissions & Capabilities

First off, HoloLens is strict about hardware permissions, so let’s make sure your app has access to the camera:

  • Open Edit > Project Settings > Player > Publishing Settings > Capabilities
  • Ensure Webcam and SpatialPerception are both checked (SpatialPerception helps with alignment, even if you’re just using markers)
  • If you haven’t already, add runtime permission requests in your code. HoloLens won’t auto-grant camera access on first launch:
    using UnityEngine;
    
    void Start()
    {
        if (!WebCamDevice.HasUserAuthorization())
        {
            WebCamDevice.RequestUserAuthorization();
        }
    }
    
2. Use MRTK’s Built-In Camera System (Skip Custom AR Cameras)

MRTK handles HoloLens’s camera pipeline natively— manually adding AR camera components or custom cameras will almost always cause conflicts:

  • Delete any custom AR cameras or AR-related components you added to the Main Camera
  • Run Mixed Reality Toolkit > Configure > Apply Mixed Reality Project Settings— this auto-sets up the correct Main Camera with the Mixed Reality Camera component
  • Confirm the Main Camera is a child of MixedRealityPlaySpace (it should be by default after running the setup tool)
3. Verify the Camera Stream is Actually Working

Before troubleshooting marker recognition, confirm the camera feed is reaching your app:

  • Add a RawImage to your UI Canvas
  • Attach this simple debug script to the Canvas:
    using UnityEngine;
    using UnityEngine.UI;
    
    public class CameraFeedDebug : MonoBehaviour
    {
        public RawImage debugDisplay;
        private WebCamTexture camTexture;
    
        void Start()
        {
            if (WebCamDevice.HasUserAuthorization())
            {
                WebCamDevice[] devices = WebCamTexture.devices;
                if (devices.Length > 0)
                {
                    camTexture = new WebCamTexture(devices[0].name, 1920, 1080);
                    debugDisplay.texture = camTexture;
                    camTexture.Play();
                }
            }
        }
    
        void OnDestroy() => camTexture?.Stop();
    }
    
  • Deploy to HoloLens— if you see the camera feed in the UI, the stream is working; if not, circle back to permissions or MRTK setup.
4. Tune Marker Recognition for HoloLens’s Camera Specs

HoloLens’s camera has unique specs that might not match your external camera setup:

  • HoloLens 2’s main camera runs at 1920x1080@30fps with a ~60° horizontal FOV
  • Update your marker recognition library’s camera settings to match these values:
    • For Vuforia: In the AR Camera component, select "HoloLens Camera" as the device, set focus mode to Auto, and input the correct resolution/FOV
    • For ARToolKit: Adjust the ARController’s camera width/height to 1920/1080 and set FOV to 60°
  • Make sure the library is using perspective projection (HoloLens doesn’t use orthogonal cameras)
5. Eliminate Camera Conflicts

Multiple active cameras or modified camera properties can block the marker recognition library from accessing the stream:

  • Ensure only the MRTK Main Camera is enabled in your scene
  • Check for scripts that modify the camera’s targetTexture, cullingMask, or depth— these can override the feed going to your marker library
6. Test with a Minimal Project

If all else fails, isolate the issue with a clean project:

  • Create a new Unity project, import MRTK Foundation and your marker library
  • Set up only the essentials: MixedRealityPlaySpace, MRTK-configured Main Camera, marker prefab, and the camera feed debug UI
  • Deploy to HoloLens— if markers work here, your original project has conflicting components or settings to track down

Hope these steps get your marker recognition up and running on HoloLens 2!

内容的提问来源于stack exchange,提问作者Imran Khan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 19:18:15