'Processing'에 해당되는 글 19건

  1. 2010.01.05 Polygon
  2. 2009.09.03 [P5] Processing CVLibrary - JMyron bug
  3. 2009.08.20 [P5] 1.06 update
  4. 2009.08.19 [CV] openCV 와 JMyron frameRate 비교 - (Processing)
  5. 2009.07.24 스터디 진행 할 것들.
  6. 2009.07.16 Algorithms for Visual Design Using the Processing Language
  7. 2009.04.08 for 문과 배열의 이해
  8. 2009.03.22 mouse rollover
  9. 2009.03.19 마우스 클릭시 사각형 이동
  10. 2009.03.19 마우스 클릭시 배경색 단계적 표현

Polygon

|
사용법 : 키보드의 방향키 상하키를 누르면 꼭지점이 줄어들고 늘어난다.
좌우키를 누르면 크기가 변한다.

문제점 : 다각형의 꼭지점이 늘어날때마다 각을 새로 계산해서 평균각을 구하여 도형이 생성되야하는데...
int width = 320;
int height = 240;
int shapePoint = 1;

int loc = 50;

void setup(){
size(width, height);

smooth();
background(0);
}

void draw(){

background(0);


beginShape();
translate(width/2, height/2);
for(int i = 0; i < 360; i+= shapePoint){
float sinX = sin(radians(i)) * loc;
float cosY = cos(radians(i)) * loc;
vertex(sinX, cosY);
}
endShape(CLOSE);
println(shapePoint);

}

void keyPressed(){
if(keyCode == UP){
shapePoint ++;
if(shapePoint > 120) shapePoint = 120;
}
if(keyCode == DOWN){
shapePoint --;
if(shapePoint < 1) shapePoint = 1;
}
if(keyCode == LEFT){
loc --;
}
if(keyCode == RIGHT){
loc ++;
}

}
And

[P5] Processing CVLibrary - JMyron bug

|
int[][] GlobCenters discrepancy in JMyron

JMyron라이브러리를 사용하면 블랍검출에서 버그가 있다


int[][] a;
  //draw center points of globs
  a = m.globCenters();
  float avX=0;
  float avY=0;
  for( int i = 0; i < a.length; i++ ){  // 0번 블랍 부터  블랍의 총 갯수의 중심좌표를 구한다.
    float mapX = map(a[i][0], 0, camW, 0, width);
    float mapY = map(a[i][1], 0, camH, 0, height);
    point( mapX, mapY );
    if(i == 0) {
      avX = mapX;
      avY = mapY;
    }
    if(textOn){
      textFont(font, 12); 
      text(i, mapX, mapY);
    }
  }
원래 라이브러리의 문제점은 블랍의 갯수 1개일때 변수 i = 0번째 블랍만 생기면
위치변수값이 0으로 출력되는 버그이다. 그러나 블랍이 2개이상일때 즉 0번 블랍 1번블랍 이상일때는 정상적으로 작동한다

위의 버그를 수정한 라이브러리는 여기서 다운을 받으시서 사용하시면 버그가 해결된다.
혹은 첨부파일을 다운받으면 해결된다.
And

[P5] 1.06 update

|
프로세싱이 1.06 업데이트 되었다

PROCESSING 1.0.6 (REV 0168) - 12 August 2009

Bug fixes and minor changes. Most important are replacement JOGL libraries
so that OpenGL applets won't present an "expired certificate" error.

[ bug fixes ] 

+ Replaced the faulty JOGL library that had expired certificates (Sun bug).
  http://dev.processing.org/bugs/show_bug.cgi?id=1271
  https://jogl.dev.java.net/servlets/ProjectDocumentList?folderID=9260&expandFolder=9260&folderID=0

+ Updated the Linux launcher script that enables Processing to be run
  from other directories, symlinks, or from launch items.
  http://dev.processing.org/bugs/show_bug.cgi?id=825
  Thanks to Ferdinand Kasper for the fix!

+ strokeWeight() was making lines 2x too thick with P2D
  http://dev.processing.org/bugs/show_bug.cgi?id=1283

+ PImage.getImage() setting the wrong image type
  http://dev.processing.org/bugs/show_bug.cgi?id=1282

+ image() not working with P2D, P3D, and OPENGL when noFill() used
  http://dev.processing.org/bugs/show_bug.cgi?id=1299
  http://dev.processing.org/bugs/show_bug.cgi?id=1222

+ Auto format problem with program deeper then 10 levels
  http://dev.processing.org/bugs/show_bug.cgi?id=1297

+ Fixed a crash on startup problem (console being null)

+ Recursive subfolder copy of library folders when exporting application
  http://dev.processing.org/bugs/show_bug.cgi?id=1295

[ changes ]

+ PDF member functions set protected instead of private
  http://dev.processing.org/bugs/show_bug.cgi?id=1276

+ On OS X, update Info.plist to be 32/64 explicit and also updated 
  JavaApplicationStub for update 4.

+ Clicking the preferences location in the Preferences window will 
  now open the parent folder for the preferences file. 
  http://dev.processing.org/bugs/show_bug.cgi?id=1279

+ Update to Java 6 update 15 for the Windows and Linux releases.

[ fixed earlier ] 

+ Mangled menu text with Java 6u10.
  http://dev.processing.org/bugs/show_bug.cgi?id=1065
And

[CV] openCV 와 JMyron frameRate 비교 - (Processing)

|
TEST Computer Spec
Macbook Pro 2.2Ghz, 4G memory, 8600GT 128M
webcam : Logitech QuickCam Pro 9000(UVC driver)


openCV
import hypermedia.video.*;
OpenCV opencv;

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

 opencv = new OpenCV( this );
 opencv.capture(320,240);
}

void draw () {
  opencv.read();
  image( opencv.image(OpenCV.RGB), 0, 0 );
  println(frameRate);
}

5~7 프레임 사이

JMyron
 
import JMyron.*;

JMyron m;//a camera object
 
void setup(){
  size(800, 600);
  m = new JMyron();//make a new instance of the object
  m.start(320, 240);//start a capture at 320x240
  
  loadPixels();
}

void draw(){
  m.update();//update the camera view
  m.imageCopy(pixels);//draw image to stage
  updatePixels();
  println(frameRate);  
}

void mousePressed(){
  m.settings();//click the window to get the settings (mac users, this will crash you)
}

public void stop(){
  m.stop();//stop the object
  super.stop();
}

37프레임

JMyron

import JMyron.*;

JMyron m;//a camera object

int camW = 320;
int camH = 240;
 


void setup(){
  size(800, 600);
  m = new JMyron();//make a new instance of the object
  m.start(camW, camH);//start a capture at 320x240
  
}

void draw(){
  m.update();//update the camera view
  
  int[] img = m.image(); //get the normal image of the camera
  
  loadPixels();
  for(int i=0;i<camW*camH;i++){ //loop through all the pixels
      pixels[i] = img[i]; //draw each pixel to the screen
  }
  updatePixels();
  
  println(frameRate);
}

void mousePressed(){
  m.settings();//click the window to get the settings
}

public void stop(){
  m.stop();//stop the object
  super.stop();
}

40~43 프레임

 openCV가 프레임률이 떨어지는 이유는 뭘까요?
And

스터디 진행 할 것들.

|
프로세싱을 위한 openGL

import javax.media.opengl.*;
import processing.opengl.*;

float a; 

void setup() {
  size(800, 600, OPENGL);
}

void draw() {
  background(255);
  
  PGraphicsOpenGL pgl = (PGraphicsOpenGL) g;  // g may change
  GL gl = pgl.beginGL();  // always use the GL object returned by beginGL
  
  // Do some things with gl.xxx functions here.
  // For example, the program above is translated into:
  gl.glColor4f(0.7, 0.7, 0.7, 0.8);
  gl.glTranslatef(width/2, height/2, 0);
  gl.glRotatef(a, 1, 0, 0);
  gl.glRotatef(a*2, 0, 1, 0);
  gl.glRectf(-200, -200, 200, 200);
  gl.glRotatef(90, 1, 0, 0);
  gl.glRectf(-200, -200, 200, 200);
  
  pgl.endGL();
  
  a += 0.5;
}
프로세싱을 위한 AR

프로세싱 PVector

프로세싱 nature of code

Open Frameworks == 

And

Algorithms for Visual Design Using the Processing Language

|

프로세싱 관련하여 새로운 책이 발간 되었다.

Product Details

  • Hardcover: 384 pages
  • Publisher: Wiley (May 11, 2009)
  • Language: English
  • ISBN-10: 0470375485
  • ISBN-13: 978-0470375488
  • Product Dimensions: 9.4 x 7.5 x 1 inches
And

for 문과 배열의 이해

|
int[][] numbers = new int[10][10];
int sum=0;

for ( int x = 0; x < numbers.length; x++){
  for ( int y = 0; y < numbers.length; y++){
    sum = sum + 1;
    numbers[x][y] = sum;
    println("["+x+"]"+"["+y+"]"+" = "+numbers[x][y]);
  }
}

And

mouse rollover

|
요즘엔 똑같은 비주얼을 얼마나 다르게 코딩을 해볼 수 있을까하고 의문이 들었다.
간단하지만 롤오버코드를 여러가지로 풀어보았다. 어떤게 좋은 코딩인지는 모르겠으나 전부다 똑같이 동작한다.^^

스터디때 했었던 조건문인 IF를 사용한 간단한 예다.

// 변수 사용
int x;
int y;

void setup(){
  size(200, 200);
  noStroke();
}

void draw(){
  background(255);
  fill(0);
  rect(x, y, 100, 100);
  if( 0 < mouseX && 100 > mouseX && 0 < mouseY && 100 > mouseY){
   x = 0;
   y = 0; 
  }else if( 100 < mouseX && 200 > mouseX && 0 < mouseY && 100 > mouseY){
    x = 100;
    y = 0;
  }else if( 0 < mouseX && 100 > mouseX && 100 < mouseY && 200 > mouseY){
    x = 0;
    y= 100;
  }else{
    x = 100;
    y = 100;
  }
}

// 변수 미사용
void setup(){
  size(200, 200);
  noStroke();
}

void draw(){
  background(255);

  if( 100 > mouseX && 100 > mouseY){
    fill(0);
    rect(0, 0, 100, 100);
  }
  else if( 100 < mouseX && 100 > mouseY){
    fill(0);
    rect(100, 0, 100, 100);
  }
  else if( 100 > mouseX && 100 < mouseY){
    fill(0);
    rect(0, 100, 100, 100);
  }
  else if(100 < mouseX && 100 < mouseY){
    fill(0);
    rect(100, 100, 100, 100);
  }
}
And

마우스 클릭시 사각형 이동

|
int x = 100;
int y = 100;

void setup(){
  size(200, 200);
  smooth();
  rectMode(CENTER);
}

void draw(){
  background(0);
  rect(x, y, 20, 20);
}

void mousePressed(){
  x = mouseX;
  y = mouseY;
}



And

마우스 클릭시 배경색 단계적 표현

|
 int count = 0; // 변수 초기화

 void setup(){
   size(200, 200); // 사이즈 설정
 }
 
 void draw(){
   background(abs(count)); //백그라운드함수에 절대값 count를 설정
 }
 
 void mousePressed(){ // 마우스를 눌렀을때 
   count += 5; // count라는 변수에 5씩 증가
   if (count > 250){ // count가 250보다 크면 
     count *= -1; // count에 -1을 곱해서 음수로 표현
   }
   println(count); // 텍스트영역에서 수치를 확인
 }

마우스를 화면에 클릭할 경우 count가 5씩 증가하여
백그라운 색깔이 검정에서 흰색으로 흰색에서 검정으로 변한다.

And
prev | 1 | 2 | next