Topic locked

Track Target position and distance in ImageTarget

December 15, 2014 - 6:31am #1

Hi, 

I use Vuforia ImageTarget Sample 3.0.9 on iOS, We replaced OpenGL 3d object, by displaying image 2d related to terget's content. But image doesn't make tracking with target like opengl 3d object.

I need to make this tracking with image too, I read this articles:

https://developer.vuforia.com/resources/dev-guide/positioning-3d-content

https://developer.vuforia.com/resources/dev-guide/pose-matrix-explained

https://developer.vuforia.com/resources/dev-guide/distance-target

But still couldn't make image track the target. That for Position/Scale/Distance ... etc.

How can we do that ? Is there any way to do that ?

 

Than you,

Khaled

Track Target position and distance in ImageTarget

December 23, 2014 - 4:36am #14

Glad  to hear this ;-)

Track Target position and distance in ImageTarget

December 23, 2014 - 1:49am #13

Than you very much it's working now :)

I found your answer about: power-of-two sized textures (e.g. 256 x 256, or 256 x 128, etc.)

in this forum question:

https://developer.vuforia.com/forum/android/texture-black-when-rendering

Track Target position and distance in ImageTarget

December 23, 2014 - 1:35am #12

Thank you for reply,

Actually i found the code but it works Great on Only "Vuforia images" which are:

"TextureTeapotBrass.png", "TextureTeapotBlue.png", "TextureTeapotRed.png", "building_texture.jpeg"

Any of this images I can see it on target with Great tracking.

But any other image is Black !! 

Do you know the reason ? Is image must has special properties ?

Track Target position and distance in ImageTarget

December 22, 2014 - 7:43am #11

On iOS you can look at the ImageTargetsEAGLView.mm file (see the initWithFrame method in particular).

 

Track Target position and distance in ImageTarget

December 22, 2014 - 7:27am #10

I'm working on iOS Vuforia 3.0.9 version, also I searched in whole project and I didn't find loadTextures() in original sample code.

I have ImageTagersViewController.m file. and no ImageTargetsRenderer class found.

I found loadTextures() in Vuforia 2.x, old version, what is the coorosponding code to it in new version ?

Track Target position and distance in ImageTarget

December 22, 2014 - 6:23am #9

Sure, you can start by looking at the loadTextures() method in ImageTargets.java in the VuforiaSamples sample project; you then need to look at the code i ImageTargetsRenderer.java, where you can find the code snippets that map the texture images to a set of OpenGL textures.

 

Track Target position and distance in ImageTarget

December 22, 2014 - 5:57am #8

Thank you for reply.

I actually searched in Vuforia code about get image texture, I found something like that but in Cloud of Vuforia 2.9.

But I work now on Vuforia 3.0.9, and ImageTarget sample works on drawing 3d object by openGL,

so please, can you guide me by some code or where can I find this code in ImageTarget Vuforia 3.0.9 to get texture of image ?

Thank you,

Track Target position and distance in ImageTarget

December 22, 2014 - 1:30am #7

But, my image (not openGL draw, normal image added to screen when ddetect this target) has no changes.

Do you know how can I make image tracking like this Black rectangle ?

The best way of tracking an image in 3D space is by creating an OpenGL texture from your image (i.e. load the image and make a texture out of it, as shown in the Image Targets sample code, for instance).  Then, you can apply the texture on a textured plane; in practice, it's about using the same approach that you have already successfully implemented for your "Black rectangle", but adding an OpenGL texture to it.

 

Track Target position and distance in ImageTarget

December 20, 2014 - 11:53pm #6

Thank you, it works,

I see Black rectangle with size = target size in true position and distance from target.

But, my image (not openGL draw, normal image added to screen when ddetect this target) has no changes.

Do you know how can I make image tracking like this Black rectangle ?

Thank you,

Track Target position and distance in ImageTarget

December 18, 2014 - 10:00pm #5

I updated the KB article for additional clarity:

https://developer.vuforia.com/resources/dev-guide/textured-plane-target

 

Track Target position and distance in ImageTarget

December 18, 2014 - 2:42pm #4

You need to have the & in front of the trackable:

QCAR::Vec2F targetSize = ((QCAR::ImageTarget *) &trackable)->getSize();

You can reference the following forum post (also hyperlinked in my previous post) which offers the specific changes necessary for iOS:

https://developer.vuforia.com/forum/ios/okay-okay-dumb-down

Track Target position and distance in ImageTarget

December 18, 2014 - 5:27am #3

Thank you for reply, this guide is interested, but I have an error in:

QCAR::Vec2F targetSize = ((QCAR::ImageTarget *) trackable)->getSize();

it's:

ImageTargetsEAGLView.mm:462:43: Cannot cast from type 'const QCAR::Trackable' to pointer type 'QCAR::ImageTarget *'

I used this code to solve it:

QCAR::TrackerManager& trackerManager = QCAR::TrackerManager::getInstance();
QCAR::ImageTracker* imageTracker = static_cast<QCAR::ImageTracker*>(trackerManager.getTracker(QCAR::ImageTracker::getClassType()));

QCAR::TargetFinder* targetFinder = imageTracker->getTargetFinder();
int nbTargets = targetFinder->getNumImageTargets();
QCAR::ImageTarget * imageTarget;
                
for(int idx = 0; idx < nbTargets ; idx++)
    imageTarget = targetFinder->getImageTarget(idx);
But also I had an error ( EXC_BAD_ACCESS ) in:
 
QCAR::Vec2F targetSize = imageTarget->getSize();
 

That because targetFinder->getNumImageTargets() count is  0.

How can I solve that ?

 

 

Thank you,

Track Target position and distance in ImageTarget

December 17, 2014 - 9:06pm #2

This Dev Guide article might be what you are looking for:

https://developer.vuforia.com/resources/dev-guide/textured-plane-target

And here's a forum post with the iOS-specific changes.

For improving tracking, this FAQ offers some tips:

https://developer.vuforia.com/forum/faq/how-can-i-improve-detection-and-tracking-stability

 

Topic locked