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
function setup()
print("Hello World!")
posx,posy=WIDTH/2,HEIGHT/2
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
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
ellipse(posx,posy,50)
end