Only able to detect and track up to 4 images at a time with ARKit 3.0

这一生的挚爱 提交于 2019-12-10 13:27:22

问题


Using the code below I'm only able to detect and track up to 4 images at any one time when using ARKit.

ARImageTrackingConfiguration *configuration = [ARImageTrackingConfiguration new];  
configuration.trackingImages = [ARReferenceImage referenceImagesInGroupNamed:@"AR Resources" bundle:nil];  
configuration.maximumNumberOfTrackedImages = 100;  
[self.sceneView.session runWithConfiguration:configuration]; 

Is anyone able to confirm what I'm seeing? I need to be able to track a larger number of images/markers and was excited when I saw this offered in the ARKit 3 announcement.

Would be great if someone is able to replicate this so I know I'm not imagining things ^^

I hope this isn't an Apple limitation, the 3DS could detect and track more than 4 images over 8 years ago.


回答1:


Try to use .detectionImages instance property in ARWorldTrackingConfiguration instead of .trackingImages in ARImageTrackingConfiguration.

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    ARWorldTrackingConfiguration *configuration = [ARWorldTrackingConfiguration new];
    configuration.detectionImages = [ARReferenceImage referenceImagesInGroupNamed:@"AR Resources" bundle:nil];

    configuration.maximumNumberOfTrackedImages = 100;   // in ARKit 3.0 image-tracking session
    //configuration.maximumNumberOfTrackedImages = 25;  // in ARKit 2.0 image-tracking session

    [self.sceneView.session runWithConfiguration:configuration];
}

Apple documentation is similar for both trackingImages and detectionImages:

Use this property to choose known 2D images for ARKit to find in the user's environment and present as ARImageAnchor for use in your AR experience.

and Apple documentation also says:

Image-only tracking lets you anchor virtual content to known images only when those images are in view of the camera. World tracking with image detection lets you use known images to add virtual content to the 3D world, and continues to track the position of that content in world space even after the image is no longer in view.

Although a world-tracking session with image tracking enabled can simultaneously track a small number of images, so you can usually track more images with image-tracking session. But in situation when being tracked images are out of view, world-tracking session is more preferable.




回答2:


Found the official answer in a comment made to ARImageTrackingConfiguration:

@discussion Image tracking provides 6 degrees of freedom tracking of known images. Four images may be tracked simultaneously.

EDIT: Found in ARConfiguration.h, line 336



来源:https://stackoverflow.com/questions/56816333/only-able-to-detect-and-track-up-to-4-images-at-a-time-with-arkit-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!