Log in or register to post comments

Turning Scanner On/Off

April 9, 2013 - 12:19pm #1

My application uses the CloudReco's scanner by calling the CRParentViewController method in a storyboard from a menu.  The scanning works great.  I add a modal view afterwards.  However, when I try returning to the main menu and then calling the CRParentViewController again, I can not start up the scanner.  I know I need to add the targetFinder->startInit method to kick off scanning again and deinitialize the scanner when I move to my modal view.  As a result, I have added a deinitializeTracker method as follows:

 

- (void)deinitializeTracker {

    

    // Background thread must have its own autorelease pool

    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();

    QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));

    if (imageTracker == NULL)

    {

        NSLog(@"Failed to load tracking data set because the ImageTracker has not been initialized.");

        

    }

    

    QCAR::TargetFinder *targetFinder = imageTracker->getTargetFinder();

    if (targetFinder == NULL) {

        NSLog(@"Fialed to get target finder.");

    }

    

    // Deinitialize Visual Search

    targetFinder->deinit();

 

    [pool release];

}

 

I later call the loadTracker method in my ARViewController's ViewDidLoad method.  Unfortunately, I get the following error:

"Failed to load tracking data set because the ImageTracker has not been initialized"

 

Suggestions are welcome.

 

Turning Scanner On/Off

April 11, 2013 - 12:40pm #6

I tried writing another method in CRQCARutils.mm to shut down the tracker. I call this method before creating my modal view to leave the tracker.  I'm guessing that it's only partially doing the job as I still cannot start scanning again after returning to the main menu.

 

- (void)deinitializeTracker {

    

    // Background thread must have its own autorelease pool

    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();

    QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER));

    if (imageTracker == NULL)

    {

        NSLog(@"Failed to load tracking data set because the ImageTracker has not been initialized.");

        

    }

    

    QCAR::TargetFinder *targetFinder = imageTracker->getTargetFinder();

    if (targetFinder == NULL) {

        NSLog(@"Fialed to get target finder.");

    }

    

    // Deinitialize Visual Search

    targetFinder->deinit();

 

    [pool release];

}

 

Any suggestions would be greatly appreciated.

Turning Scanner On/Off

April 11, 2013 - 8:19am #5

No luck.  I've been tracing the code for the attempted scanning of the 2nd image.  When I enter CRParentViewController the 2nd time, the videostream has already been started.  The [QCARHelper startdetecting] method is called which ultimately calls imageTracker->start(); and targetFinder->startRecognition();  Unfortunately, no tracking occurs.

I'm guessing when I leave the scanner the first time, I'm not turning something off that needs to be shut down.

Thanks!

Turning Scanner On/Off

April 10, 2013 - 8:19am #4

The cloud reco sample turns off the scanning functionality when it is displaying book covers, alternating between states using enterScanningMode() and enterContentMode()

Additionally the other technique is simply to use pauseAR() and resumeAR()

 

Have you tried both of these techniques?

N

Turning Scanner On/Off

April 10, 2013 - 7:23am #3

Thanks for your reply.  I have read the threads and understand the tab view application.  I have also looked through the specification and have tried using several of the  methods available in the QCARutils class.  For Vuforia to be successful in our applications, there needs to be a way to turn off the scanning functionality.  We are not as concerned with the delay when restarting the scanner.  We are also finding that leaving the scanner on prohibits us from using QuartzAnimations in other parts of our projects.  

Please advise.

 

Thanks,

Jack

Turning Scanner On/Off

April 10, 2013 - 2:44am #2

 

Hi jackmann,
 
This is because Vuforia has not currently been designed to init() and deinit() within the same session.

Please see this thread for more details and a workaround:

https://developer.vuforia.com/forum/ios/targetfinder-scanline-shows-black-after-reinit

 

N

 

Log in or register to post comments