Log in or register to post comments

Get coordinates to overlay image

December 7, 2011 - 1:32am #1

Hi,

I m trying to overlay image on frame marker but the image does not overlay properly and it is also not zoom-in or zoom-out when camera comes closer to marker or away from marker.

I used below post to get the coordinates
https://ar.qualcomm.at/arforums/showpost.php?p=3538&postcount=8

using this post i get x,y,width and height as below:
CGFloat x = ShaderUtils::minVal(s0.x,s1.x,s2.x,s3.x);
CGFloat y = ShaderUtils::minVal(s0.y,s1.y,s2.y,s3.y);
CGFloat width = ShaderUtils::maxVal(s0.x,s1.x,s2.x,s3.x) - x;
CGFloat height = ShaderUtils::maxVal(s0.y,s1.y,s2.y,s3.y) - y;

After this, I set this coordinates to imageview frame as below:
CGRect sBounds = CGRectMake(x, y, width, height);
myImageView.frame = sBounds;

But the view does not fit into marker's view and also it does not update x and y based on current coordinates once i move camera away from marker.

Please someone can point me what i m doing wrong?

Thanks,
Hardik

Get coordinates to overlay image

February 26, 2018 - 3:05am #19

Can anyone guide me how to get coordinates to overlay image for the latest library? I am trying to get x, y, width and height to place image over the image target.

Get coordinates to overlay image

June 28, 2013 - 3:02am #18

Glad I could help :)

N

Get coordinates to overlay image

June 27, 2013 - 8:58pm #17

Hey thanks a lot.. By changing the scale of coordinates i am able to change the size of overlayed texture .

Get coordinates to overlay image

June 27, 2013 - 4:36am #16

Have you tried changing the scale of the coordinates from 0.5 to something bigger?

 

N

Get coordinates to overlay image

June 27, 2013 - 2:02am #15

Thanks a lot for your reply. Now i am able to overlay any png image over the detected target.

 I am able to change the x and y cooridinates of the texture which is being overlayed .

Wanted to know whether can i change the size of the overlayed texture?

Get coordinates to overlay image

June 26, 2013 - 4:55am #14

Like I said, it's probably worth searching the forums, as it is amazing what you can find...

Although this link is for Android, you may be able to apply it in iOS:

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

 

N

Get coordinates to overlay image

June 26, 2013 - 4:42am #13

Thanks for the reply. Actually i am able to overlay a 3d or 2d shape using open gl on the target image. To overlay any png image over image target do we need to use opengl ?

Could please help me out by providing any code snippet...

Get coordinates to overlay image

June 26, 2013 - 4:34am #12

I do not see any reason why not.

Maybe the easiest way would be to overlay a plane containing the texture, as this way you will also get a 3d appearance to it.

Depends what you want.

You may find this thread useful  https://developer.vuforia.com/forum/qcar-api/get-coordinates-ar

...and its also worth searching the forums.

 

N

Get coordinates to overlay image

June 26, 2013 - 3:51am #11

Hi,

 

Can we overlay a png or jpg image when the target image is detected in ios ?

Re: Get coordinates to overlay image

June 4, 2012 - 6:49am #10

Hi All (MoSR),

I'm working with the frame markers example app at the moment, also trying to super impose just a 2d image over the frame marker(s). I have it working perfectly in landscape orientation right; so thanks for all that sample code to get me started - would have taken me quite some time (3D / GL isn't really my thing).

However now I'm having difficulty with other orientations. I've tried applying the setRotationMatrix, and rotatePoseMatrix methods (from ShaderUtils.cpp) to the modelViewMatrix, & modelViewProjection matrix prior to my calcScreenCoordsOf call (from the sample code posted in this forum); however this seems to have no effect for me. I've also tried working directly in my UIView overlay with affine transforms; also no luck.

MoSR, I noticed in one of your other posts you mentioned you'd update the code with orientation translation.. Would be fantastic if you could do so, or even just give me a couple of pointers.
Cheers,

Reece.

Re: Get coordinates to overlay image

December 21, 2011 - 9:42am #9

Thanks Kim. Really helpfull!

Re: Get coordinates to overlay image

December 21, 2011 - 5:43am #8

You can now access the camera calibration like this (note you no longer need the Tracker):

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

Be sure to add the following imports:

#import <QCAR/CameraDevice.h>
#import <QCAR/VideoMode.h>

- Kim

Re: Get coordinates to overlay image

December 21, 2011 - 4:52am #7

Hi everyone.

I'm trying to get the tip of MoSR work in the version of QCAR that I'm using, wich is 1.5.3 beta1.

Maybe someone can help me and update the technique to the last version.

Some things I solved, like the projectionMatrix, wich in the new version is in the qUtils.

But I can't find the:
QCAR::Tracker
QCAR::CameraDevice
QCAR::VideoMode

Thank you for the help!

Re: Get coordinates to overlay image

December 13, 2011 - 5:26am #6

Take a look at the first post in the thread - it references some sample code that uses the following to return a CGPoint value:
- (CGPoint) projectCoord:(CGPoint)coord inView:(const QCAR::CameraCalibration&)cameraCalibration andPose:(QCAR::Matrix34F)pose withOffset:(CGPoint)offset
I believe that hardik has written the minVal and maxVal himself - you do have to do some work yourself even if we've made the AR bit easier! :-)

Re: Get coordinates to overlay image

December 13, 2011 - 5:02am #5

Hi,
How do you manage to get x,y values ??
CGFloat x=ShaderUtils::minVal(s0.x,s1.x,s2.x,s3,x)

Above line is not working for me- No member minVal for ShaderUtils.
Any pointers on this ?

Thanks in advance

Re: Get coordinates to overlay image

December 8, 2011 - 5:41am #4

Here's what I did to prove that this works, combined with the suggestion in the original post:

If you followed the original post, you should already have GGPoints s0..3 declared in the EAGLView.

Modify the appDelegate 'didFinishLaunchingWithOptions' as follows:

    viewController = [[ARViewController alloc] init];
	
    parentV = [[UIView alloc] initWithFrame: screenBounds];
    parentV.backgroundColor = [UIColor greenColor];
	
    screenBounds = CGRectMake(0, 0, parentV.frame.size.height, parentV.frame.size.width);
    view = [[EAGLView alloc] initWithFrame: screenBounds];
	
    [parentV addSubview:view];
    
    CGRect frame = {0,0,10,10};
    s0V = [[UIView alloc] initWithFrame:frame];
    s1V = [[UIView alloc] initWithFrame:frame];
    s2V = [[UIView alloc] initWithFrame:frame];
    s3V = [[UIView alloc] initWithFrame:frame];
    s0V.backgroundColor = [UIColor redColor];
    s1V.backgroundColor = [UIColor greenColor];
    s2V.backgroundColor = [UIColor blueColor];
    s3V.backgroundColor = [UIColor yellowColor];
    [parentV addSubview:s0V];
    [parentV addSubview:s1V];
    [parentV addSubview:s2V];
    [parentV addSubview:s3V];

    [viewController setView:parentV];
    
    [window addSubview: viewController.view];

   [NSTimer scheduledTimerWithTimeInterval:0.04 target:self selector:@selector(moveCorners:) userInfo:NULL repeats:YES];

And the timer callback method:

- (void)moveCorners:(NSTimer*)theTimer
{
    CGRect frame = CGRectMake(view.s0.x, view.s0.y, 10, 10);
    s0V.frame = frame;
    frame = CGRectMake(view.s1.x, view.s1.y, 10, 10);
    s1V.frame = frame;
    frame = CGRectMake(view.s2.x, view.s2.y, 10, 10);
    s2V.frame = frame;
    frame = CGRectMake(view.s3.x, view.s3.y, 10, 10);
    s3V.frame = frame;
}

That should place a small coloured square on each of the target corners. Once you've proven that works in your implementation you can proceed with adapting it to your solution.

Re: Get coordinates to overlay image

December 8, 2011 - 3:55am #3

Hi, I have the same problem, my x an y coordinate doesn't update for my UIImageView, how I can overlay image on the Image pattern?
Please help there is 2 weeks that I try to add UIImageView with image sequence animation to the scene, the UIImageView appears but not in the good place and not using Matrix tranformation.
Thanks in advance,
Maher.

Re: Get coordinates to overlay image

December 7, 2011 - 2:37am #2

I would suggest drawing a tiny view (3pixels?) at each of s0..s3 in red to compare with your intended overlaid view, to help you diagnose the problem.

Log in or register to post comments