Help with Pan/Tilt Face tracker code


#1

Hello,

I am creating a Pan/Tilt face tracker with the Pimoroni pan/tilt hat based off https://learn.pimoroni.com/tutorial/electromechanical/building-a-pan-tilt-face-tracker

I have got the tracker program working, however, the camera tilts up to max a few seconds after starting. I have tried changing the default position for the camera but it seems to make no difference. Is there another line I should try changing to have the camera not tilt at the start?
# Default Pan/Tilt for the camera in degrees.
# Camera range is from -90 to 90
cam_pan = 90
cam_tilt = 0 (default is 60)

Full Code Link:


#2

The cam_tilt value is in degrees of the total range of camera movement, so a value of 0 would be (I think) fully tilted upwards, and a value of 180 would be fully tilted downwards.

You’ll need to start with 90 and add/subtract as necessary.

Looking back over my code it looks like I’ve confused things by saying:

# Default Pan/Tilt for the camera in degrees.
# Camera range is from -90 to 90
cam_pan = 90
cam_tilt = 60

And then doing this:

# Turn the camera to the default position
pan(cam_pan-90)
tilt(cam_tilt-90)

So that a cam_tilt value of 0 would result in -90 being sent to the PanTilt HAT.