In my program I create ellipse that is on top of an image taken from the camera. This ellipse starts at the middle of the screen immediately when the program starts. I am trying to change the ellipse’s position as the device moves to match the spot on the image where it originally was. For eg. if the ellipse started on a TV that was in your image from the camera then the ellipse will move up if the image of the TV moves up. That way, no matter what camera angle is present, the ellipse will be on the TV or wherever the ellipse started. However, I cannot get the tracking right. Any ideas? Here is my code:
-- Position tracking
-- Use this function to perform your initial setup
-- This function gets called once every frame
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
capturedImage = image(CAMERA)
-- Get the size of the current camera texture
local camWidth, camHeight = spriteSize( CAMERA )
-- Draw the special CAMERA sprite
sprite( CAMERA, WIDTH/2, HEIGHT/2, math.min( camWidth, WIDTH ) )
-- Do your drawing here
posx = posx + RotationRate.y*28
posy = posy -RotationRate.x*43
This isn’t exactly what I am trying to do. Let me try to better explain. I want to look at something and make a dot. Then I want to look away and look back and have that dot still there. Basically it should look as if that dot was actually sitting wherever my camera was pointed. Similar to if your scope shot and made a hole in the image displayed and if the hole stayed on that exact location so if you made a hole on a couch and move your camera right the hole would still be on the couch.
If you are talking about putting a dot over a specific object in a live scene (ie the camera picture is contunally changing as you move the iPad), that is difficult.
If you are talking about putting a dot on a still picture, and the still picture moves around, then it is pretty easy to keep the dot in the same relative place, just follow the movements of the picture.