Category Archives: computational cameras

future of computer vision

thelivingrobot_hs
http:// seedmagazine.com/content/article/the_living_robot/

Computer vision has been using in different areas for years. I think the reason behind making researches about computer vision is, most important and effective sense is vision. We mostly learn thing by seeing. I have been to an experiment 3 years ago. We were in a room and having a dinner with around 50 people. Suddenly they turned the lights off for 5 min. We tried to eat our food without seeing it. You can smell it, you can touch it, you can hear the people around you, but you can’t see it. It was every interesting to see that vision is very important for us.

I think one of the important areas for the computer vision is, industrial production.  In factories people using CV, for automated systems or to see very small details.

Another area is health services. Now a day, doctors are using cameras and robotic arms in surgeries.

I think in the near future, we are going to start producing smart machines with cameras.

There is an article on www.seedmagazine.com about a new robot that have ability to learn things, and at the end it dies because it learns more that its capacity. I am sure when the time comes, people will start to develop algorithms for those robots that they can start learning the things that they see by their eyes (cameras).  In this example, they are using sonar sensor, which gives range values. For Example, hat if we use a camera with a sonar sensor. So we can detect objects (maybe with their shapes), which are close to our robot. Than by using an algorithm like color tracking we can understand the objects color. This process is very similar to a babies learning process. We can keep those data in memory and by using an algorithm (something like neural networks) we can start learning.

For example, our robot sees a chair (a chair like black one in class) and keeps its shape in its mind, than checks for the color. Then whenever it sees a chair with similar shape and color, it can think that it is in ITP.

So, maybe they can start watching our moves and start to make correlations between reason and result. That means we are creating the human again and all those sci-fi movies would become real.

tracking v1.0

This weeks assignment was to track something.

I am planing to track dancers moves for my final project and make some visuals to them. So, I start with using IR lamp (array of IR LED’s) and a firewire cam with IR filter. I track the reflection of the IR’s from the objects. I have 2 images to share with you….

blur code

blur:

import processing.core.PApplet;
import processing.core.PImage;
import processing.video.*;

public class compW2Blur extends PApplet {

/**
* Getting Started with Capture.
*
* Reading and displaying an image from an attached Capture device.
*/
PImage back;
int threshold = 16;
Capture video;
boolean shootPhoto = false;
float v = (float) (1.0/9.0);
float[][] kernel = { { v, v, v },
{ v, v, v },
{ v, v, v } };
static public void main(String _args[]){
PApplet.main(new String[]{”compW2Blur”});
}

public void setup() {
size(640, 480);

// If no device is specified, will just use the default.
video = new Capture(this, 640, 480);

// To use another device (i.e. if the default device causes an error),
// list all available capture devices to the console to find your videoera.
//String[] devices = Capture.list();
//println(devices);

// Change devices[0] to the proper index for your videoera.
//video = new Capture(this, width, height, devices[0]);

// Opens the settings page for this capture device.
//videoera.settings();
}

public void grabBackground(){

//println(”in”);
shootPhoto = true;
back = video.get(0, 0, video.width, video.height);
}

public void draw() {
if (video.available()) {
video.read();
image(video, 0,0);

if(shootPhoto == true){

loadPixels();
/* int numberOfChanges = 0;

for (int row = 0; row < video.height; row++) {
for (int col = 0; col < video.width; col++) {
int offset = row * width + col;

int fgColor = video.pixels[offset];
int bgColor = back.pixels[offset];
float fgR = red(fgColor);
float fgG = green(fgColor);
float fgB = blue(fgColor);

float bgR = red(bgColor);
float bgG = green(bgColor);
float bgB = blue(bgColor);
float diff = dist(fgR, fgG, fgB, bgR, bgG, bgB);
if (diff > threshold) {
//pixels[offset] = fgColor;
numberOfChanges++;
//pixels[offset] = color(255,255,255);

}
else{pixels[offset] = color(0,0,0);

}

}
}
// if (numberOfChanges > video.pixels.length/2) {
//    uploadPicture();
//}
grabBackground(); //you decide grab after every frame or just at setup and mousedown

updatePixels();
*/

// Create an opaque image of the same size as the original
PImage edgeImg = createImage(video.width, video.height, RGB);
// Loop through every pixel in the image.
for (int y = 1; y < video.height-1; y++) { // Skip top and bottom edges
for (int x = 1; x < video.width-1; x++) { // Skip left and right edges

float sum = 0; // Kernel sum for this pixel
for (int ky = -1; ky <= 1; ky++) {
for (int kx = -1; kx <= 1; kx++) {
// Calculate the adjacent pixel for this kernel point
int pos = (y + ky)*width + (x + kx);
// Image is grayscale, red/green/blue are identical
float val = blue(pixels[pos]);
// Multiply adjacent pixels based on the kernel values
sum += kernel[ky+1][kx+1] * val;
}
}
// For this pixel in the new image, set the gray value
// based on the sum from the kernel
edgeImg.pixels[y*video.width + x] = color(sum);
}
}
// State that there are changes to edgeImg.pixels[]
edgeImg.updatePixels();
image(edgeImg, 0, 0); // Draw the new image

}

}
}

public void keyPressed() {
if (key == ’s’) {

grabBackground();
}
}

}

background remove code

background remove:

import processing.core.PApplet;
import processing.core.PImage;
import processing.video.*;

public class compW2Back extends PApplet {

/**
* Getting Started with Capture.
*
* Reading and displaying an image from an attached Capture device.
*/
PImage back;
int threshold = 16;
Capture video;
boolean shootPhoto = false;
float[][] kernel = { { -1, -1, -1 },
{ -1,  9, -1 },
{ -1, -1, -1 } };

static public void main(String _args[]){
PApplet.main(new String[]{”compW2Back”});
}

public void setup() {
size(640, 480);

// If no device is specified, will just use the default.
video = new Capture(this, 640, 480);

// To use another device (i.e. if the default device causes an error),
// list all available capture devices to the console to find your videoera.
//String[] devices = Capture.list();
//println(devices);

// Change devices[0] to the proper index for your videoera.
//video = new Capture(this, width, height, devices[0]);

// Opens the settings page for this capture device.
//videoera.settings();
}

public void grabBackground(){

//println(”in”);
shootPhoto = true;
back = video.get(0, 0, video.width, video.height);
}

public void draw() {
if (video.available()) {
video.read();
image(video, 0,0);

if(shootPhoto == true){

loadPixels();
int numberOfChanges = 0;

for (int row = 0; row < video.height; row++) {
for (int col = 0; col < video.width; col++) {
int offset = row * width + col;

int fgColor = video.pixels[offset];
int bgColor = back.pixels[offset];
float fgR = red(fgColor);
float fgG = green(fgColor);
float fgB = blue(fgColor);

float bgR = red(bgColor);
float bgG = green(bgColor);
float bgB = blue(bgColor);
float diff = dist(fgR, fgG, fgB, bgR, bgG, bgB);
if (diff > threshold) {
//pixels[offset] = fgColor;
numberOfChanges++;
//pixels[offset] = color(255,255,255);

}
else{pixels[offset] = color(0,0,0);

}

}
}
// if (numberOfChanges > video.pixels.length/2) {
//    uploadPicture();
//}
grabBackground(); //you decide grab after every frame or just at setup and mousedown

updatePixels();

/*

// Create an opaque image of the same size as the original
PImage edgeImg = createImage(video.width, video.height, RGB);
// Loop through every pixel in the image.
for (int y = 1; y < video.height-1; y++) { // Skip top and bottom edges
for (int x = 1; x < video.width-1; x++) { // Skip left and right edges

float sum = 0; // Kernel sum for this pixel
for (int ky = -1; ky <= 1; ky++) {
for (int kx = -1; kx <= 1; kx++) {
// Calculate the adjacent pixel for this kernel point
int pos = (y + ky)*width + (x + kx);
// Image is grayscale, red/green/blue are identical
float val = red(pixels[pos]);
// Multiply adjacent pixels based on the kernel values
sum += kernel[ky+1][kx+1] * val;
}
}
// For this pixel in the new image, set the gray value
// based on the sum from the kernel
edgeImg.pixels[y*video.width + x] = color(sum);
}
}
// State that there are changes to edgeImg.pixels[]
edgeImg.updatePixels();
image(edgeImg, 0, 0); // Draw the new image*/

}

}
}

public void keyPressed() {
if (key == ’s’) {

grabBackground();
}
}

}

Edge detection code

Edge detection:

import processing.core.PApplet;
import processing.core.PImage;
import processing.video.*;

public class compW2Edge extends PApplet {

/**
* Getting Started with Capture.
*
* Reading and displaying an image from an attached Capture device.
*/
PImage backgroundImage = new PImage(width,height);
PImage back;
int threshold = 16;
Capture video;
boolean shootPhoto = false;
float[][] kernel = { { -1, -1, -1 },
{ -1,  9, -1 },
{ -1, -1, -1 } };

public void setup() {
size(640, 480);

// If no device is specified, will just use the default.
video = new Capture(this, 640, 480);

// To use another device (i.e. if the default device causes an error),
// list all available capture devices to the console to find your videoera.
//String[] devices = Capture.list();
//println(devices);

// Change devices[0] to the proper index for your videoera.
//video = new Capture(this, width, height, devices[0]);

// Opens the settings page for this capture device.
//videoera.settings();
}

public void grabBackground(){
//image(video, 0,0);
backgroundImage.copy(video,0,0,video.width,video.height,0,0,video.width,video.height);
backgroundImage.updatePixels();
//println(”in”);
shootPhoto = true;
back = video.get(0, 0, video.width, video.height);
}

public void draw() {
if (video.available()) {
video.read();
image(video, 0,0);

if(shootPhoto == true){

loadPixels();
int numberOfChanges = 0;

for (int row = 0; row < video.height; row++) {
for (int col = 0; col < video.width; col++) {
int offset = row * width + col;

int fgColor = video.pixels[offset];
int bgColor = back.pixels[offset];
float fgR = red(fgColor);
float fgG = green(fgColor);
float fgB = blue(fgColor);

float bgR = red(bgColor);
float bgG = green(bgColor);
float bgB = blue(bgColor);
float diff = dist(fgR, fgG, fgB, bgR, bgG, bgB);
if (diff > threshold) {
//pixels[offset] = fgColor;
numberOfChanges++;
pixels[offset] = color(255,255,255);

}
else{pixels[offset] = color(0,0,0);

}

}
}
// if (numberOfChanges > video.pixels.length/2) {
//    uploadPicture();
//}
grabBackground(); //you decide grab after every frame or just at setup and mousedown

updatePixels();

// Create an opaque image of the same size as the original
PImage edgeImg = createImage(video.width, video.height, RGB);
// Loop through every pixel in the image.
for (int y = 1; y < video.height-1; y++) { // Skip top and bottom edges
for (int x = 1; x < video.width-1; x++) { // Skip left and right edges

float sum = 0; // Kernel sum for this pixel
for (int ky = -1; ky <= 1; ky++) {
for (int kx = -1; kx <= 1; kx++) {
// Calculate the adjacent pixel for this kernel point
int pos = (y + ky)*width + (x + kx);
// Image is grayscale, red/green/blue are identical
float val = red(pixels[pos]);
// Multiply adjacent pixels based on the kernel values
sum += kernel[ky+1][kx+1] * val;
}
}
// For this pixel in the new image, set the gray value
// based on the sum from the kernel
edgeImg.pixels[y*video.width + x] = color(sum);
}
}
// State that there are changes to edgeImg.pixels[]
edgeImg.updatePixels();
image(edgeImg, 0, 0); // Draw the new image

}

}
}

public void keyPressed() {
if (key == ’s’) {

grabBackground();
}
}

}

compCameras week2

this weeks assignmen was to play arround some image processing techniques. I did some edge detection, bluring and background removing. All the applications that I have are sensitive to motion. They are searching through differences between pixels and then doing their detection.

However I don’t know how to export html with eclipse. So, for this week I am puting my code here. To see the results press “s”.

week1

Reasons to share photos:

1) My family and friends live in Turkey. So, I share photos to keep them updated.

2) Important and interesting moments

3) If there is more than one person in a photo, I share it and they can keep a copy of it.

an example

By uploading an image, we can give locations, time. Also if we can notice the persons that we want to share the picture, via e-mail or mms(that’s easier), that would be really great. Like the one that I posted in example link, I can send this image to a hospital or a doctor and ask for help. It could be something like a health server(ex:helpme@help.com), which you can ask for help.