Log in or register to post comments

Simultaneous multiple Multi-Targets tracking

February 6, 2014 - 2:39pm #1

Hi,

According to the forums only single image tracking supports multiple simultaneous tracking, I was wondering is there is a workaround to be able to track two multi-targets simultaneously.

I would like for the user to have the ability to track two multi-target objects within one window.

Any help or work around would be greatly appreciated, also is there an ETA for such a feature to be supported?

Kind Regards,
W

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 1:17pm #15

Lol thanks Nalin, will try once I get hold of a machine. 

 

Thanks again,

W

------ UPDATE ------

It worked perfectly! 

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 5:40am #14

It is not possible that your solution works.

Oh, but it is...  :)

 

You made two mistakes.  

Firstly you need to make this call exactly where I stated, right after InitTracker:

    [self initTracker];

    QCAR::setHint(QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 12);

 
 
Secondly, in order to see two bowls and spoons you need to amend the code in (void)renderFrameQCAR(), because as it stands the code will only ever draw one.  You need to ensure that the code that draws the bowl and spoon is inside a loop that iterates through the number of trackables
 
You could have spotted this by understanding the code a bit better and showing a log as follows:
 

        const QCAR::TrackableResult* result=NULL;

        int numResults=state.getNumTrackableResults();

        NSLog(@"NumTrackableResults = %i",numResults);

 

To make it easier for you I have posted the remaining code for renderFrameQCAR() below.

 

 

HTH

 
N
 
 

    // Did we find any trackables this frame?

    if (state.getNumTrackableResults())

    {

        // Get the trackable:

        const QCAR::TrackableResult* result=NULL;

        int numResults=state.getNumTrackableResults();

        

        NSLog(@"NumTrackableResults = %i",numResults);        

        

        // Browse results searching for the MultiTargets

        for (int j=0;j<numResults;j++)

        {

            result = state.getTrackableResult(j);

            if (result->isOfType(QCAR::MultiTargetResult::getClassType()))

            {

                QCAR::Matrix44F modelViewMatrix =

                QCAR::Tool::convertPose2GLMatrix(result->getPose());

                QCAR::Matrix44F modelViewProjection;

                SampleApplicationUtils::scalePoseMatrix(kCubeScaleX, kCubeScaleY, kCubeScaleZ,

                                                        &modelViewMatrix.data[0]);

                SampleApplicationUtils::multiplyMatrix(&vapp.projectionMatrix.data[0],

                                                       &modelViewMatrix.data[0],

                                                       &modelViewProjection.data[0]);

                

                glUseProgram(shaderProgramID);

                

                // Draw the cube:

                

                // We must detect if background reflection is active and adjust the culling direction.

                // If the reflection is active, this means the pose matrix has been reflected as well,

                // therefore standard counter clockwise face culling will result in "inside out" models.

                glEnable(GL_CULL_FACE);

                glCullFace(GL_BACK);

                if(QCAR::Renderer::getInstance().getVideoBackgroundConfig().mReflection == QCAR::VIDEO_BACKGROUND_REFLECTION_ON)

                    glFrontFace(GL_CW);  //Front camera

                else

                    glFrontFace(GL_CCW);   //Back camera

                

                glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                      (const GLvoid*) &cubeVertices[0]);

                

                glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                      (const GLvoid*) &cubeNormals[0]);

                

                glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,

                                      (const GLvoid*) &cubeTexCoords[0]);

                

                glEnableVertexAttribArray(vertexHandle);

                

                glEnableVertexAttribArray(normalHandle);

                

                glEnableVertexAttribArray(textureCoordHandle);

                

                glActiveTexture(GL_TEXTURE0);

                glBindTexture(GL_TEXTURE_2D, [augmentationTexture[0] textureID]);

                glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,

                                   (GLfloat*)&modelViewProjection.data[0] );

                glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/);

                glDrawElements(GL_TRIANGLES, NUM_CUBE_INDEX, GL_UNSIGNED_SHORT,

                               (const GLvoid*) &cubeIndices[0]);

                glDisable(GL_CULL_FACE);

                

                // Draw the bowl:

                modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());

                

                // Remove the following line to make the bowl stop spinning:

                [self animateBowl: &modelViewMatrix];

                

                SampleApplicationUtils::translatePoseMatrix(0.0f, -0.50f*120.0f, 1.35f*120.0f,

                                                            &modelViewMatrix.data[0]);

                SampleApplicationUtils::rotatePoseMatrix(-90.0f, 1.0f, 0, 0,

                                                         &modelViewMatrix.data[0]);

                

                SampleApplicationUtils::scalePoseMatrix(kBowlScaleX, kBowlScaleY, kBowlScaleZ,

                                                        &modelViewMatrix.data[0]);

                SampleApplicationUtils::multiplyMatrix(&vapp.projectionMatrix.data[0],

                                                       &modelViewMatrix.data[0],

                                                       &modelViewProjection.data[0]);

                

                glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                      (const GLvoid*) &objectVertices[0]);

                glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,

                                      (const GLvoid*) &objectNormals[0]);

                glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,

                                      (const GLvoid*) &objectTexCoords[0]);

                

                glBindTexture(GL_TEXTURE_2D, [augmentationTexture[1] textureID]);

                

                glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,

                                   (GLfloat*)&modelViewProjection.data[0] );

                

                glDrawElements(GL_TRIANGLES, NUM_OBJECT_INDEX, GL_UNSIGNED_SHORT,

                               (const GLvoid*) &objectIndices[0]);

                

                SampleApplicationUtils::checkGlError("MultiTargetss renderFrameQCAR");

                

            }

        }    

        

        // If it was not found exit

        if (result==NULL)

        {

            // Clean up and leave

            glDisable(GL_BLEND);

            glDisable(GL_DEPTH_TEST);

            

            QCAR::Renderer::getInstance().end();

            return;

        }

        

    }

    

    glDisable(GL_BLEND);

    glDisable(GL_DEPTH_TEST);

    

    glDisableVertexAttribArray(vertexHandle);

    glDisableVertexAttribArray(normalHandle);

    glDisableVertexAttribArray(textureCoordHandle);

    

    QCAR::Renderer::getInstance().end();

    [self presentFramebuffer];

 

 

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 4:36am #13

I have tested it in the VuforiaSamples-2.8.9 you have provided as a part of the SDK. Similarly to the vuforiasamples.zip I had sent you the only changes made were the addition of the line you specified and change of the dataset used. Please use the sample application I had sent you earlier. It is not possible that your solution works.

Regards,

W

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 4:28am #12

In that case I do not know what to suggest, as we retested on iOS/Android in native and in Unity, so you must be doing something different.

One thing you could do as a quick test it to try it in Unity in play mode or on the device

 

N

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 4:22am #11

Both objects I am scanning are different, they are the ones I had sent you earlier within the sample application. 

W

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 4:18am #10

Are you multi-targets identical?

This only works if the targets are distinct.

 

N

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 4:12am #9

Thank you for getting back to me, however your solution does not work for me. Within the Session.mm file inside the method of prepareAR() under the [self initTracker]; I have added the setHint. However it still can only work for one object at a time. Any ideas?

 

Regards,
W

Simultaneous multiple Multi-Targets tracking

February 24, 2014 - 3:41am #8

Hi,

After further investigation this does work as expected.

It is however crucial to ensure that the SetHint call to set MAX_SIMULTANEOUS must be done after initialising the tracker.

So in prepareAR() in SampleApplicationSession.mm:

    [self initTracker];    

    QCAR::setHint(QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 12);

 

Hopefully, this will work for you, so let me know.

 

cheers,

N

 

Simultaneous multiple Multi-Targets tracking

February 10, 2014 - 4:49am #7

Will do once I get an opportunity. Thanks again.

W

Simultaneous multiple Multi-Targets tracking

February 10, 2014 - 4:45am #6

Can you PM me with a link to your zipped project (including targets) so I can try to reproduce?

thanks

N

Simultaneous multiple Multi-Targets tracking

February 10, 2014 - 4:36am #5

Native for iOS using Xcode.

Regards,

W

Simultaneous multiple Multi-Targets tracking

February 10, 2014 - 2:50am #4

Is this native or Unity?  Android or iOS?

 

N

Simultaneous multiple Multi-Targets tracking

February 9, 2014 - 6:02pm #3

Hi,

Thank you for the reply. I have already attempted to adjust MAX_SIMULTANEOUS_TARGETS from its inital value of 2 up till 20, all of which have not allowed two products side-by-side to both be 'scanned' within one window. Currently im having to move from one product and focus on another to 'scan' it. I am only using one face/side of the objects side-by-side for this test, with no success.

W

Simultaneous multiple Multi-Targets tracking

February 7, 2014 - 1:41am #2

Hi

Yes this should be possible:

https://developer.vuforia.com/resources/dev-guide/detecting-and-tracking-multiple-targets-simultaneously

Although the link does not mention it specifically you can try increasing MAX_SIMULTANEOUS_TARGETS to 12, though in reality 7 or higher should make this work.

The reason is that each multi-target is made up of 6 image targets, and at any one point in time, only three of them will be in view, and the remainder will be hidden.

Give it a try.

 

HTH

N

Log in or register to post comments