Log in or register to post comments

Using Frame Markers and image Targets Together in iOS app

April 5, 2012 - 4:06am #1

Hi am newbi of QualComm Voforia
I have one Question Can we use Frame Markers and image Targets Together with following condition
At Same time Application Can recognize Both like Registered Image Target and Frame markers. ?

Using Frame Markers and image Targets Together in iOS app

August 16, 2012 - 3:52am #6

Yes this is possible.

I just built a sample to test it by taking the ImageTargets app and adding the FrameMarker code.

You will need to do a fair amount of tweaking, as the samples assume that the target type is mutually exclusive.

So basically rather than using  TargetType targetType;

You need to set up QCAR Utils to use:

    BOOL INIT_IMAGETARGETS;

    BOOL INIT_FRAMEMARKERS;

...which can be set in the init function.

Below are some more code snippets that show how the trackers can be set up in QCARUtils.mm.

HTH

N

- (int)initTracker

{

    int res = 0;

    

    // Initialize the image or marker tracker

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

 

    

    if (INIT_IMAGETARGETS)

    {

        // Image Tracker...

        QCAR::Tracker* trackerBase = trackerManager.initTracker(QCAR::Tracker::IMAGE_TRACKER);

        if (trackerBase == NULL)

        {

            NSLog(@"Failed to initialize ImageTracker.");

        }

        else

        {

            NSLog(@"Successfully initialized ImageTracker.");

            res = 1;

        }

    }

 

    if (INIT_FRAMEMARKERS)

    {

        // Marker Tracker...

        QCAR::Tracker* trackerBase = trackerManager.initTracker(QCAR::Tracker::MARKER_TRACKER);

        if (trackerBase == NULL)

        {

            NSLog(@"Failed to initialize MarkerTracker.");            

        }

        else

        {

            NSLog(@"Successfully initialized MarkerTracker.");

            

            // Create the markers required

            QCAR::MarkerTracker* markerTracker = static_cast<QCAR::MarkerTracker*>(trackerBase);

            if (markerTracker == NULL)

            {

                NSLog(@"Failed to get MarkerTracker.");

            }

            else

            {

                NSLog(@"Successfully got MarkerTracker.");

                

                // Create frame markers:

                if (!markerTracker->createFrameMarker(0, "MarkerQ", QCAR::Vec2F(50,50)) ||

                    !markerTracker->createFrameMarker(1, "MarkerC", QCAR::Vec2F(50,50)) ||

                    !markerTracker->createFrameMarker(2, "MarkerA", QCAR::Vec2F(50,50)) ||

                    !markerTracker->createFrameMarker(3, "MarkerR", QCAR::Vec2F(50,50)))

                {

                    NSLog(@"Failed to create frame markers.");

                }

                else

                {

                    NSLog(@"Successfully created frame markers.");

                    res = 1;

                }

            }

        }

    }

    

    if (res == 0)

    {

        appStatus = APPSTATUS_ERROR;

        errorCode = QCAR_ERRCODE_INIT_TRACKER;

    }

    

    return res;

}

 
 

- (void)startCamera

{

    // Initialise the camera

    if (QCAR::CameraDevice::getInstance().init()) {

        // Configure video background

        [self configureVideoBackground];

        

        //// Select the default mode - given as example of how and where to set the Camera mode

        //if (QCAR::CameraDevice::getInstance().selectVideoMode(QCAR::CameraDevice::MODE_DEFAULT)) {

        

        // Start camera capturing

        if (QCAR::CameraDevice::getInstance().start()) {

            // Start the tracker

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

 

 

 

            if (INIT_IMAGETARGETS)

            {

                QCAR::Tracker* tracker = trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER);

 

                if(tracker != 0)

                    tracker->start();

            }

            

            if (INIT_FRAMEMARKERS)

            {

                QCAR::Tracker* trackerFM = trackerManager.getTracker(                                                               QCAR::Tracker::MARKER_TRACKER);

                

                if(trackerFM != 0)

                    trackerFM->start();                

            }

            

            // Cache the projection matrix:

            const QCAR::CameraCalibration& cameraCalibration = QCAR::CameraDevice::getInstance().getCameraCalibration();

            projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f, 2000.0f);

        }

        

        // Restore camera settings

        [self restoreCameraSettings];

    }

}

 

 

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

// Stop capturing images from the camera

- (void)stopCamera

{

    // not done properly for both

    

    // Stop the tracker:

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

    

    if (INIT_IMAGETARGETS)

    {

        QCAR::Tracker* tracker = trackerManager.getTracker(QCAR::Tracker::IMAGE_TRACKER);

        if(tracker != 0)

            tracker->stop();

    }

    if (INIT_FRAMEMARKERS)

    {

        QCAR::Tracker* tracker = trackerManager.getTracker(QCAR::Tracker::MARKER_TRACKER);

        if(tracker != 0)

            tracker->stop();

    }

    

    

    QCAR::CameraDevice::getInstance().stop();

    QCAR::CameraDevice::getInstance().deinit();

}

 

 

 

Using Frame Markers and image Targets Together in iOS app

August 14, 2012 - 9:20am #5

I've tried doing this and it crashed while creating frame markers after the initialization of both trackers.

The frame markers creation is done using the createFrameMarker function of MarkerTracker class.

Re: Using Frame Markers and image Targets Together in iOS app

June 10, 2012 - 5:25pm #4

Hi! I'm a developer using Vuforia for the first time. I'm trying to detect and track a frame marker sitting on an image target, I've nitialized both the IMAGE_TRACKER and MARKER_TRACKER in QCARutils.mm.

I'm trying to use the ImageTargets sample. I've rewritten initTracker as follows, but it only detects the image targets… Please, help!

- (int)initTracker
{
    int res = 0;  
    QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
    
    QCAR::Tracker* trackerBase = trackerManager.initTracker(QCAR::Tracker::IMAGE_TRACKER);
    if (trackerBase == NULL) {
        NSLog(@"Failed to initialize ImageTracker.");
    }
    else {
        NSLog(@"Successfully initialized ImageTracker.");
        res = 1;
    }
    

    QCAR::Tracker* trackerBase2 = trackerManager.initTracker(QCAR::Tracker::MARKER_TRACKER);
    if (trackerBase2 == NULL) {
        NSLog(@"Failed to initialize MarkerTracker.");            
    }
    else {
        NSLog(@"Successfully initialized MarkerTracker.");
        
        QCAR::MarkerTracker* markerTracker = static_cast<QCAR::MarkerTracker*>(trackerBase2);
        if (markerTracker == NULL) {
            NSLog(@"Failed to get MarkerTracker.");
        }
        else {
            NSLog(@"Successfully got MarkerTracker.");
            
            if (!markerTracker->createFrameMarker(0, "MarkerQ", QCAR::Vec2F(50,50)) ||
                !markerTracker->createFrameMarker(1, "MarkerC", QCAR::Vec2F(50,50)) ||
                !markerTracker->createFrameMarker(2, "MarkerA", QCAR::Vec2F(50,50)) ||
                !markerTracker->createFrameMarker(3, "MarkerR", QCAR::Vec2F(50,50)))
            {
                NSLog(@"Failed to create frame markers.");
            }
            else {
                NSLog(@"Successfully created frame markers.");
                res = 1;
            }
        }
    }
    if (res == 0) {
        appStatus = APPSTATUS_ERROR;
        errorCode = QCAR_ERRCODE_INIT_TRACKER;
    }
    return res;
}

Re: Using Frame Markers and image Targets Together in iOS app

April 6, 2012 - 12:21am #3

Thanks ksiva. I'll Definitely try this today it self and If got any issue will let you know.

Re: Using Frame Markers and image Targets Together in iOS app

April 5, 2012 - 4:00pm #2

Sure! You could for example place an image target inside the frame marker, track them side by side, or track the frame marker sitting on an image target. Make sure the frame marker has a solid (e.g. white) border around the black frame, especially if you're going to track it sitting on top of an image target. See the dev guide for details.

Make sure you initialize both the IMAGE_TRACKER and MARKER_TRACKER for this to work. See QCARutils.mm.

QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
QCAR::Tracker* trackerBase = trackerManager.initTracker(QCAR::Tracker::IMAGE_TRACKER);
QCAR::Tracker* trackerBase = trackerManager.initTracker(QCAR::Tracker::MARKER_TRACKER);

- Kim

Log in or register to post comments