Hi,
I recently have been learning the iOS side of the Vuforia SDK (I started with Android). I am trying to replicate an App I made on Android, and in this app I use the projectScreenPointToPlane function to translate a touch in 2D screen space to the 3D AR Target space. I then check the translation and determine if it is within a certain area on the target.
I have this functionality working perfectly on Android. I mirrored my implementation in my iOS project. However, when I print the translated values of my touch in iOS ( intersection.data[0] and intersection.data[1] ), the values are inconsistent.
For instance, if I positon my device to view the target straight on, I get a translated value A [ ie: (0.0, 0.0) ] when I touch the center of the target through my screen. But as I move the device, the translated coordinates are skewed. If I view the target with my device from a greater distance/different angle and touch the same point on the target through the screen, I receive a different translated value B [ ie: (50.0, -20.0) ]. The translation value becomes so skewed from different view points that it is impossible to run it through any sort of conditionals.
I didn't have this problem with Android, is there something I am missing here? I would really like to resolve this issue, as I am frustrated that what I thought I understood now suddenly doesn't work for iOS.
- Alex
PS: Here is the function from the code provided in the Video Playback sample. In my app, I simply changed the conditional statement to check for a smaller range than the entire target:
- (int)tapInsideTargetWithID
{
QCAR::Vec3F intersection, lineStart, lineEnd;
// Get the current projection matrix
QCAR::Matrix44F projectionMatrix = [vapp projectionMatrix];
QCAR::Matrix44F inverseProjMatrix = SampleMath::Matrix44FInverse(projectionMatrix);
CGRect rect = [self bounds];
int touchInTarget = -1;
// ----- Synchronise data access -----
[dataLock lock];
// The target returns as pose the centre of the trackable. Thus its
// dimensions go from -width / 2 to width / 2 and from -height / 2 to
// height / 2. The following if statement simply checks that the tap is
// within this range
for (int i = 0; i < NUM_TARGETS; ++i) {
SampleMath::projectScreenPointToPlane(inverseProjMatrix, videoData[i].modelViewMatrix, rect.size.width, rect.size.height,
QCAR::Vec2F(touchLocation_X, touchLocation_Y), QCAR::Vec3F(0, 0, 0), QCAR::Vec3F(0, 0, 1), intersection, lineStart, lineEnd);
// print out the translated values
NSLog(@"---->intersection[%i]: x: %f y: %f z:%f", i, intersection.data[0], intersection.data[1], intersection.data[2]);
if ((intersection.data[0] >= -videoData[i].targetPositiveDimensions.data[0]) && (intersection.data[0] <= videoData[i].targetPositiveDimensions.data[0]) &&
(intersection.data[1] >= -videoData[i].targetPositiveDimensions.data[1]) && (intersection.data[1] <= videoData[i].targetPositiveDimensions.data[1])) {
// The tap is only valid if it is inside an active target
if (YES == videoData[i].isActive) {
touchInTarget = i;
break;
}
}
}
projectScreenPointToPlane Issue
Have you checked this article ?
https://developer.vuforia.com/forum/faq/technical-how-can-i-project-target-point-screen
projectScreenPointToPlane Issue
Just checked it out....for what I am trying to do, isn't it better to convert the 2D touch -> 3D space and then check if an object was selected? What would be the benefit of doing it the way the article explained (3D space -> 2D touch)?
projectScreenPointToPlane Issue
What I am most confused about is why what I implemented for my Android app's 2D->3D conversion isn't able to also work o
projectScreenPointToPlane Issue
A few ideas:
1 - check your code against the Dominoes sample and see which coordinates get printed out.
2 - check the orientation code as it could be that portrait and landscape might be getting mixed up
projectScreenPointToPlane Issue
Hello here at Prisma we have same problem our implementation of the tap converted to the target scene works very fine on Android but on IOS values are always scketcy and quite inconsistent.