Log in or register to post comments

getName() for frame marker target

November 12, 2011 - 4:24pm #1

Hello,

I am trying to pass an int representing the name of the current trackable back to Java. This is working for the "chips" and "stones" ImageTargets, but the frame marker target I have added is not correctly identified.

My C++:

			...
				if(strcmp(trackable->getName(), "mymarker1"){
					trackerNum = 3;
				}
				else if(strcmp(trackable->getName(), "chips")){
					trackerNum = 2;
				}
				else if(strcmp(trackable->getName(), "stones")){
					trackerNum = 1;
				}
				else {
					trackerNum = 0;
				}

                		LOG("tapped inside the target!");
				displayMessage(trackerNum, intersection.data[0], intersection.data[1]);

My config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<QCARConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="qcar_config.xsd">
  <Tracking>
   <ImageTarget size="247 173" name="stones" />
   <ImageTarget size="247 173" name="chips" />
   <Marker type="id-frame" id="0" size="50 50" name="mymarker1" /> 
  </Tracking>
</QCARConfig>

The correct int is assigned for the "chips" and "stones" targets, but the frame marker is always assigned the int for the first of "chips" and "stones" to appear in the control statement (in this case, the frame marker is assigned the "chips" value of 2, but if I place the control statement for "stones" before the statement for "chips" then the frame marker is assigned the value for
"stones").

Can anyone help me fix this control statement or find a different way to pass a unique ID for the trackables to Java?

I appreciate the assistance.

Re: getName() for frame marker target

November 14, 2011 - 10:38am #3

That works; thank you so much for the help.

Re: getName() for frame marker target

November 12, 2011 - 9:17pm #2

strcmp returns 0 when two strings are equal:

Quote:

The strcmp() and strncmp() return an integer greater than, equal to, or less than 0, according as the string s1 is greater than, equal to, or less than the string s2.

So this should look more like this:

if(strcmp(trackable->getName(), "mymarker1") == 0)
{
    trackerNum = 3;
}
...

- Kim

Log in or register to post comments