Search code examples
iosswiftaugmented-realitykudan

Kudan: Is it possible to call a function when a marker is detected?


I am using Kudan AR framework https://www.kudan.eu/ to develop iPhone app on Xcode 7.3.1.

I am able to reproduce the basic like how to setup model and tracker. When a marker is detected in an ARCameraViewController, an armodel successfully appears in the camera view.

My situation is: I want to call a function when a marker is detected in ARCameraViewController. The function may be print("hello") or download something.

How may we achieve this?


Solution

  • You want to use:

    - (void)addTrackingEventTarget:(id)target action:(SEL)action forEvent:(ARImageTrackableEvents)event;
    

    e.g.

    [trackable addTrackingEventTarget:self action:@selector(imageDetected:) forEvent:ARImageTrackableEventDetected];
    

    You can find a bit more documentation about this in Kudan's API docs https://wiki.kudan.eu/apidocs/iOSDocs/db/de1/interface_a_r_image_trackable.html#ae5329511da8f0b137e2d472e52c22e95