About Opencv detect the action to change the animation
in
Contributed Library Questions
•
2 years ago
Hey, all:
Did anyone made the video by Opencv in p5?
I want to make the test that it detect and control the your action by the face or hand's project with opencv.
This is the demo code,I don't know How can do it?
Process for animation.
First, when run this programme, there is a animation in the screen.
And then, the camera can detect your movement when you shake by your hand's or face.
Then, the ball will come out by your hand's or face's action in the screen.
The ball can automatic to move and rebound when it touch around.
At last, when the ball random to hit the animation, the animation to be changed to the other animation.
Thx.
Code:
//Define a variable of position
float x=30;
float xpos,ypos;
float xspeed= 3.0;
float yspeed= 2.0;
float xdirection= 1;
float ydirection= 1;
float radius= 15.0;
import processing.video.*;
Movie myMovie;
Movie myMovie1;
Movie myMovie2;
Movie myMovie3;
void setup() {
size(640, 480, P2D);
background(0);
smooth();
noStroke();
// Load and play the video in a loop
myMovie = new Movie(this, "2d.avi");//Load this video
myMovie.loop();//Makes draw() run loop
myMovie1 = new Movie(this, "Murdoc.avi");
myMovie1.loop();
myMovie2 = new Movie(this, "Noodle.avi");
myMovie2.loop();
myMovie3 = new Movie(this, "Russel.avi");
myMovie3.loop();
}
void movieEvent(Movie myMovie) {
myMovie.read();
}
void draw() {
fill(0,12);
rect(random(xpos),random(ypos),width,height);
fill(0,0,255,50);
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
//x+=speed;
if (xpos < 0 || xpos > width) {
xdirection*=-1 ;
}
if (ypos < 0 || ypos > height) {
ydirection*=-1 ;
}
ellipse(xpos+x/4,ypos+x/4,x,x);
// tint(255, 20);
// image(myMovie, myMovie.width/2, myMovie.height/2);
//////// Displays the image at point (100, 0) at half of its size
image(myMovie, 0, 0,width/6,height/6);
image(myMovie1,130, 0,width/6,height/6);
image(myMovie2,260, 0,width/6,height/6);
image(myMovie3,390, 0,width/6,height/6);
}
Did anyone made the video by Opencv in p5?
I want to make the test that it detect and control the your action by the face or hand's project with opencv.
This is the demo code,I don't know How can do it?
Process for animation.
First, when run this programme, there is a animation in the screen.
And then, the camera can detect your movement when you shake by your hand's or face.
Then, the ball will come out by your hand's or face's action in the screen.
The ball can automatic to move and rebound when it touch around.
At last, when the ball random to hit the animation, the animation to be changed to the other animation.
Thx.
Code:
//Define a variable of position
float x=30;
float xpos,ypos;
float xspeed= 3.0;
float yspeed= 2.0;
float xdirection= 1;
float ydirection= 1;
float radius= 15.0;
import processing.video.*;
Movie myMovie;
Movie myMovie1;
Movie myMovie2;
Movie myMovie3;
void setup() {
size(640, 480, P2D);
background(0);
smooth();
noStroke();
// Load and play the video in a loop
myMovie = new Movie(this, "2d.avi");//Load this video
myMovie.loop();//Makes draw() run loop
myMovie1 = new Movie(this, "Murdoc.avi");
myMovie1.loop();
myMovie2 = new Movie(this, "Noodle.avi");
myMovie2.loop();
myMovie3 = new Movie(this, "Russel.avi");
myMovie3.loop();
}
void movieEvent(Movie myMovie) {
myMovie.read();
}
void draw() {
fill(0,12);
rect(random(xpos),random(ypos),width,height);
fill(0,0,255,50);
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
//x+=speed;
if (xpos < 0 || xpos > width) {
xdirection*=-1 ;
}
if (ypos < 0 || ypos > height) {
ydirection*=-1 ;
}
ellipse(xpos+x/4,ypos+x/4,x,x);
// tint(255, 20);
// image(myMovie, myMovie.width/2, myMovie.height/2);
//////// Displays the image at point (100, 0) at half of its size
image(myMovie, 0, 0,width/6,height/6);
image(myMovie1,130, 0,width/6,height/6);
image(myMovie2,260, 0,width/6,height/6);
image(myMovie3,390, 0,width/6,height/6);
}
1