Log in or register to post comments

How do I push a view controller once an image tracker is recognized?

April 11, 2012 - 10:36am #1

How do I push a view controller once an image tracker is recognized? Where do I call [self presentModalViewController: ] from?

I want to recognize an image, and push a view controller with my own views in it.
I can show a view, by adding my own view as a subview in EAGLView's render method, but I need an entire view controller to be shown.

Re: How do I push a view controller once an image tracker is rec

April 12, 2012 - 6:51am #7

That's good Supereid86 - but take heed of the first item as well:

"If you want to invoke a pop-up screen on only the first detection, you need to set up the logic to do that."

It could be possible to get a second 'frame' after detection causing another attempt to pop-up a modal view, before pauseAR has had time to stop the camera pipeline.

Re: How do I push a view controller once an image tracker is rec

April 12, 2012 - 6:37am #6

@MOSR

Using pauseAR before the delegate receives the message and resumeAR after popup is dismissed solved my problem, as the AR stopped looking for tracking markers.

Thanks!

Re: How do I push a view controller once an image tracker is rec

April 12, 2012 - 6:31am #5

Hi Supereid86,

This is an app logic design problem not a QCAR issue. This is code that makes up the behaviour of your app.

If you want to invoke a pop-up screen on only the first detection, you need to set up the logic to do that.

If you want the pop-up to stay around for a period of time after the detection has failed you need to implement a timeout.

If you want the further detections to not attempt to pop-up again until the user has dismissed the pop-up you need to block that yourself.

If you want detection to stop whilst the pop-up is visible you need to use pauseAR and resumeAR.

Re: How do I push a view controller once an image tracker is rec

April 12, 2012 - 6:15am #4

In the render method I added the following code:

if ((trackable->getStatus(), "DETECTED"))
{
[self.delegate EAGLView:self didRecognizeMarkerAtIndex:targetIndex];
}

The problem is that this gets called like 60 times/second, as long as the tracker is on screen. How do I get it to make the call to the delegate only once?

See NSLog output below:

2012-04-12 09:13:14.551 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.597 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.628 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.651 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.695 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.728 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.750 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.796 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.828 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.851 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.895 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.928 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.951 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:14.996 AhmedAR[11485:560b] Did recognize marker at index 0
2012-04-12 09:13:15.028 AhmedAR[11485:560b] Did recognize marker at index 0

Re: How do I push a view controller once an image tracker is rec

April 12, 2012 - 5:40am #3

@MOSR, my question had more to do with the workings of the EAGLView view. When it recognizes a marker image, it calls renderFRameQCAR, and whatever code gets put in there will get called, as long as the marker is on screen.

If I call an action on the main thread here, it will get called many times over, as long as the image tracker remains on screen.
I setup a delegate protocol on EAGLView, with a method

-(void)EAGLView:(EAGLView *)eaglView didRecognizeMarkerAtIndex:(int)targetIndex;

Where is the best place to call this in EAGLView to notify it's delegate (in my case ARViewController) that the index has been recognized?

Re: How do I push a view controller once an image tracker is rec

April 12, 2012 - 2:37am #2
Supereid86 wrote:

How do I push a view controller once an image tracker is recognized? Where do I call [self presentModalViewController: ] from?

In the same way that you'd enable/modify a view, you need to call a method on the main thread that calls [ presentModalViewController] - you could use your own root view controller, or arParentViewController, depending on where you want to insert views.

The method can be in your appDelegate, you own view controller, arParentViewController or even in the EAGLView - you just need access to the viewController object from wherever you invoke the method.

Log in or register to post comments