Log in or register to post comments

Reinitialising QCAR

August 2, 2011 - 8:16am #1

Hello,

I'd like to know how/if it's possible to deinitialise QCAR completely then reinitialise it at a later stage in the app? (without using onPause/onResume)

I've tried to use a number of functions including calling:

QCAR::deinit();
[eaglview onDestroy];

Then try to call

[eaglview onCreate];

And tried a bunch of other things, but when I try to reinitialise it I always get the following error (which causes the "Application initialisation failed"):

ERROR: Tracking datasets already loaded - won't load again

Is it possible to unload the tracking dataset?

Thanks for your help!

Re: Reinitialising QCAR

January 30, 2012 - 1:41am #17

Hi lucky - we need some clarification here, and a methodical approach to pin this down.

You say "The problem comes the first we launch the AR View" which you say you do when you press a button, yet the error is this:

"Error launching remote program: failed to get the task for process 2774."

which is a signing/entitlements problem, which only happens at startup?

You need to first resolve the signing problems (nothing we can do to help you there), then insert some logging to show where the error is occuring, at which point we can try to advise.

BTW - is your AppStore published app running until you press the button to launch QCAR? Can you send us a link to the app?

Re: Reinitialising QCAR

January 27, 2012 - 12:20pm #16

Hey MoSR,

I tried using the Ad Hoc Distribution License as well. The problem comes the first we launch the AR View.
It shows up as a pop up when running from XCode:
Error Starting Executable 'MyApp AR'
Error launching remote program: failed to get the task for process 2774.

However, next time on it runs fine.

When i release the app with Distribution License, it fails every time.

I appreciate your assistance here.

Best regards,
Lucky

Re: Reinitialising QCAR

January 27, 2012 - 7:47am #15

Hi Lucky, did you resolve this problem?

Re: Reinitialising QCAR

January 18, 2012 - 4:14am #14

Hi Lucky,

From my experience publishing a number of apps, what you publish is what you get - there is no known difference in the environment between the two. But there could be differences between a debug build and a release build, either from ifdef'd sections or code generation problems (although both unlikely).

Have you tested with an Archive or Release build using an AdHoc distribution license?

Can you confirm that your published app works on the first press of the button and launch of QCAR, that QCAR exits when asked, and you only get the error on the second press?

Re: Reinitialising QCAR

January 18, 2012 - 3:44am #13
MoSR wrote:

The tracker component of Qualcomm AR on iOS isn't unloaded by QCAR::deinit in the current release. Adding a check into the loadTracker method in EAGLView.mm will resolve the re-initialisation error problem.

- (void)loadTracker
{
static bool trackerLoaded = NO;

if (trackerLoaded == NO)
{
// Background thread must have its own autorelease pool
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

// --- tracker initialisation removed for clarity ----

[pool release];

trackerLoaded = YES;
}

// Continue execution on the main thread
[self performSelectorOnMainThread:@selector(bumpAppStatus) withObject:nil waitUntilDone:NO];
}

@MoSR:
I built an app in which QCar creation is done on click of a button.
I used the code suggested above and it works fine while testing the app. i.e. When I re-initialize QCar, it works fine and doesn't throw any error. Eveything worked fine till I published the app.
But after I submitted the same app on Apple's app store, when I click the button for the first time (and also click again), it doesn't open the camera view and throws the following error: "Application initialisation failed".

Any idea why its not working after the app is published?

-lucky

Re: Reinitialising QCAR

September 27, 2011 - 2:14am #12
stridefrodo wrote:

Ability to load tracking database from document folder rather than resource so we can download database on the fly.

Your wish... that's actually what I meant above. :-)

Re: Reinitialising QCAR

September 26, 2011 - 1:20pm #11

I have another feature request :)

Ability to load tracking database from document folder rather than resource so we can download database on the fly.

Re: Reinitialising QCAR

September 23, 2011 - 7:09am #10
omartayeb wrote:

I am loading the tracking data from the Documents directory instead of the assets folder (so that I can swap out the tracking set without updating the app)

I would like to be able to unload the QCAR::Tracker singleton and reload it from scratch after the initial load() is done.

Hi Omar, that feature is in our candidate list for new features in the next version (not for a maintenance release) - thanks for letting us know your use case.

Re: Reinitialising QCAR

September 22, 2011 - 4:47pm #9

Hi MoSR,

Thanks for your replies and help. Can I make a (low priority) feature request please?

I would like to be able to unload the QCAR::Tracker singleton and reload it from scratch after the initial load() is done.

Use-case:

I am loading the tracking data from the Documents directory instead of the assets folder (so that I can swap out the tracking set without updating the app). The only way this works at the moment is if I swap it out just before the app loads. I would like to swap it out while the app is running, by pausing the camera view for a few seconds and running it again.

Thank you!

Re: Reinitialising QCAR

September 13, 2011 - 3:01am #8

BTW - this assumes that you've prevented the Tracker reloading as in my first post on the subject.

Re: Reinitialising QCAR

September 13, 2011 - 3:00am #7

I've created a mock up of what you're trying to do using the ImageTargets project, which successfully restarted the video feed. Here's how I did it.

I regrouped the 'application didFinishLaunchingWithOptions', extracting the QCAR view creation and startup into a function and adding a couple of time triggered functions to control the stop and restart:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    
    window = [[UIWindow alloc] initWithFrame: screenBounds];
    
    [self createQCARview];
    
    [window makeKeyAndVisible];
     
    [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(stopQCAR:) userInfo:nil repeats:NO];
    [NSTimer scheduledTimerWithTimeInterval:20.0 target:self selector:@selector(restartQCAR:) userInfo:nil repeats:NO];
    
    return YES;
}

The QCAR views are now initialised in the recallable function:

- (void) createQCARview
{
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    
    // We are going to rotate our EAGLView by 90 degrees, so its width must be
    // equal to the screen's height, and height to width
    CGRect viewBounds;
    viewBounds.origin.x = 0;
    viewBounds.origin.y = 0;
    viewBounds.size.width = screenBounds.size.height;
    viewBounds.size.height = screenBounds.size.width;
    view = [[EAGLView alloc] initWithFrame: viewBounds];
    //view.backgroundColor = [UIColor redColor];
    
    // Create an auto-rotating overlay view and its view controller (used for
    // displaying UI objects, such as the camera control menu)
    overlayView = [[OverlayView alloc] initWithFrame: screenBounds];
    overlayViewController = [[OverlayViewController alloc] init];
    [overlayViewController setView:overlayView];
    
    // Set the EAGLView's position (its centre) to be the centre of the window
    CGPoint pos;
    pos.x = screenBounds.size.width / 2;
    pos.y = screenBounds.size.height / 2;
    [[view layer] setPosition:pos];
    
    // Rotate the EAGLView by 90 degress (landscape to portrait)
    CGAffineTransform rotate = CGAffineTransformMakeRotation(90 * M_PI  / 180);
    view.transform = rotate;
    
    // Add the EAGLView and the overlay view to the window
    [window addSubview:view];
    [window addSubview: overlayViewController.view];
    
    // Perform actions on the EAGLView now it has been created
    [view onCreate];
}

And my timer stop and restart functions look like this:

- (void) stopQCAR:(NSTimer *)timer
{
    [view onPause];
    [view onDestroy];

    // Create an intermission message window
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    UIView *intervalV = [[UIView alloc] initWithFrame:screenBounds];
    UILabel *intervalL = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 400, 100)];
    intervalL.text = @"Intermission";                     
    [intervalV addSubview:intervalL];
    [window addSubview:intervalV];
    [intervalV release];
    [intervalL release];
    
    // Remove QCAR views from the window
    [view removeFromSuperview];
    view = nil;
    [overlayView removeFromSuperview];
    overlayView = nil;
    [overlayViewController release];
    overlayViewController = nil;
}

- (void) restartQCAR:(NSTimer *)timer
{
    [self createQCARview];
    [view onResume];
}

Hope that helps.

Re: Reinitialising QCAR

September 12, 2011 - 6:05am #6

Same question.

Because when I pause it, I cannot see my video feed when restarting.

Re: Reinitialising QCAR

August 9, 2011 - 8:37am #5

Thanks for your help!

Is there any way at all to unload the tracker?

Re: Reinitialising QCAR

August 5, 2011 - 6:05am #4

The tracker component of Qualcomm AR on iOS isn't unloaded by QCAR::deinit in the current release. Adding a check into the loadTracker method in EAGLView.mm will resolve the re-initialisation error problem.

- (void)loadTracker
{
static bool trackerLoaded = NO;

if (trackerLoaded == NO)
{
// Background thread must have its own autorelease pool
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

// --- tracker initialisation removed for clarity ----

[pool release];

trackerLoaded = YES;
}

// Continue execution on the main thread
[self performSelectorOnMainThread:@selector(bumpAppStatus) withObject:nil waitUntilDone:NO];
}

Re: Reinitialising QCAR

August 2, 2011 - 2:47pm #3

I'm experimenting with integrating a few SDKs together, but to switch to another function in the app it requires all the memory it can get which means completely unloading QCAR and loading it back again when required. Currently it seems to retain the tracking dataset.

Re: Reinitialising QCAR

August 2, 2011 - 11:03am #2

We will look into that. What use-case are you trying to address by de-initializing and re-initializing?

-- Steve

Log in or register to post comments