I am writing a code that takes a webcam feed and tracks the person on it, I have then put a gif in place of the person, I now want to rotate the gif to match the direction of movement so that it looks like it is walking that way.
I have tried using rotate (), push and pop and translate and I just cannot get the gif to rotate.
var gif
var angle = 0
let video;
let poseNet;
let poses = [];
function modelReady() {
console.log("ready");
}
function preload (){
gif = createImg("ant gif.gif")
}
function setup() {
createCanvas(640, 480);
video = createCapture(VIDEO)
video.size(width, height);
video.hide();
imageMode (CENTER)
angleMode(DEGREES)
poseNet = ml5.poseNet(video, { maxPoseDetections: 8 } );
poseNet.on("pose", function (results) {
poses = results;
});
}
function draw() {
background(255)
if (poses[0]){
gif.position(width - poses[0].pose.nose.x, poses[0].pose.nose.y)
}
gif.size(100,100)
}
New contributor
jessie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1