Bu Blogda Ara

30 Aralık 2009 Çarşamba

İki Kamera Color Tracking

İki elim doluyken nasıl screenshot aldım? C: Orkun.

import processing.video.*;
Capture video;
Capture video2;
int[] depobrightestx = new int[2];
int[] depobrightesty = new int[2];
int[] deporedx = new int[2];
int[] deporedy = new int[2];
int[] depobluex = new int[2];
int[] depobluey = new int[2];
int sayac=1;
String[] captureDevices;
String[] alist = new String[100];

void setup() {
size(1280, 480); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
println(Capture.list());
captureDevices=Capture.list();
video = new Capture(this, 640, 480, 30);
video.settings();
video2=new Capture(this,640,480,30);
video2.settings();



noStroke();
smooth();
frameRate(4);
}

void draw() {

if (video.available()) {
video.read();
image(video,0,0);
}
if(video2.available()){
image(video2,640,0);
video2.read();
}
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = width/2; // X-coordinate of the brightest video pixel
int brightestY = width/2; // Y-coordinate of the brightest video pixel
int redX = width/2;
int redY = width/2;
int blueX = width/2;
int blueY = width/2;
float blueeValue = 128;
float brightestValue =128;
float reddValue = 128;
// Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
loadPixels();
int index = 0;
for (int y = 0; y <>
for (int x = 0; x <>
// Get the color stored in the pixel
int pixelValue = pixels[index];
// Determine the brightness of the pixel
float redValue = red(pixelValue);
float greenValue= green(pixelValue);
float blueValue= blue(pixelValue);

// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if ((greenValue > 140)&&(redValue>140)&&(blueValue<60)){
if (( x !=0) &&( y != 0))
{
brightestValue = redValue;
brightestY = y;
brightestX = x;
}
}

if ((blueValue> 200)&&(greenValue <>
if (( x !=0) && (y != 0)){
blueeValue = blueValue;
blueY = y;
blueX = x;
}
}

if ((redValue > reddValue)&&(blueValue<90)&&(greenvalue<90)){
if (( x !=0) &&( y != 0))
{
reddValue = redValue;
redY = y;
redX = x;
}
}

index++;

}


}
// Draw a large, yellow circle at the brightest pixel

fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 14, 14);
stroke(0,0,0,120);

fill (255, 0, 0 , 128);
ellipse(redX,redY, 14,14);
fill (0, 50, 200 , 128);
ellipse(blueX,blueY, 14,14);



line(blueX, blueY, brightestX, brightestY);
line(redX, redY, blueX, blueY);
line(brightestX, brightestY, redX, redY);
depobrightestx [sayac] = brightestX ;
depobrightestx = append (depobrightestx,sayac+2);
depobrightesty [sayac] = brightestY ;
depobrightesty = append (depobrightesty,sayac+2);
deporedx [sayac] = redX ;
deporedx = append (deporedx,sayac+2);
deporedy [sayac] = redY ;
deporedy = append (deporedy,sayac+2);
depobluex [sayac] = blueX ;
depobluex = append (depobluex,sayac+2);
depobluey [sayac] = blueY ;
depobluey = append (depobluey,sayac+2);
sayac++;

}

VE GORUNTULER IKIYE KATLANIR


/*
Ikincil Kamera

Cagri Zaman
31 Aralik 09
*/

import processing.video.*;
Capture bir; //kamera nesneleri
Capture iki;

String[] captureDevices;


void setup(){
size(1280,480 );
print(Capture.list());
captureDevices = Capture.list();

bir=new Capture(this,640,480,30);
bir.settings();
iki=new Capture(this,640,480,30);
iki.settings();

}

void draw(){
if(bir.available()){
bir.read();
image(bir,0,0);
}

if(iki.available()){
iki.read();
image(iki,640,0);

}




}

Düzeltme- Sonlu Elemanlar Dizisi

Array lerde kullanılan Expand komutu yanlış. Expand sadece dizinin boyutunu değiştiriyor. Kullanılması gereken komut Append(array,value) olacaktı.

29 Aralık 2009 Salı

'colour tracking' heyecanı 2 - renk kapmaca

'colour tracking' heyecanı

fotoğraflar - 3 renk







sonlu elemanlar analizisi

import processing.video.*;
Capture video;
int[] depobrightestx = new int[2];
int[] depobrightesty = new int[2];
int[] deporedx = new int[2];
int[] deporedy = new int[2];
int[] depobluex = new int[2];
int[] depobluey = new int[2];
int sayac=1;
String[] alist = new String[100];

void setup() {
size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 30);

noStroke();
smooth();
frameRate(4);
}

void draw() {
fill(255,70);
rect(0,0,640,480);

if (video.available()) {
video.read();
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = width/2; // X-coordinate of the brightest video pixel
int brightestY = width/2; // Y-coordinate of the brightest video pixel
int redX = width/2;
int redY = width/2;
int blueX = width/2;
int blueY = width/2;
float blueeValue = 128;
float brightestValue =128;
float reddValue = 128;
// Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
// Get the color stored in the pixel
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float redValue = red(pixelValue);
float greenValue= green(pixelValue);
float blueValue= blue(pixelValue);

// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if ((greenValue > 140)&&(redValue>140)&&(blueValue<60)){
if (( x !=0) &&( y != 0))
{
brightestValue = redValue;
brightestY = y;
brightestX = x;
}
}

if ((blueValue> 200)&&(greenValue < 150)&&(redValue< 200)){
if (( x !=0) && (y != 0)){
blueeValue = blueValue;
blueY = y;
blueX = x;
}
}
if ((redValue > reddValue)&&(blueValue<90)&&(greenValue<90)){
if (( x !=0) &&( y != 0))
{
reddValue = redValue;
redY = y;
redX = x;
}
}
index++;
}
}
// Draw a large, yellow circle at the brightest pixel

fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 14, 14);
stroke(0,0,0,120);

fill (255, 0, 0 , 128);
ellipse(redX,redY, 14,14);
fill (0, 50, 200 , 128);
ellipse(blueX,blueY, 14,14);



line(blueX, blueY, brightestX, brightestY);
line(redX, redY, blueX, blueY);
line(brightestX, brightestY, redX, redY);
depobrightestx [sayac] = brightestX ;
depobrightestx = expand (depobrightestx,sayac+2);
depobrightesty [sayac] = brightestY ;
depobrightesty = expand (depobrightesty,sayac+2);
deporedx [sayac] = redX ;
deporedx = expand (deporedx,sayac+2);
deporedy [sayac] = redY ;
deporedy = expand (deporedy,sayac+2);
depobluex [sayac] = blueX ;
depobluex = expand (depobluex,sayac+2);
depobluey [sayac] = blueY ;
depobluey = expand (depobluey,sayac+2);
sayac++;
}
}

Red-Yellow-Blue




üçüncü renk mavidir

/**
* Brightness Tracking
* by Golan Levin.
*
* Tracks the brightest pixel in a live video signal.
* revision by Çağrı Hakan Zaman 20 Aralik 2009
* revision by Sema Alaçam 29 Aralik 2009
*/

import processing.video.*;
Capture video;

String[] alist = new String[100];

void setup() {
size(600, 480); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 30);

noStroke();
smooth();
frameRate(4);
}

void draw() {

if (video.available()) {
video.read();
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = width/2; // X-coordinate of the brightest video pixel
int brightestY = width/2; // Y-coordinate of the brightest video pixel
int redX = width/2;
int redY = width/2;
int blueX = width/2;
int blueY = width/2;
float blueeValue = 128;
float brightestValue =128;
float reddValue = 128;
// Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
// Get the color stored in the pixel
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float redValue = red(pixelValue);
float greenValue= green(pixelValue);
float blueValue= blue(pixelValue);

// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if ((greenValue > 140)&&(redValue>140)&&(blueValue<60)){
if (( x !=0) &&( y != 0))
{
brightestValue = redValue;
brightestY = y;
brightestX = x;
}
}

if ((blueValue> 200)&&(greenValue < 150)&&(redValue< 200)){
if (( x !=0) && (y != 0)){
blueeValue = blueValue;
blueY = y;
blueX = x;
}
}
if ((redValue > reddValue)&&(blueValue<90)&&(greenValue<90)){
if (( x !=0) &&( y != 0))
{
reddValue = redValue;
redY = y;
redX = x;
}
}
index++;
}
}
// Draw a large, yellow circle at the brightest pixel

fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 14, 14);
stroke(0,0,0,120);

fill (255, 0, 0 , 128);
ellipse(redX,redY, 14,14);
fill (0, 50, 200 , 128);
ellipse(blueX,blueY, 14,14);



line(blueX, blueY, brightestX, brightestY);
line(redX, redY, blueX, blueY);
line(brightestX, brightestY, redX, redY);

}
}

22 Aralık 2009 Salı

3dsMax'e metin dosyasından veri okutmak

Asagidaki 3Dsmax betigi (script) ile, bir metin dosyasindan (*.txt) bir satirlik bilgili okutabilir, okutulan degeri belirli parcalarina bolebilir (burada bosluklara gore parcalara ayrilmis " "
yerin "-" ya da "," sekilinde farkli bölücüler de kullanılabilir.)

Bu betik, su anda dosyadan 3 adet sayi bilgisini okumakta kullanilmaktadir. Ihtiyaca gore daha detayli dosyalar icin de uyarlanabilir.


f = openFile "DosyaAd.txt"
if f != undefined then
(
while (not eof f) do
(
ss = readLine f -- satir oku ve degeri ss stringine ata
tokens = filterString ss " " -- ss string'ini boşlulara göre token (atomlarına) ayır.
)
close f
)
x = tokens[2] as integer -- 2. token elemanı tam sayıya çevir ve x'e ata.
y = tokens[3] as integer -- 3. token elemanı tam sayıya çevir ve y'ye ata.
print x -- x degerini ekrana yazdır
print y

20 Aralık 2009 Pazar

örnek kodun text dosyasına dönüştürülmesi

import processing.video.*;

Capture video;
String[] alist = new String[100];

void setup() {
size(800, 600); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 30);
noStroke();
smooth();
frameRate(4);
}

void draw() {
if (video.available()) {
video.read();
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = 0; // X-coordinate of the brightest video pixel
int brightestY = 0; // Y-coordinate of the brightest video pixel
int redX =0;
int redY = 0;
float brightestValue =128;
float reddValue = 128;
// Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for (int y = 0; y < x =" 0;" style="font-weight: bold;"> // Get the color stored in the pixel
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float redValue = red(pixelValue);
float greenValue= green(pixelValue);
float blueValue= blue(pixelValue);

// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if ((greenValue > 200)&&(redValue>200)&&(blueValue< brightestvalue =" redValue;" brightesty =" y;" brightestx =" x;"> reddValue)&&(blueValue<70)&&(greenvalue<70)){ reddvalue =" redValue;" redy =" y;" redx =" x;" style="font-weight: bold;">// Draw a large, yellow circle at the brightest pixel
fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 50, 50);
fill (255, 0, 0 , 128);
ellipse(redX,redY, 50,50);

//text dosyasına dönüştürme süreci

String valbrightestX = Integer.toString (brightestX);
String valbrightestY = Integer.toString(brightestY);
String valredX = Integer.toString (redX);
String valredY = Integer.toString (redY);
String b = ("-");
String kal = (valbrightestX+b+valbrightestY+b+b+valredX+b+valredY+b+b+b+b);
println (valbrightestX) ;
alist= append (alist, kal);

saveStrings("nouns.txt", alist);

}
}



-----------------------------------------------------------------------------------

örnek text verisi.....

null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
0-0--0-0----
0-0--0-0----
0-0--122-472----
238-517--0-0----
244-288--0-0----
0-0--0-0----
0-0--0-0----
511-177--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
284-326--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
0-0--0-0----
547-129--0-0----
285-598--0-0----
0-0--0-0----
0-0--0-0----

what is next

- kameradan alınan ve filtrelenen renge ait koordinatın: X , Y ve zaman bilgisi ile metin dosyasına yazdırılması

- kameradan alınan ve filtrelenen renge ait koordinatın: X , Y ve zaman bilgisi ile xml dosyasına yazdırılması

- dosyadan okunan nokta bulutu verisinin farklı ortamlarda işlenmesi:

-- rhino
-- 3dsMax
-- processing
-- maya mell
-- flash action script

- dosyadan okunan verilerin nasıl işlenebileceğine dair kaynak ve örnek araştırması (buket)

- konu ile ilişkili olabilecek örnek kodların ve revizyonlaırn blog aracılığıyla paylaşımı
the production of space. henri lefebvre
algılanan dünya. marleau-ponty
"Mekan eylemi çağırıyor, bu arada imgelem eylemden önce çalışmaya başlıyor" : mekanın poetikası. gaston bachelard

gibi okumalar mekan ve öznenin karşılaşması ile ilgili aklıma gelenler, daha da aklıma geldikçe yazarım
bu kitaplar kütüphaneden bulunabilir

bir ornek kod

/**
* Brightness Tracking
* by Golan Levin.
*
* Tracks the brightest pixel in a live video signal.
* revision by Cagri Hakan Zaman 20 Aralik 2009
*/


import processing.video.*;

Capture video;

void setup() {
size(800, 600); // Change size to 320 x 240 if too slow at 640 x 480
// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 30);
noStroke();
smooth();
}

void draw() {
if (video.available()) {
video.read();
//image(video, 0, 0, width, height); // Draw the webcam video onto the screen
int brightestX = 0; // X-coordinate of the brightest video pixel
int brightestY = 0; // Y-coordinate of the brightest video pixel
int redX =0;
int redY = 0;
float brightestValue =128;
float reddValue = 128;
// Brightness of the brightest video pixel
// Search for the brightest pixel: For each row of pixels in the video image and
// for each pixel in the yth row, compute each pixel's index in the video
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
// Get the color stored in the pixel
int pixelValue = video.pixels[index];
// Determine the brightness of the pixel
float redValue = red(pixelValue);
float greenValue= green(pixelValue);
float blueValue= blue(pixelValue);

// If that value is brighter than any previous, then store the
// brightness of that pixel, as well as its (x,y) location
if ((greenValue > 200)&&(redValue>200)&&(blueValue< 150)){
brightestValue = redValue;
brightestY = y;
brightestX = x;
}
if ((redValue > reddValue)&&(blueValue<70)&&(greenValue<70)){
reddValue = redValue;
redY = y;
redX = x;
}
index++;
}
}
// Draw a large, yellow circle at the brightest pixel
fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 50, 50);
fill (255, 0, 0 , 128);
ellipse(redX,redY, 50,50);
}
}




20 aralık





başlangıçtaki soru(n)lar

- hareket ve renk verisi yakalandıktan sonra ne amaçla kullanılacak?
- mekanın sınırlarını mı tanımlayacak?
- bir kutunun deformasyonu mu?
- 2 ve 3 boyut geçişleri nasıl olacak? verideki 3. boyuta geçiş, verinin temsiline nasıl yansıyacak?

bir kac faydalı link

http://www.learningprocessing.com/
http://www.processing.org