AR attempt | Hannah Davis

My aim for this assignment was to make one pattern reveal a basketball and to make another reveal a hoop, and then eventually have the basketball be able to go into the hoop….I got so far as to get the basketball  and hoop to appear when their respective patterns are on screen. I want to:

a) know why this thing is so damn shaky,

b) figure out where/if there are any clear, English javadocs for nyartoolkit?

c) make 3D models of these two things, not just 2D images

d) figure out how to interact between these two amidst all the different matrices etc.

 

Video below:

 

Code:

import processing.video.*;
// Processing 2.04a + NyARToolkit 1.1.7 //pared down from Amnon Owed http://www.creativeapplications.net/processing/augmented-reality-with-processing-tutorial-processing/
import java.io.*;
import processing.opengl.*;
// for OPENGL rendering
import jp.nyatla.nyar4psg.*;
// the NyARToolkit Processing library
//DON’T FORGET TO PUT THE “PATT.XXX” FILES AND “camera_para.dat” IN A DATA FOLDER IN YOUR SKETCH FOLDER
Capture cam;
MultiMarker nya;
PImage basketball;
PImage hoop;

 

void setup() {
size(640, 480, OPENGL);
basketball = loadImage(“basketball.png”);
hoop = loadImage(“hoop.png”);
cam = new Capture(this, 640, 480);
cam.start();
frameRate(30);
// create a new MultiMarker at a specific resolution (arWidth x arHeight), with the default camera calibration and coordinate system
nya = new MultiMarker(this, width, height, “camera_para.dat”, NyAR4PsgConfig.CONFIG_DEFAULT);
// set the delay after which a lost marker is no longer displayed. by default set to something higher, but here manually set to immediate.
//nya.setLostDelay(1);
nya.addARMarker(“4x4_1.patt”, 80); //your have to print out the cooresponding pdf file and put the .patt files in data folder
nya.addARMarker(“4x4_2.patt”, 80);
}
void draw() {

background(0); // a background call is needed for correct display of the marker results

cam.read();
image(cam, 0, 0, width, height); // display the image at the width and height of the sketch window
nya.detect(cam); // detect markers in the input image at the correct resolution (incorrect resolution will give assertion error)
if (nya.isExistMarker(0)) {
setMatrix(nya.getMarkerMatrix(0)); //use this marker to translate and rotate the processing drawing
//translate(0, 0, 25); //offset half the size of the cube.
scale(1,-1);
image(basketball, 0, 0, 100, 100);
//fill(255, 0, 0);
// box(200,200,1);
}
//perspective();
if (nya.isExistMarker(1)) {
setMatrix(nya.getMarkerMatrix(1));
scale(1,-1);
//translate(0, 0, 25);
image(hoop, 0, 0, 150, 150);
//fill(0, 255, 0);
//box(50);
}
}

 

Comments are closed.