Recitation 9: Media Controller – Ariana Alvarez

For this week’s recitation, we were assigned to manipulate media in Processing through Arduino. I decided to explore the live video webcam in processing and manipulate the tint function in live images with the help of a potentiometer and infrared distance sensor in Arduino. 

For the first attempt in the code, I was able to change the opacity in the tint applied to the live video through the potentiometer. However, as I wasn’t redrawing the background in processing, the opacity was just change upon itself, and led to the creation of an even more interesting effect of blurred image, that made any user on the screen have some kind of a ghostly look.

The second manipulation, was inspired by the readings in “Computer Vision in Artists and Designer”, as it mentioned how algorithms and computing media has been used in detecting motion, specially that which involved “the movements of people”. Therefore, I developed a code that changed the tint of an image from blue to red, depending on how close an individual was situated from the infrared distance sensor in Arduino. 

For the codes of both iterations of media manipulation, I was going to use the multiple values example so that both sensors in Arduino were connected to processing. However, I first did it with the one value example, and when changing it to multiple values, both sensors were not working in the most efficient way while working simultaneously, therefore I changed it back to one value codes for the time provided. Here I am attaching the codes I used for both Arduino and Processing.

I was inspired in the ways technology was used in my project, specially in the sense that I felt as if I created an object that helped enhance security systems in stores. Similar to the idea of the game system LimboTime, which was developed for participants to attempt and pass below an imaginary line. If such individual crosses above the line, the game rings an alarm. Similar to this idea, for my second media manipulation, if a person went passed the allowed distance, the colors started to change in the webcam.

Code from Arduino

void setup() {
Serial.begin(9600);
}

void loop() {
int pin1 = analogRead(A0);
int sensorValue = map(pin1,0,1023,0,255);
Serial.write(sensorValue);

// too fast communication might cause some latency in Processing
// this delay resolves the issue.
delay(10);
}

Code from Processing

import processing.serial.*;


Serial myPort;
int valueFromArduino;


import processing.video.*; 
Capture cam;


void setup() { 
  size(1280, 480); 
  cam = new Capture(this, 640, 480);
  cam.start(); 
  
  
  printArray(Serial.list());
  // this prints out the list of all available serial ports on your computer.

  myPort = new Serial(this, Serial.list()[4], 9600);
  // WARNING!
  // You will definitely get an error here.
  // Change the PORT_INDEX to 0 and try running it again.
  // And then, check the list of the ports,
  // find the port "/dev/cu.usbmodem----" or "/dev/tty.usbmodem----" 
  // and replace PORT_INDEX above with the index number of the port.
  
} 

void draw() { 
  //background(255);
  if (cam.available()) { 
   cam.read(); 
  } 
     
  int x = valueFromArduino;
  scale(-1,1);
  image(cam, -640, 0); 
  scale(-1,1);
  image(cam, 640, 0);
  tint(0, 153, 204, x); 
 

//  if (valueFromArduino < 100) {
//      tint(0, 153, 204);
//  } else { 
//    tint(255,0,0);
//  }
  
   // to read the value from the Arduino
  while ( myPort.available() > 0) {
    valueFromArduino = myPort.read();
  }
  println(valueFromArduino);//This prints out the values from Arduino
}

*Side Note: I have been trying to include images of the circuit and pictures of the media manipulation, however it is not allowing me to do so as it says there’s an error with the images, therefore I’ll try it again tomorrow and if not possible I’ll send them through e-mail directly to Rudi*

Leave a Reply