Log in or register to post comments

Reload dataset everytime the camera view is started

July 18, 2012 - 8:23am #1

Hello,

I have an application which dinamically downloads the dataset before every appearance of the AR view. I would like to reload the dataset every time the AR appears. Please help me.

Reload dataset everytime the camera view is started

August 13, 2012 - 12:27pm #14

Awesome !

Figured there had to be a reason, which came to mind after the initial reply - hence the edit :)

N

Reload dataset everytime the camera view is started

August 13, 2012 - 10:58am #13

The problem was with the missing [qUtils activateDataSet:...] line. Now it works. Thank you very much for your help!

Reload dataset everytime the camera view is started

August 12, 2012 - 1:55pm #12

so does this line get called:

        [qUtils addTargetName:@"trackable5" atPath:@"asset.xml"];

as it does not seem to be showing up in the log?

N

EDIT

One other thing just came to mind:  where are you calling [qUtils activateDataSet] ? 

 

Reload dataset everytime the camera view is started

August 11, 2012 - 7:16am #11

Actually the dataset added second time isn't loaded and activated.

Reload dataset everytime the camera view is started

August 11, 2012 - 7:13am #10

Hi, 

Thank you for your answer. Now all the dat and xml files are in app bundle, so the problem isn't related to download.

This is the implementation of the class which contains the Vuforia AR view:

@implementation HWCameraViewController

 

- (void)loadView {

    QCARutils *qUtils = [QCARutils getInstance];

    

    CGRect screenBounds = [[UIScreen mainScreen] bounds];

        

    // Provide a list of targets we're expecting - the first in the list is the default

    

    if (firstTime) {

        NSLog(@"AR view load 1");

        [qUtils addTargetName:@"Stones & Chips" atPath:@"StonesAndChips.xml"];

 

    }

    else {

        NSLog(@"AR view load 2");

        [qUtils addTargetName:@"trackable5" atPath:@"asset.xml"];

    }

    

    // Add the EAGLView and the overlay view to the window

    arParentViewController = [[ARParentViewController alloc] init];

    arParentViewController.arViewRect = screenBounds;

    [self setView:arParentViewController.view];

}

 

- (void)viewDidLoad {

    [super viewDidLoad];

    firstTime = NO;

}

 

- (void)viewDidAppear:(BOOL)animated {

    [super viewDidAppear:animated];

    

    if (firstTime == NO) {

        // do the same as when the view is shown

        [arParentViewController viewDidAppear:animated];

    }    

    firstTime = NO;

}

 

- (void)viewDidUnload {   

    [arParentViewController release];

    [super viewDidUnload];

}

 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

 

@end

 
 
The dataset added when the view loads second time doesn't work.
Log:
2012-08-11 16:58:26.550 proba[3238:707] AR view load 1
2012-08-11 16:58:26.557 proba[3238:707] ARParentVC: creating
2012-08-11 16:58:26.562 proba[3238:707] ARVC: loadView
2012-08-11 16:58:26.874 proba[3238:707] QCAR OpenGL flag: 2
2012-08-11 16:58:26.877 proba[3238:707] ARVC: viewDidLoad
2012-08-11 16:58:26.897 proba[3238:707] QCARutils onCreate()
2012-08-11 16:58:26.902 proba[3238:707] APPSTATUS_INIT_APP
2012-08-11 16:58:26.908 proba[3238:707] APPSTATUS_INIT_QCAR
2012-08-11 16:58:26.950 proba[3238:707] autofocus: 1, autofocusContinuous: 1, torch 1
2012-08-11 16:58:26.961 proba[3238:707] ARParentVC: loading
2012-08-11 16:58:26.973 proba[3238:707] ARVC: Rotating to Portrait
2012-08-11 16:58:26.966 proba[3238:410b] INFO/AR(3238) 2012-08-11 16:58:26: QCAR SDK version 1.5.8
2012-08-11 16:58:27.000 proba[3238:707] EAGLView: layoutSubviews
2012-08-11 16:58:27.395 proba[3238:707] ARParentVC: appeared
2012-08-11 16:58:27.397 proba[3238:707] ARVC: viewDidAppear
2012-08-11 16:58:27.399 proba[3238:707] QCARutils onResume()
2012-08-11 16:58:27.400 proba[3238:707] viewdidappear arcameravc
2012-08-11 16:58:37.445 proba[3238:707] APPSTATUS_INIT_TRACKER
2012-08-11 16:58:37.468 proba[3238:707] Successfully initialized ImageTracker.
2012-08-11 16:58:37.470 proba[3238:707] APPSTATUS_INIT_APP_AR
2012-08-11 16:58:37.471 proba[3238:707] APPSTATUS_LOAD_TRACKER
2012-08-11 16:58:37.474 proba[3238:410f] INFO/AR(3238) 2012-08-11 16:58:37: ImageTracker: Successfully created dataset
2012-08-11 16:58:37.476 proba[3238:410f] datasetpath:StonesAndChips.xml
2012-08-11 16:58:37.782 proba[3238:410f] Successfully loaded data set.
2012-08-11 16:58:37.786 proba[3238:410f] Successfully activated data set.
2012-08-11 16:58:37.790 proba[3238:707] APPSTATUS_INITED
2012-08-11 16:58:37.791 proba[3238:707] APPSTATUS_CAMERA_RUNNING
2012-08-11 16:58:37.820 proba[3238:707] DEBUG/AR(3238) UIView has CAEAGLLayer class
2012-08-11 16:58:37.822 proba[3238:707] DEBUG/AR(3238) UIView responds to selector renderFrameQCAR
2012-08-11 16:58:38.543 proba[3238:580b] active trackables: 0
2012-08-11 16:58:38.648 proba[3238:580b] active trackables: 0
2012-08-11 16:58:40.823 proba[3238:580b] active trackables: 1
2012-08-11 16:58:40.891 proba[3238:580b] active trackables: 1
2012-08-11 16:58:40.922 proba[3238:580b] active trackables: 1
2012-08-11 16:58:44.818 proba[3238:707] ARVC: viewDidDisappear
2012-08-11 16:58:44.820 proba[3238:707] QCARutils onPause()
2012-08-11 16:58:44.821 proba[3238:707] APPSTATUS_CAMERA_STOPPED
2012-08-11 16:58:46.352 proba[3238:707] AR view load 2
2012-08-11 16:58:46.353 proba[3238:707] ARParentVC: creating
2012-08-11 16:58:46.355 proba[3238:707] ARVC: loadView
2012-08-11 16:58:46.372 proba[3238:707] QCAR OpenGL flag: 2
2012-08-11 16:58:46.374 proba[3238:707] ARVC: viewDidLoad
2012-08-11 16:58:46.392 proba[3238:707] QCARutils onCreate()
2012-08-11 16:58:46.396 proba[3238:707] autofocus: 1, autofocusContinuous: 1, torch 1
2012-08-11 16:58:46.398 proba[3238:707] ARParentVC: loading
2012-08-11 16:58:46.400 proba[3238:707] ARVC: Rotating to Portrait
2012-08-11 16:58:46.407 proba[3238:707] EAGLView: layoutSubviews
2012-08-11 16:58:46.777 proba[3238:707] ARParentVC: appeared
2012-08-11 16:58:46.780 proba[3238:707] ARVC: viewDidAppear
2012-08-11 16:58:46.782 proba[3238:707] QCARutils onResume()
2012-08-11 16:58:46.836 proba[3238:707] APPSTATUS_CAMERA_RUNNING
2012-08-11 16:58:46.839 proba[3238:707] DEBUG/AR(3238) UIView has CAEAGLLayer class
2012-08-11 16:58:46.841 proba[3238:707] DEBUG/AR(3238) UIView responds to selector renderFrameQCAR
2012-08-11 16:58:47.499 proba[3238:707] viewdidappear arcameravc
2012-08-11 16:58:47.517 proba[3238:8b03] active trackables: 0
2012-08-11 16:58:47.646 proba[3238:8b03] active trackables: 0
2012-08-11 16:58:47.748 proba[3238:8b03] active trackables: 0

Reload dataset everytime the camera view is started

August 8, 2012 - 1:51am #9

After calling the destroyAR, and continue to use the singleton qUtils of intact, it seems to crash.

So, this code it is NG.

I thought APPSTATUS_UNINITED will return to the status, and continue working without problem.

Was troubled.

Reload dataset everytime the camera view is started

August 7, 2012 - 3:32am #8

I have crash on "if (!theDataSet->load([dataSetPath cStringUsingEncoding:NSASCIIStringEncoding], QCAR::DataSet::STORAGE_ABSOLUTE))".

Cause of Crash is because the path and name of the class is closed DataSetItem been release.

To fix this, edit as follows: DataSetItem class.

 

# pragma mark --- Class interface for DataSet list ---

@ implementation DataSetItem

 

@ synthesize name;

@ synthesize path;

@ synthesize dataSet;

 

- (Id) initWithName: (NSString *) theName andPath: (NSString *) thePath

{

     self = [super init];

     if (self) {

         name = theName;

         path = thePath;

 

        [name retain]; / / / / add line

        [path retain]; / / / / add line

 

         dataSet = nil;

     }

     return self;

}

 

/ / / / add dealloc block

- (Void) dealloc

{

    [name release];

    [path release];

 

     [super dealloc];

}

 

@ end

Reload dataset everytime the camera view is started

August 5, 2012 - 9:03pm #7

on QCARutils.mm

 

////////////////////////////////////////////////////////////////////////////////

// destroy the Augmented Reality context

- (void)destroyAR

{

    NSLog(@"QCARutils onDestroy()");   

 

    // Deinitialise QCAR SDK

    if (appStatus != APPSTATUS_UNINITED)

    {

        //clear old registrated marker information on QCARutil

        [targetsList removeAllObjects];  //add this line

        QCAR::deinit();

 

    }

    appStatus = APPSTATUS_UNINITED;

 

}

 

on ARViewController.m

 

- (void)viewWillAppear:(BOOL)animated

{

    //add this block

    if(qUtils.appStatus == APPSTATUS_UNINITED)

    {

        [qUtils createARofSize:arViewSize forDelegate:arView];

        arVisible = NO;

    }

 

    NSLog(@"ARVC: viewWillAppear");

}

 

on your Marker registration process

 

    QCARutils *qUtils = [QCARutils getInstance];

 

    if(qUtils.appStatus != APPSTATUS_UNINITED)

    {

        //delete AR data

        [qUtils destroyAR];

    }

 

    //new registration marker…

 

    [someView addSubview:arParentViewController.view];

 

 

New marker should now be reloaded.

Because the code was modified without permission, there might be a bug.

Also, please tell me if there is a mistake.

 

English is not good for, and then use machine translation.

If you are hard to read I'm sorry.

Reload dataset everytime the camera view is started

August 5, 2012 - 8:21pm #6

Can you post up what the XCode log is actually showing and whether there are any errors at all?

The other thing you could do as an interim step is to have all the different data sets present within the bundle as this will help you track down exactly where the problem is i.e. is it to do with downloading or is it due to activation.

Any more info you can provide would be most helpful.

N

Reload dataset everytime the camera view is started

August 4, 2012 - 11:28am #5

Hi,

The problem is that only the first dataset is working (which was added the first time that vuforia view was started).

Reload dataset everytime the camera view is started

July 19, 2012 - 4:07am #4

Hi MBeata,

What is the problem you are having with this?

N

Reload dataset everytime the camera view is started

July 18, 2012 - 8:58am #3

Thank you for the reply.

When the vuforia AR view is started first time, everything is ok, the dataset is loaded from the documents folder. Then if I go back to the other view, there I do something, and I get the new dataset. After that I have to go again to the vuforia AR view, and in this step i would like to reload the dataset.

Reload dataset everytime the camera view is started

July 18, 2012 - 8:46am #2

Hi MBeata

      I have an application which dinamically downloads the dataset before every appearance of the AR view.

There will be a natural delay which I am sure you can understand, though it is not clear why you need to download a dataset before every appearance?  This delay will be extended by the fact that Vuforia will need time to catch up every time you change/activate datasets.

      I would like to reload the dataset every time the AR appears.

Have a look at this thread which will explain some more and has some sample code:

https://ar.qualcomm.at/content/read-xml-document-folder

... however it might be worth thinking through whether this is the best strategy.  

Basically once you download remote datasets (XML+DAT files) you need to store them in the documents directory.  This thread will show you how to invoke these as opposed to datasets that are part of the app bundle.

HTH

N

 

 

 

 

Log in or register to post comments