Diana Thompson, Week 6

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV myopencv;

import twitter4j.conf.*;
import twitter4j.*; //having just this will work
import twitter4j.auth.*;
import twitter4j.api.*;
import java.util.*;

Twitter twitter; //Twitter – class, twitter – object can be myTwitter

void setup()
{
size(800,600);
video = new Capture(this, 640/2, 480/2);
myopencv = new OpenCV(this, 640/2, 480/2);
myopencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video.start();

ConfigurationBuilder cb = new ConfigurationBuilder(); // cb (mycb) is a variable name
cb.setOAuthConsumerKey(“3KwViu2rXjVK3hl7DlOGkUo22”);
cb.setOAuthConsumerSecret(“AOqtBR4kxihi2zpNnKaNilYkGso2nAO1nTJe45puv5PLBBGkUU”);
cb.setOAuthAccessToken(“2616177440-sFIcqFJ1obMO4gjzh6WyGMU8GWsDjxc9baieKqb”);
cb.setOAuthAccessTokenSecret(“BApUJCBk94KcSMA8tJiQnQ6d5UiZvfavPJpRczkTBOEAY”);

TwitterFactory tf = new TwitterFactory(cb.build()); //object tf (mytf)

twitter = tf.getInstance(); //
}

void draw(){
scale(2);
myopencv.loadImage(video);
image(video, 0, 0 );
noFill();
stroke(123, 255, 24);
strokeWeight(9);
Rectangle[] faces = myopencv.detect();
println(“Number of Faces Detected:” + faces.length);

if(faces.length == 0){
tweet2();
}

for (int i = 0; i < faces.length; i++) {
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height); //green rectangle that draws the face // if (0<x
}
}
void tweet2()
{
try
{
Status status = twitter.updateStatus(“This is my tweet yall sent from Processing.”);
System.out.println(“Status updated to [” + status.getText() + “].”);
}
catch (TwitterException te)
{
System.out.println(“Error: “+ te.getMessage());
}
}

void captureEvent(Capture c) {
c.read();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s