Hi,
The simplest way to achieve this would be to keep track of the number of trackable results in renderFrameQCAR(), which you can see here:
QCAR::State state = QCAR::Renderer::getInstance().begin();
NSLog(@"active trackables: %d", state.getNumTrackableResults());
What you could do is store this each frame, and as soon as it changes then you can trigger a callback, and the simplest way of doing this would be to use notifications.
So in renderFrameQCAR() when the number changes you could post it using something like this:
NSNumber* numberofTrackables = [NSNumber numberWithInt:state.getNumTrackableResults()];
[[NSNotificationCenter defaultCenter] postNotificationName:kUpdatedNumberofTrackables
object:numberofTrackables
userInfo:nil];
...and on the receiving end where you need the callback:
[[NSNotificationCenter defaultCenter]
addObserverForName:kUpdatedNumberofTrackables
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *notification) {
NSNumber* object:numberofTrackables = notification.object;
NSLog(@"number of trackables found = %@", numberofTrackables);
// do other work
}];
The only other thing you may need to do is define the notification once
NSString * const kUpdatedNumberofTrackables = @"kUpdatedNumberofTrackables";
...and also again to refer to it externally:
extern NSString * const kUpdatedNumberofTrackables;
HTH
N
Hi i've been using a similar aproach to what you describe, and it works perfect when calling the notification. but when i try to do something with object attached to the notification (a NSString with a url) my app crashes with error exc_bad_access code=1 on the first line my object is use.
Im trying to get a url from the target metadata and then use this url to launch a web page. my code works perfectly when i use a constant string like this
- (void) urlButtonTapped:(id)sender
{
url = [NSURL URLWithString:@"http://www.demotec.mx"];
if (![[UIApplication sharedApplication] openURL:url])
NSLog(@"%@%@",@"Failed to open url:",[url description]);
}
but when i use a global string with the url on it instead of @"http://www.demotec.mx" my app crashes
hope someone can help me with this issue