mac online apple blackjack http://www.euro-online.org

First Experiment with Arduino

unnamed (6)

I’ve borrowed an Arduino kit from the technicians in Culture Lab, and have started my practice with some exercises. In this blog I will talk about my first experiment with it. It was a totally new thing to do, but I really enjoyed it because it is always good to gain a new skill that can break a lot of limits and boundaries and therefore it would enable me to expand my art practices to a wider prospect.

The Arduino Starter Kit contains all items you need to start practicing Arduino projects. It has an Arduino UNO board, a beard board which gives you extra space to make your connections,  electric components such as resistors, wires LED lights, LCD screen and the Arduino projects book.

The book is a very good point to start, it is well designed and it uses a simple and direct method to deliver the basics of everything related to this micro-controller starting from making electric circuits, to programming with some examples of some simple projects to start with.

I have started with building an electric circuit, by connecting an LED light to the power through a resistor and it is connected to a switch from the other side.

This Image demonstrates the connection of this basic circuit. when I press the button the light works and it stops when I remove my finger.

After doing this simple exercise, I have started reading about programming through the Adruino software.

and that’s what I came up to with the help of the book, please see this: Video .

In order to make this “spaceship interface!” I have used the following sketch:

New experiments will be uploaded soon.

 

the processing study result2

观世音菩萨7

i will continue show my study outcome from this half a month investigation.

 

ball [] collection= new ball [10];

void setup() {
size(600, 600);
smooth();
for(int i=0;i<10;i++){
collection[i]= new ball(random(0,width),random(0,600));}

}

void draw() {
background(0);
for(int i=0;i<10;i++){
collection[i].ball();
}
}

class ball{
// variable
float x;
float y;//more excercise
float speedx=5;
float speedy=2.5;
//constructor
ball(float _x,float _y){x=_x;y=_y; }//more also you know

//functionality
void ball(){
display();
move();
bounce();
gravity();}
void display(){
ellipse(x,y,30,30);}
void move(){x+=speedx;
y+=speedy;}
void bounce(){
if(x>width){speedx=speedx*-1;}
if(x<0){speedx=speedx*-1;}
if(y>height){speedy=speedy*-1;}
if(y<0){speedy=speedy*-1;}
}
void gravity(){speedy+=0.05;}
}

.

and also the pixel and images i have learned.

PImage img;

void setup() {
size(200, 200);
img = loadImage(“cat.jpg”);
}

void draw() {
loadPixels();
// Since we are going to access the image’s pixels too
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;

// The functions red(), green(), and blue() pull out the 3 color components from a pixel.
float r = hue(img.pixels[loc]);
float g = saturation(img.pixels[loc]);
float b = brightness(img.pixels[loc]);

// Image Processing would go here
// If we were to change the RGB values, we would do it here, before setting the pixel in the display window.

// Set the display pixel to the image pixel
pixels[loc] = color(r,g,b);
}
}
updatePixels();
}

PImage img;

void setup() {
size(200, 200);
img = loadImage(“cat.jpg”);
}

void draw() {
loadPixels();
// Since we are going to access the image’s pixels too
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;

// The functions red(), green(), and blue() pull out the 3 color components from a pixel.
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.pixels[loc]);

float adjustBrightness = ((float) mouseX / width) * 8.0;
r *= adjustBrightness;
g *= adjustBrightness;
b *= adjustBrightness;
// Constrain RGB to between 0-255
r = constrain(r,0,255);
g = constrain(g,0,255);
b = constrain(b,0,255);
// Make a new color and set pixel in the window
color c = color(r,g,b);
pixels[loc] = c;

// Image Processing would go here
// If we were to change the RGB values, we would do it here, before setting the pixel in the display window.

// Set the display pixel to the image pixel

}
}
updatePixels();
}

PImage img;

void setup() {
size(200, 200);
img = loadImage(“cat.jpg”);
}

void draw() {
loadPixels();
// Since we are going to access the image’s pixels too
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;

// The functions red(), green(), and blue() pull out the 3 color components from a pixel.
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.pixels[loc]);
float distance= dist(x,y,mouseX,mouseY);
float adjustBrightness = (50-distance)/50;
r *= adjustBrightness;
g *= adjustBrightness;
b *= adjustBrightness;
// Constrain RGB to between 0-255
r = constrain(r,0,255);
g = constrain(g,0,255);
b = constrain(b,0,255);
// Make a new color and set pixel in the window
color c = color(r,g,b);
pixels[loc] = c;

// Image Processing would go here
// If we were to change the RGB values, we would do it here, before setting the pixel in the display window.

// Set the display pixel to the image pixel

}
}
updatePixels();
}

 

codes:

PImage source; // Source image
PImage destination; // Destination image

void setup() {
size(200, 200);
source = loadImage(“blackcat.jpg”);
// The destination image is created as a blank image the same size as the source.
destination = createImage(source.width, source.height, RGB);
}

void draw() {
float threshold = 175;

// We are going to look at both image’s pixels
source.loadPixels();
destination.loadPixels();

for (int x = 0; x < source.width; x++) {
for (int y = 0; y < source.height; y++ ) {
int loc = x + y*source.width;
// Test the brightness against the threshold
if (brightness(source.pixels[loc]) > threshold) {
destination.pixels[loc] = color(255); // White
} else {
destination.pixels[loc] = color(0); // Black
}
}
}

// We changed the pixels in destination
destination.updatePixels();
// Display the destination
image(destination,0,0);
}

 

the processing study results 1.

楞严咒

this half of month i have learn those following tutorials in processing.

 

the math and the shapes.

in the 12th tutorial, i have learn basic mathematics.

there are codes:

import toxi.geom.*;

Vec3D vec1= new Vec3D(-100,100,0);
Vec3D vec2=new Vec3D(100,-40,0);

void setup(){
background(0);
size(500,500);
}

void draw(){
background(0);
translate(250,250);
stroke(#D3B1B1);
strokeWeight(1);
line(-500,0,500,0);
line(0,-500,0,500);

stroke(0,0,255);
strokeWeight(6);
point(vec1.x,vec1.y);
strokeWeight(1);
line(0,0,vec1.x,vec1.y);

stroke(0,255,0);
strokeWeight(6);
point(vec2.x,vec2.y);
strokeWeight(1);
line(0,0,vec2.x,vec2.y);

Vec3D a = vec1.copy();
a.normalize();
a.scaleSelf(50);
stroke(255,0,0);
strokeWeight(2);
line(0,0,a.x,a.y);

Vec3D b=vec1.add(vec2);
stroke(#F7FF17);
strokeWeight(2);
line(0,0,b.x,b.y);

stroke(#E717FF);
strokeWeight(2);
line(vec2.x,vec2.y,b.x,b.y);

Vec3D c= vec1.sub(vec2);
stroke(#17FFEA);
strokeWeight(2);
line(0,0,c.x,c.y);}

and also the bouncing balls, different motion model. which i prepare use them into my exhibition of artwork and audience module.

import toxi.geom.*;

ArrayList ballcollection;

void setup(){
size(600,600);
smooth();

ballcollection = new ArrayList();

for(int i=0;i<100;i++){
Vec3D origin= new Vec3D(random(0,width),random(0,height),0);
ball myball= new ball(origin);
ballcollection.add(myball);
}
}

void draw(){
background(0);

for(int i=0;i<ballcollection.size();i++){
ball mb=(ball) ballcollection.get(i);
mb.run();
}
}

 

another codes i have wrote in processing… different kinds of bouncing balls:

 

ArrayList ballcollection;

void setup() {
size(600, 600);
smooth();
ballcollection= new ArrayList();

for (int i=0; i<100; i++) {
ball myball= new ball(random(0, width), random(0, height));
ballcollection.add(myball);
}
}

void draw() {
background(0);
for (int i=0; i<100; i++) {
ball myball=(ball) ballcollection.get(i);
myball.ball();

}
}

there is another tab:

class ball{
// variable
float x;
float y;//more excercise
float speedx=5;
float speedy=2.5;
//constructor
ball(float _x,float _y){x=_x;y=_y; }//more also you know

//functionality
void ball(){
display();
move();
bounce();
gravity();}
void display(){
ellipse(x,y,30,30);}
void move(){x+=speedx;
y+=speedy;}
void bounce(){
if(x>width){speedx=speedx*-1;}
if(x<0){speedx=speedx*-1;}
if(y>height){speedy=speedy*-1;}
if(y<0){speedy=speedy*-1;}
}
void gravity(){speedy+=0.05;}
}

and…

import toxi.geom.*;

ArrayList ballcollection;

void setup(){
size(600,600);
smooth();

ballcollection = new ArrayList();

for(int i=0;i<100;i++){
Vec3D origin= new Vec3D(random(0,width),random(0,height),0);
ball myball= new ball(origin);
ballcollection.add(myball);
}
}

void draw(){
background(0);

for(int i=0;i<ballcollection.size();i++){
ball mb=(ball) ballcollection.get(i);
mb.run();
}
}

class ball {
Vec3D loc= new Vec3D(0, 0, 0);
Vec3D speed= new Vec3D(random(-2.2), random(-2, 2), 0);
Vec3D acc=new Vec3D();
Vec3D grav=new Vec3D(0, 0.2, 0);

ball(Vec3D _loc) {
loc=_loc;
}

void run() {
display();
move();
bounce();
//linebetween();
flock();
//gravity();
}

void flock(){
separate(4);

}

void separate(float magnitude){
Vec3D steer=new Vec3D();
int count=0;
for (int i=0; i< ballcollection.size (); i++) {
ball other=(ball) ballcollection.get(i);
float lon= loc.distanceTo(other.loc);
if (lon>0 && lon<20) {

Vec3D diff=loc.sub(other.loc);
diff.normalizeTo(1.0/lon);
steer.addSelf(diff);
count++;
}}
if (count>0){
steer.scaleSelf(1.0/count);}
steer.scaleSelf(magnitude);

acc.addSelf(steer);}

void linebetween() {
for (int i=0; i< ballcollection.size (); i++) {
ball other=(ball) ballcollection.get(i);
float lon= loc.distanceTo(other.loc);
if (lon>0 && lon<40) {

stroke(#DEA6A6);

line(loc.x, loc.y, other.loc.x, other.loc.y);
}}}

void display() {
ellipse(loc.x, loc.y, 20, 20);
}

void move() {
speed.addSelf(acc);
speed.limit(0.5);
loc.addSelf(speed);
acc.clear();
}

void gravity() {
speed.addSelf(grav);
}

void bounce() {
if (loc.x>width) {
speed.x=speed.x*-1;
}
if (loc.x<0) {
speed.x=speed.x*-1;
}
if (loc.y>height) {
speed.y=speed.y*-1;
}
if (loc.y<0) {
speed.y=speed.y*-1;
}
}

}

 

ArrayList ballcollection;

void setup() {
size(600, 600);
smooth();
ballcollection= new ArrayList();

}

void draw() {
background(0);

ball myball= new ball(random(0, width), random(0, height));
ballcollection.add(myball);
for (int i=0; i<ballcollection.size(); i++) {
ball myballdynamic=(ball) ballcollection.get(i);
myballdynamic.ball();

}
}

class ball{
// variable
float x;
float y;//more excercise
float speedx=5;
float speedy=2.5;
//constructor
ball(float _x,float _y){x=_x;y=_y; }//more also you know

//functionality
void ball(){
display();
move();
bounce();
gravity();}
void display(){
ellipse(x,y,30,30);}
void move(){x+=speedx;
y+=speedy;}
void bounce(){
if(x>width){speedx=speedx*-1;}
if(x<0){speedx=speedx*-1;}
if(y>height){speedy=speedy*-1;}
if(y<0){speedy=speedy*-1;}
}
void gravity(){speedy+=0.05;}
}

codes:

ArrayList ballcollection;

 

float rotation = 0.0;

public void setup() {
size(600, 600);

smooth();
ballcollection= new ArrayList();

}

void draw() {
background(0);

ball myball= new ball(300, 300);
ballcollection.add(myball);
for (int i=0; i<ballcollection.size(); i++) {
ball myballdynamic=(ball) ballcollection.get(i);
myballdynamic.ball();

}
}

class ball{
// variable
float x;
float y;//more excercise
float speedx=random(-2,2);
float speedy=random(-2,2);
//constructor
ball(float _x,float _y){x=_x;y=_y;}//more also you know

//functionality
void ball(){
display();
move();
bounce();
gravity();}
void display(){
ellipse(x,y,30,30);}
void move(){x+=speedx;
y+=speedy;}
void bounce(){
if(x>width){speedx=speedx*-1;}
if(x<0){speedx=speedx*-1;}
if(y>height){speedy=speedy*-1;}
if(y<0){speedy=speedy*-1;}
}
void gravity(){speedy+=1;}
}

explore faceOSC and processing connection

阿弥陀佛1314

In my project where will require the data manipulation in processing, and then export data to arduino to achieve interact with people. and it involves another useful tool: faceosc. today i research from internet about the faceOSC and processing.

/* jason stephens
Computational Cameras
FaceOSC -> Controls Generative System
(aka: Control Noise With Mouth)

Facetracking through:
Kyle McDonald’s FaceOSC https://github.com/kylemcdonald/ofxFaceTracker

Adapted from from Greg Borenstein’s 2011 example

https://gist.github.com/1603230

Objective:
Demonstrate FaceOSC with a series of generative sketches with face controlled parameters.

Method:
Create a baseline series of animations increasing in complexity between keyPress 1-6.
Add perlin noise to each
Add faceControl to replace perlin noise

TODO:
DONE____print directions
DONE____add 6 spiral
____add toggle for faceControl to function
____add faceControl fucntionality

____add toggle for perlin noise for each
DONE____add toggle for lines
DONE____push ’1′ creates sin movement on X axis
DONE____push ’2′ creates cos movement on Y axis (osicllate up/down)
DONE____push ’3′ creates circle from circulating dots
____add center location based on center of face
____blink changes rotation direction
____mouth width changes X amplitude
____mouth heigh changes Y amplitude
____eyes change center circle

NOTES:
locationX = amplitude * cos (angle); // where cos(angle) = 0-1
locationY = amplitude * sin (angle); // where sin(angle) = 0-1
*/

//faceControl variables
import oscP5.*;
OscP5 oscP5;

PVector posePosition = new PVector();
boolean found;
float eyeLeftHeight;
float eyeRightHeight;
float mouthHeight;
float mouthWidth;
float nostrilHeight;
float leftEyebrowHeight;
float rightEyebrowHeight;
float poseOrientationX;
float poseOrientationY;
float poseOrientationZ;
float poseScale;

float mouthArea; // equals (mouthHeight * mouthWidth);
PImage myImg;

//drawingCircles
PVector amplitude;
PVector location;
PVector angularVelocity;
PVector centerCircle;

float centerX;
float centerY;
float radius = 100;
float moveX;

float angle = 0;
float aVelocity = .05;
float amplitudeX = 200;
float amplitudeY = 200;
float theta = 0;
float spiralTheta = 0;
float spiralSize =1;
float spiralAcceleration = .01;
float pX=0;
float pY=0;

int lastKey = 0;
boolean showLines = false;
boolean mouseVelocity = false;
boolean mouseYspiralAcceleration = false;
boolean faceControl = false;

void setup () {
size (750, 750);
smooth ();
background(255);
strokeWeight (5);
centerX = width/2;
centerY = height/2;

oscP5 = new OscP5(this, 8338);
oscP5.plug(this, “mouthWidthReceived”, “/gesture/mouth/width”);
oscP5.plug(this, “mouthHeightReceived”, “/gesture/mouth/height”);
oscP5.plug(this, “eyebrowLeftReceived”, “/gesture/eyebrow/left”);
oscP5.plug(this, “eyebrowRightReceived”, “/gesture/eyebrow/right”);
oscP5.plug(this, “eyeLeftReceived”, “/gesture/eye/left”);
oscP5.plug(this, “eyeRightReceived”, “/gesture/eye/right”);
oscP5.plug(this, “jawReceived”, “/gesture/jaw”);
oscP5.plug(this, “nostrilsReceived”, “/gesture/nostrils”);
oscP5.plug(this, “found”, “/found”);
oscP5.plug(this, “poseOrientation”, “/pose/orientation”);
oscP5.plug(this, “posePosition”, “/pose/position”);
oscP5.plug(this, “poseScale”, “/pose/scale”);
//myImg = loadImage(“sup.png”);
imageMode(CENTER) ;

printDirections();
}

void draw () {

semiTransparent();

//returns the velocity (either mouseControlled or hardCoded depending on ‘v’ keyPress
float varVelocity = calcVelocity(aVelocity); //calculate the variable velocity. take angular velocity as argument

// Create the PVectors for motion and prepare them for following calcultion function
PVector angularVelocity = new PVector (angle, varVelocity); //stores initial angle and the deltaAngle
PVector amplitude = new PVector (amplitudeX, amplitudeY); //stores the maxX maxY (aka radius)

//set location and centerCircle PVectors w/o faceControl

//this PVector holds the return value of the calculation function, which sends radius and velocity info to calc
PVector location = calculateCircle(angularVelocity, amplitude);
//figure out where the translation of the entire circle
PVector centerCircle = calculateCenter(centerX, centerY);

if (lastKey == 1) {
drawOscillatingX(location, centerCircle);
}
if (lastKey == 2) {
drawOscillatingY(location, centerCircle);
}
if (lastKey == 3) {
drawCircle(location, centerCircle); //send the location PVector (containing both X and Y coordinates
}
if (lastKey == 4) {
drawCircleDual(location, centerCircle); // this time add noise
}
if (lastKey == 5) {
drawCircleQuad(location, centerCircle); // this time add noise
}
if (lastKey == 6) {
drawSpiral(location, centerCircle); // this time add noise
}
if (lastKey == 7) {
drawFaceControlSpirals(location, centerCircle);
}
}
//Start the Machine
void printDirections() {
println(“Controls: animation = 1-6 : showLines = SpaceBar : mouseX Velocity = ‘v’ : mouseY Sprial = ‘s’”);
println(“faceControl = ‘f’”);
}

void semiTransparent() {
rectMode(CORNER);
noStroke();
fill(255, 10);
rect(0, 0, width, height);
stroke(0);
noFill();
}

//calculate Variable velocity. take Angular Velocity as an argument
float calcVelocity(float aVelocity) {
float velocity = aVelocity;
//if boolean for mouse controlled velocity is false, then return the standard velocity
if (mouseVelocity == false) {
}
//if boolean for mouse control is true, then set velocity
if (mouseVelocity == true) {
velocity = map(mouseX, 0, width, -1, 1);
}
return velocity;
}

// This function takes 4 argumments and returns 1 PVector
PVector calculateCircle (PVector angularVelocity, PVector amplitude) {
float x = amplitude.x * cos (theta);
float y = amplitude.y * sin (theta);
location = new PVector (x, y);
theta = theta + angularVelocity.y; //
return location;
}

// this function returns calculates where the circle is (translates) and returns as PVector
PVector calculateCenter(float centerX, float centerY) {
PVector centerCircle = new PVector (centerX, centerY);
return centerCircle;
}

// Do ’1′: draw the osicallating X
void drawOscillatingX (PVector location, PVector centerCircle) {
if (faceControl == false) {
translate (centerCircle.x, centerCircle.y);
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
point (0, 0);
point (location.x, 0);
}
//_____________________________________________________________
if (faceControl == true) {
//map the small ofFaceTracker screen (640×480) to the width and size of this screen
float mouthScalar = map(mouthWidth, 10, 18, 0, 1.5); // make a scalar for location.x as a function of mouth
location.mult(mouthScalar);

float newPosX = map (posePosition.x, 0, 640, 0, width);
float newPosY = map(posePosition.y, 0, 480, 0, height);
translate(width – newPosX, newPosY-100);
scale(poseScale*.3);

//left EYE

float leftEyeMove = map(location.x, – amplitudeX, amplitudeX, -25, 33);
pushMatrix();
translate (leftEyeMove, 0);
//Left iris
fill(0, 0, 255);
noStroke();
ellipse(-100, 0, 50, 50);

//LeftPupil
fill(0);
stroke(1);
ellipse(-100, 0, 20, 20);
popMatrix();

float rightEyeMove = map(location.x, – amplitudeX, amplitudeX, -33, 25);
pushMatrix();
translate(rightEyeMove, 0);
//right EYE
//Right Iris
fill(0, 0, 255);
noStroke();
ellipse(100, 0, 50, 50);
//Right Pupil
fill(0);
stroke(1);
ellipse(100, 0, 20, 20);
popMatrix();

//turn off fill
noFill();
//get eye informatio and set scalar
float blinkAmountRight = map (eyeRightHeight, 2.5, 3.8, 0, 125);
float blinkAmountLeft = map (eyeLeftHeight, 2.5, 3.8, 0, 125);

// right eye size, blink and movement
ellipse (100, 0, amplitudeX *.6, blinkAmountRight); //scalar added to eyeHeight
if (eyeRightHeight < 3.1) {
fill(0);
ellipse (100, 0, amplitudeX *.6, blinkAmountRight*1.6); //scalar added to eyeHeight
noFill();
}

//left eye size, blink, and movement
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft);
if (eyeLeftHeight < 3.1) {
fill(0);
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft*1.6); //scalar added to eyeHeight
noFill();
}

// pesky point!
point (location.x, 0);
}
}

//Do ’2′: draw the oscillating Y
void drawOscillatingY (PVector location, PVector centerCircle) {
if (faceControl == false) {
translate (centerCircle.x, centerCircle.y); //use the PVector to determine the translate
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
//point (location.x*.1, location.y*.1);
point (0, 0);
point (0, location.y);
}

//_____________________________________________________________
if (faceControl == true) {
//create mouthScalar
float mouthScalar = map(mouthHeight, 1, 10, 0, 1.5); // make a scalar for location.x as a function of mouth
location.mult(mouthScalar);

//map the small ofFaceTracker screen (640×480) to the width and size of this screen
float newPosX = map (posePosition.x, 0, 640, 0, width);
float newPosY = map(posePosition.y, 0, 480, 0, height);
translate(width – newPosX, newPosY-100);
scale(poseScale*.3);

//left EYE

float leftEyeMove = map(location.y, – amplitudeY, amplitudeY, -10, 10);
pushMatrix();
translate (30, leftEyeMove);
//Left iris
fill(0, 0, 255);
noStroke();
ellipse(-100, 0, 50, 50);

//LeftPupil
fill(0);
stroke(1);
ellipse(-100, 0, 20, 20);
popMatrix();

float rightEyeMove = map(location.y, – amplitudeY, amplitudeY, -10, 10);
pushMatrix();
translate(-30, rightEyeMove);
//right EYE
//Right Iris
fill(0, 0, 255);
noStroke();
ellipse(100, 0, 50, 50);
//Right Pupil
fill(0);
stroke(1);
ellipse(100, 0, 20, 20);
popMatrix();

//turn off fill
noFill();
//get eye informatio and set scalar
float blinkAmountRight = map (eyeRightHeight, 2.5, 3.8, 0, 125);
float blinkAmountLeft = map (eyeLeftHeight, 2.5, 3.8, 0, 125);

// right eye size, blink and movement
ellipse (100, 0, amplitudeX *.6, blinkAmountRight); //scalar added to eyeHeight
if (eyeRightHeight < 3.1) {
fill(0);
ellipse (100, 0, amplitudeX *.6, blinkAmountRight*1.6); //scalar added to eyeHeight
noFill();
}

//left eye size, blink, and movement
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft);
if (eyeLeftHeight < 3.1) {
fill(0);
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft*1.6); //scalar added to eyeHeight
noFill();
}

// pesky point!
point (0, location.y);
}
}

//Do ’3′: draw the circle from points
void drawCircle (PVector location, PVector centerCircle) {
if (faceControl == false) {
translate (centerCircle.x, centerCircle.y);
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
point (0, 0);
point (location.x, location.y);
if (showLines) {
line(0, 0, location.x, location.y);
}
}
//_____________________________________________________________
if (faceControl == true) {
//create the scalar!
float mouthScalar = map(mouthHeight, 1, 10, 0, 1.5); // make a scalar for location.x as a function of mouth
location.mult(mouthScalar);

//map the small ofFaceTracker screen (640×480) to the width and size of this screen
float newPosX = map (posePosition.x, 0, 640, 0, width);
float newPosY = map(posePosition.y, 0, 480, 0, height);
translate(width – newPosX, newPosY-100);
scale(poseScale*.3);

//left EYE

float leftEyeMoveUD = map(location.y, – amplitudeY, amplitudeY, -10, 10);
float leftEyeMoveLR = map(location.x, – amplitudeX, amplitudeX, -10, 10);
pushMatrix();
translate (leftEyeMoveLR, leftEyeMoveUD);
//Left iris
fill(0, 0, 255);
noStroke();
ellipse(-100, 0, 50, 50);

//LeftPupil
fill(0);
stroke(1);
ellipse(-100, 0, 20, 20);
popMatrix();

float rightEyeMoveUD = map(location.y, – amplitudeY, amplitudeY, -10, 10);
float rightEyeMoveLR = map(location.x, – amplitudeX, amplitudeX, -10, 10);
pushMatrix();
translate(rightEyeMoveLR, rightEyeMoveUD);
//right EYE
//Right Iris
fill(0, 0, 255);
noStroke();
ellipse(100, 0, 50, 50);
//Right Pupil
fill(0);
stroke(1);
ellipse(100, 0, 20, 20);
popMatrix();

//turn off fill
noFill();
//get eye informatio and set scalar
float blinkAmountRight = map (eyeRightHeight, 2.5, 3.8, 0, 125);
float blinkAmountLeft = map (eyeLeftHeight, 2.5, 3.8, 0, 125);

// right eye size, blink and movement
ellipse (100, 0, amplitudeX *.6, blinkAmountRight); //scalar added to eyeHeight
if (eyeRightHeight < 3.1) {
fill(0);
ellipse (100, 0, amplitudeX *.6, blinkAmountRight*1.6); //scalar added to eyeHeight
noFill();
}

//left eye size, blink, and movement
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft);
if (eyeLeftHeight < 3.1) {
fill(0);
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft*1.6); //scalar added to eyeHeight
noFill();
}

// pesky point!
point (location.x, location.y);

if (showLines) {
point (location.x, location.y);
line(pX, pY, location.x, location.y);
}
float pX = location.x;
float pY = location.y;
}
}
//Do ’4′: draw the circle from points
void drawCircleDual (PVector location, PVector centerCircle) {
translate (centerCircle.x, centerCircle.y);
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
point (0, 0);
//line(0, 0, width-location.x, height-location.y);
float backWardsY = location.y*-1;
point (location.x, backWardsY);
point (location.x, location.y);
if (showLines) {
line(0, 0, location.x, location.y);
line (0, 0, location.x, backWardsY);
}
}

//Do ’5′: draw the circle from points
void drawCircleQuad (PVector location, PVector centerCircle) {
if (faceControl == false) {
translate (centerCircle.x, centerCircle.y);
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
point (0, 0);
//line(0, 0, width-location.x, height-location.y);
float backWardsY = location.y*-1;
float backWardsX = location.x*-1;
point (location.x, backWardsY);
point (location.x, location.y);
point (backWardsX, backWardsY);
point (backWardsX, location.y);
if (showLines) {
line(0, 0, location.x, location.y);
line (0, 0, location.x, backWardsY);
line (0, 0, backWardsX, backWardsY);
line (0, 0, backWardsX, location.y);
}
}
//_____________________________________________________________
if (faceControl == true) {
//create the scalar!
float mouthScalar = map(mouthHeight, 1, 10, 0, 1.5); // make a scalar for location.x as a function of mouth
location.mult(mouthScalar);

//map the small ofFaceTracker screen (640×480) to the width and size of this screen
float newPosX = map (posePosition.x, 0, 640, 0, width);
float newPosY = map(posePosition.y, 0, 480, 0, height);
translate(width – newPosX, newPosY-100);
scale(poseScale*.3);

//left EYE

float leftEyeMoveUD = map(location.y, – amplitudeY, amplitudeY, -10, 10);
float leftEyeMoveLR = map(location.x, – amplitudeX, amplitudeX, -10, 10);
pushMatrix();
translate (leftEyeMoveLR, leftEyeMoveUD);
//Left iris
fill(0, 0, 255);
noStroke();
ellipse(-100, 0, 50, 50);

//LeftPupil
fill(0);
stroke(1);
ellipse(-100, 0, 20, 20);
popMatrix();

float rightEyeMoveUD = map(location.y, – amplitudeY, amplitudeY, -10, 10);
float rightEyeMoveLR = map(location.x, – amplitudeX, amplitudeX, -10, 10);
pushMatrix();
translate(rightEyeMoveLR, rightEyeMoveUD);
//right EYE
//Right Iris
fill(0, 0, 255);
noStroke();
ellipse(100, 0, 50, 50);
//Right Pupil
fill(0);
stroke(1);
ellipse(100, 0, 20, 20);
popMatrix();

//turn off fill
noFill();
//get eye informatio and set scalar
float blinkAmountRight = map (eyeRightHeight, 2.5, 3.8, 0, 125);
float blinkAmountLeft = map (eyeLeftHeight, 2.5, 3.8, 0, 125);

// right eye size, blink and movement
ellipse (100, 0, amplitudeX *.6, blinkAmountRight); //scalar added to eyeHeight
if (eyeRightHeight < 2.5) {
fill(0);
ellipse (100, 0, amplitudeX *.6, blinkAmountRight*1.6); //scalar added to eyeHeight
noFill();
}

//left eye size, blink, and movement
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft);
if (eyeLeftHeight < 2.5) {
fill(0);
ellipse (-100, 0, amplitudeX *.6, blinkAmountLeft*1.6); //scalar added to eyeHeight
noFill();
}

//line(0, 0, width-location.x, height-location.y);
float backWardsY = location.y*-1;
float backWardsX = location.x*-1;
point (location.x, backWardsY);
point (location.x, location.y);
point (backWardsX, backWardsY);
point (backWardsX, location.y);
if (showLines) {
line(0, 0, location.x, location.y);
line (0, 0, location.x, backWardsY);
line (0, 0, backWardsX, backWardsY);
line (0, 0, backWardsX, location.y);
}
}
}
//Do ’6′: draw the circle from points
void drawSpiral (PVector location, PVector centerCircle) {
translate (centerCircle.x, centerCircle.y);
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
point (0, 0);
//create the spiraling for loop. use absolute value to determine boundary conditions.
//use spiralTheta as a SCALAR
if (mouseYspiralAcceleration) {
spiralAcceleration = map(mouseY, 0, height, .001, 1);
}
spiralTheta = spiralTheta+ spiralSize * spiralAcceleration;
if (abs(spiralTheta) > 2) {
spiralSize =spiralSize*-1;
}
location.mult(spiralTheta);
point (location.x, location.y);
if (showLines) {
line(0, 0, location.x, location.y);
}
}

////Do ’7′: draw the faceControlCircles
void drawFaceControlSpirals (PVector location, PVector centerCircle) {
translate (centerCircle.x, centerCircle.y);
ellipse (0, 0, amplitudeX *.5, amplitudeY*.5);
point (0, 0);
//line(0, 0, width-location.x, height-location.y);
float backWardsY = location.y*-1;
float backWardsX = location.x*-1;
point (location.x, backWardsY);
point (location.x, location.y);
point (backWardsX, backWardsY);
point (backWardsX, location.y);
if (showLines) {
line(0, 0, location.x, location.y);
line (0, 0, location.x, backWardsY);
line (0, 0, backWardsX, backWardsY);
line (0, 0, backWardsX, location.y);
}
}

// this allows me to increase the complexity with keypad
void keyPressed() {
if (key == ’0′) {
lastKey=0;
}
if (key == ’1′) {
lastKey=1;
}
if (key == ’2′) {
lastKey=2;
}
if (key== ’3′) {
lastKey=3;
}
if (key ==’4′) {
lastKey=4;
}
if (key ==’5′) {
lastKey=5;
}
if (key == ’6′) {
lastKey=6;
}
if (key == ’7′) {
lastKey = 7;
}
if (key == ‘ ‘) {
showLines = !showLines;
}
if (key == ‘v’) {
mouseVelocity = !mouseVelocity;
}
if (key == ‘s’) {
mouseYspiralAcceleration = !mouseYspiralAcceleration;
}
if (key == CODED) {
if (keyCode == SHIFT) {
faceControl = !faceControl;
}
}
}

public void mouthWidthReceived(float w) {
println(“mouth Width: ” + w);
mouthWidth = w;
}
public void mouthHeightReceived(float h) {
println(“mouth height: ” + h);
mouthHeight = h;
}
public void eyebrowLeftReceived(float h) {
println(“eyebrow left: ” + h);
leftEyebrowHeight = h;
}
public void eyebrowRightReceived(float h) {
println(“eyebrow right: ” + h);
rightEyebrowHeight = h;
}
public void eyeLeftReceived(float h) {
println(“eye left: ” + h);
eyeLeftHeight = h;
}
public void eyeRightReceived(float h) {
println(“eye right: ” + h);
eyeRightHeight = h;
}
public void jawReceived(float h) {
println(“jaw: ” + h);
}

public void nostrilsReceived(float h) {
println(“nostrils: ” + h);
nostrilHeight = h;
}
public void found(int i) {
println(“found: ” + i); // 1 == found, 0 == not found
found = i == 1;
}
public void posePosition(float x, float y) {
println(“pose positiontX: ” + x + ” Y: ” + y );
posePosition = new PVector(x, y);
}
public void poseScale(float s) {
println(“scale: ” + s);
poseScale = s;
}
public void poseOrientation(float x, float y, float z) {
println(“pose orientationtX: ” + x + ” Y: ” + y + ” Z: ” + z);
poseOrientationX = x;
poseOrientationY = y;
poseOrientationZ = z;
}
void oscEvent(OscMessage theOscMessage) {
if (theOscMessage.isPlugged()==false) {
println(“UNPLUGGED: ” + theOscMessage);
}
}

and also this codes:

import oscP5.*;
OscP5 oscP5;

PVector posePosition;
boolean found;
float eyeLeftHeight;
float eyeRightHeight;
float mouthHeight;
float mouthWidth;
float nostrilHeight;
float leftEyebrowHeight;
float rightEyebrowHeight;

PVector[] meshPoints;

float poseScale;

void setup() {
size(640, 480);
frameRate(30);

meshPoints = new PVector[66];
for (int i = 0; i < meshPoints.length; i++) {
meshPoints[i] = new PVector();
}

oscP5 = new OscP5(this, 8338);
oscP5.plug(this, “mouthWidthReceived”, “/gesture/mouth/width”);
oscP5.plug(this, “mouthHeightReceived”, “/gesture/mouth/height”);
oscP5.plug(this, “eyebrowLeftReceived”, “/gesture/eyebrow/left”);
oscP5.plug(this, “eyebrowRightReceived”, “/gesture/eyebrow/right”);
oscP5.plug(this, “eyeLeftReceived”, “/gesture/eye/left”);
oscP5.plug(this, “eyeRightReceived”, “/gesture/eye/right”);
oscP5.plug(this, “jawReceived”, “/gesture/jaw”);
oscP5.plug(this, “nostrilsReceived”, “/gesture/nostrils”);
oscP5.plug(this, “found”, “/found”);
oscP5.plug(this, “poseOrientation”, “/pose/orientation”);
oscP5.plug(this, “posePosition”, “/pose/position”);
oscP5.plug(this, “poseScale”, “/pose/scale”);
oscP5.plug(this, “loadMesh”, “/raw”);
}

void draw() {
background(0);
stroke(100);
if (found) {
fill(255);
for (int i = 0; i < meshPoints.length-1; i++) {
PVector p = meshPoints[i];
ellipse(p.x, p.y, 3, 3);
if(i > 0){
PVector prev = meshPoints[i-1];
line(prev.x, prev.y, p.x,p.y);
}
}

/*translate(posePosition.x, posePosition.y);
scale(poseScale);
noFill();
// ellipse(0,0, 3,3);
ellipse(-20, eyeLeftHeight * -9, 20, 7);
ellipse(20, eyeRightHeight * -9, 20, 7);
ellipse(0, 20, mouthWidth* 3, mouthHeight * 3);
ellipse(-5, nostrilHeight * -1, 7, 3);
ellipse(5, nostrilHeight * -1, 7, 3);
rectMode(CENTER);
fill(0);
rect(-20, leftEyebrowHeight * -5, 25, 5);
rect(20, rightEyebrowHeight * -5, 25, 5);
*/
}
}

public void mouthWidthReceived(float w) {
// println(“mouth Width: ” + w);
mouthWidth = w;
}

public void mouthHeightReceived(float h) {
// println(“mouth height: ” + h);
mouthHeight = h;
}

public void eyebrowLeftReceived(float h) {
// println(“eyebrow left: ” + h);
leftEyebrowHeight = h;
}

public void eyebrowRightReceived(float h) {
println(“eyebrow right: ” + h);
rightEyebrowHeight = h;
}

public void eyeLeftReceived(float h) {
println(“eye left: ” + h);
eyeLeftHeight = h;
}

public void eyeRightReceived(float h) {
// println(“eye right: ” + h);
eyeRightHeight = h;
}

public void jawReceived(float h) {
// println(“jaw: ” + h);
}

public void nostrilsReceived(float h) {
// println(“nostrils: ” + h);
nostrilHeight = h;
}

public void found(int i) {
println(“found: ” + i); // 1 == found, 0 == not found
found = i == 1;
}

public void posePosition(float x, float y) {
//println(“pose positiontX: ” + x + ” Y: ” + y );
posePosition = new PVector(x, y);
}

public void poseScale(float s) {
//println(“scale: ” + s);
poseScale = s;
}

public void poseOrientation(float x, float y, float z) {
//println(“pose orientationtX: ” + x + ” Y: ” + y + ” Z: ” + z);
}

// this method was generated programmatically. It’s fugly.
public void loadMesh(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float x5, float y5, float x6, float y6, float x7, float y7, float x8, float y8, float x9, float y9, float x10, float y10, float x11, float y11, float x12, float y12, float x13, float y13, float x14, float y14, float x15, float y15, float x16, float y16, float x17, float y17, float x18, float y18, float x19, float y19, float x20, float y20, float x21, float y21, float x22, float y22, float x23, float y23, float x24, float y24, float x25, float y25, float x26, float y26, float x27, float y27, float x28, float y28, float x29, float y29, float x30, float y30, float x31, float y31, float x32, float y32, float x33, float y33, float x34, float y34, float x35, float y35, float x36, float y36, float x37, float y37, float x38, float y38, float x39, float y39, float x40, float y40, float x41, float y41, float x42, float y42, float x43, float y43, float x44, float y44, float x45, float y45, float x46, float y46, float x47, float y47, float x48, float y48, float x49, float y49, float x50, float y50, float x51, float y51, float x52, float y52, float x53, float y53, float x54, float y54, float x55, float y55, float x56, float y56, float x57, float y57, float x58, float y58, float x59, float y59, float x60, float y60, float x61, float y61, float x62, float y62, float x63, float y63, float x64, float y64, float x65, float y65) {
println(“loading mesh…”);
meshPoints[0].x = x0;
meshPoints[0].y = y0;
meshPoints[1].x = x1;
meshPoints[1].y = y1;
meshPoints[2].x = x2;
meshPoints[2].y = y2;
meshPoints[3].x = x3;
meshPoints[3].y = y3;
meshPoints[4].x = x4;
meshPoints[4].y = y4;
meshPoints[5].x = x5;
meshPoints[5].y = y5;
meshPoints[6].x = x6;
meshPoints[6].y = y6;
meshPoints[7].x = x7;
meshPoints[7].y = y7;
meshPoints[8].x = x8;
meshPoints[8].y = y8;
meshPoints[9].x = x9;
meshPoints[9].y = y9;
meshPoints[10].x = x10;
meshPoints[10].y = y10;
meshPoints[11].x = x11;
meshPoints[11].y = y11;
meshPoints[12].x = x12;
meshPoints[12].y = y12;
meshPoints[13].x = x13;
meshPoints[13].y = y13;
meshPoints[14].x = x14;
meshPoints[14].y = y14;
meshPoints[15].x = x15;
meshPoints[15].y = y15;
meshPoints[16].x = x16;
meshPoints[16].y = y16;
meshPoints[17].x = x17;
meshPoints[17].y = y17;
meshPoints[18].x = x18;
meshPoints[18].y = y18;
meshPoints[19].x = x19;
meshPoints[19].y = y19;
meshPoints[20].x = x20;
meshPoints[20].y = y20;
meshPoints[21].x = x21;
meshPoints[21].y = y21;
meshPoints[22].x = x22;
meshPoints[22].y = y22;
meshPoints[23].x = x23;
meshPoints[23].y = y23;
meshPoints[24].x = x24;
meshPoints[24].y = y24;
meshPoints[25].x = x25;
meshPoints[25].y = y25;
meshPoints[26].x = x26;
meshPoints[26].y = y26;
meshPoints[27].x = x27;
meshPoints[27].y = y27;
meshPoints[28].x = x28;
meshPoints[28].y = y28;
meshPoints[29].x = x29;
meshPoints[29].y = y29;
meshPoints[30].x = x30;
meshPoints[30].y = y30;
meshPoints[31].x = x31;
meshPoints[31].y = y31;
meshPoints[32].x = x32;
meshPoints[32].y = y32;
meshPoints[33].x = x33;
meshPoints[33].y = y33;
meshPoints[34].x = x34;
meshPoints[34].y = y34;
meshPoints[35].x = x35;
meshPoints[35].y = y35;
meshPoints[36].x = x36;
meshPoints[36].y = y36;
meshPoints[37].x = x37;
meshPoints[37].y = y37;
meshPoints[38].x = x38;
meshPoints[38].y = y38;
meshPoints[39].x = x39;
meshPoints[39].y = y39;
meshPoints[40].x = x40;
meshPoints[40].y = y40;
meshPoints[41].x = x41;
meshPoints[41].y = y41;
meshPoints[42].x = x42;
meshPoints[42].y = y42;
meshPoints[43].x = x43;
meshPoints[43].y = y43;
meshPoints[44].x = x44;
meshPoints[44].y = y44;
meshPoints[45].x = x45;
meshPoints[45].y = y45;
meshPoints[46].x = x46;
meshPoints[46].y = y46;
meshPoints[47].x = x47;
meshPoints[47].y = y47;
meshPoints[48].x = x48;
meshPoints[48].y = y48;
meshPoints[49].x = x49;
meshPoints[49].y = y49;
meshPoints[50].x = x50;
meshPoints[50].y = y50;
meshPoints[51].x = x51;
meshPoints[51].y = y51;
meshPoints[52].x = x52;
meshPoints[52].y = y52;
meshPoints[53].x = x53;
meshPoints[53].y = y53;
meshPoints[54].x = x54;
meshPoints[54].y = y54;
meshPoints[55].x = x55;
meshPoints[55].y = y55;
meshPoints[56].x = x56;
meshPoints[56].y = y56;
meshPoints[57].x = x57;
meshPoints[57].y = y57;
meshPoints[58].x = x58;
meshPoints[58].y = y58;
meshPoints[59].x = x59;
meshPoints[59].y = y59;
meshPoints[60].x = x60;
meshPoints[60].y = y60;
meshPoints[61].x = x61;
meshPoints[61].y = y61;
meshPoints[62].x = x62;
meshPoints[62].y = y62;
meshPoints[63].x = x63;
meshPoints[63].y = y63;
meshPoints[64].x = x64;
meshPoints[64].y = y64;
meshPoints[65].x = x65;
meshPoints[65].y = y65;
}

void oscEvent(OscMessage theOscMessage) {
if (theOscMessage.isPlugged()==false) {
println(“UNPLUGGED: ” + theOscMessage);
}
}

the second one seems more explicit. the first one i run them into my processing. but it doesn’t work, i ask Tom, he suggested me i need to cut down different parts of codes because it is too complex, then test them one by one to find the problem.

so i change the void draw. see as follows:

void draw () {
translate(300,300);
rect(mouthWidth,mouthHeight,50,50);
fill(#A731A2);
strokeWeight(5);
stroke(#31A77D);

}

what i do is just make a circle of mouth.

then start it, bingo!!!

sorry i dont know how to insert short video, this is just picture. on running this codes, the rectangule is moving with my month simoutanously.

i will inverstigate further about processing.

 

 

 

 

 

processing youtube tutorial

10

today i watch the processing tutorial in youtube, it is suitable for me. this tutorial is to teach how to write codes in processing carefully and patiently, and comments below are full of satisfaction.

 

it sorted out some problem i have in processing learning. today i just went through the 01-05.

also, i know the processing based on java language, i am thinking about does it help if i also learn java as well?

 

then i found a good study website in Chinese. 

this website is to offer plenty kinds of computer technologies including programming, software studying, etc, categories by different kinds of jobs. Which means if one want to find a job in relevant area they can directly study in this website which provide enough knowledge helping you to enter your career. and it also has advice to guide you how to study to achieve your career plans and wont cost lots of money, very helpful.

it has java fundamental tutorial, intermediate and advanced tutorial.

because it is in chinese language, it will much easier for me to study java.

processing3

6

it is not easy for jumping beginner level to intermediate, i puzzled when i go further in “images and pixels’ tutorial. why when i writing codes by myself it cannot work, or sometimes the result is not what i want? it is strange.

filter is helpful to my projects. i think to make a rotten face would first confirm the eyes, mouth in a face, then i could use fade picture to filter them one by one.

but then i got problem! i have to read them again and again to make sense.

i have to copy it to processing, then analyse them one by one. then finally i understand them.

there is another problem, these codes seems so difficult.

even there are explanation sentence everywhere, but i have to consider could i write those codes by myself?

i decide to start to look for any tutorial in other websites. and i find there are lots of valuable tutorial in youtube.

processing

3

i know that my final project need complex programming, so i decide to study processing today. there are lots of tutorials in processing official websites, i know it is not easy thing, i am planning to learn one tutorial per day until i complete them all and will also look for other methods to handle processing as well.

today i go through the three introducing tutorial, very basic knowledge about processing. i am now sure this software is necessary for my rotten face project.