Augmented Reality

To create an augmented reality application you do need: 1. Processing 1.5.1 stable or Processing 2 2. Quicktime 7 (Apple video software) 3. Video digitalizer for Quicktime WinVDIG1.0.5.exe, also known as QTCap Basic Quicktime Video Capture 4. Library GSVideo-1.00windows.zip 5. Library NyAR4psg Execute SimpleLite in examples (there are problems!) Execute SimpleLite3 given by the teacher with changes in code!   Arduino code: void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(A0)); } Processing code The Processing code import codeanticode.gsvideo.*; import jp.nyatla.nyar4psg.*; import processing.serial.*; Serial myPort; GSCapture cam; NyARMultiBoard nya; PFont font; String inString = null; float low = 3.0; float high = 32.0; float weight; void setup() { size(640,480,P3D); println(Serial.list()); myPort = new Serial(this, Serial.list()[1], 9600); myPort.bufferUntil(‘n’); font = loadFont(“crystal-lightning-64.vlw”); cam=new GSCapture(this,width,height); cam.play(); String[] patts = {“scale16.pat”}; double[] widths = {80}; nya = new NyARMultiBoard(this, width, height, “camera_para.dat”, patts, widths); print(nya.VERSION); nya.gsThreshold=120; nya.cfThreshold=0.4; } void draw(){ if (cam.available() !=true) { return; } cam.read(); hint(DISABLE_DEPTH_TEST); image(cam,0,0); hint(ENABLE_DEPTH_TEST); if(nya.detect(cam)){ if (nya.markers[0].detected){ nya.markers[0].beginTransform(); textFont(font,25.0); textAlign(CENTER); fill(50, 255, 0); translate(0,50,80); rotateX(radians(180)); rotateX(radians(90)); text(weight, 0, 0, 0); nya.markers[0].endTransform(); } } } void serialEvent (Serial myPort) { inString = myPort.readStringUntil(‘n’); if (inString != null) { inString = trim(inString); float val = float(inString); weight = 100+((val-low)*(100/(high-low))); }  

Leave a Reply

The best way to predict the future is to invent it (Alan Kay)