phren0logy
YaBB Newbies
Offline
Posts: 11
Re: Ruby-Processing and NyARToolkit
Reply #2 - Mar 3rd , 2009, 4:26pm
Thanks, I was able to fix it using the live view. The issue, embarrassingly enough, was that I misspelled nyatla as nyalta. This means that a failure in the line: import "jp.nyalta.nyar4psg" passed silently, as far as I can tell. Is there some way to get feedback about a failed import? Edit: This works: ============================== require 'ruby-processing' class Artooltest < Processing::App load_library "video" load_library "opengl" load_library 'NyAR2' load_library 'NyARToolkit' include_package "processing.video" include_package "procesing.opengl" import 'jp.nyatla.nyar4psg' import "javax.media.opengl" puts "NyAR2 loaded" if library_loaded? :NyAR2 puts "NyARToolkit loaded" if library_loaded? :NyARToolkit def setup render_mode OPENGL frame_rate 15 @cam = Capture.new(self, width, height, 30) @nya = NyARBoard.new(self, width, height, "camera_para.dat", "patt.hiro", 80) @nya.gsThreshold=120 @nya.cfThreshold=0.4 image_mode CORNERS end def draw @cam.read if @cam.available image @cam, 0, 0 fill(220, 20, 20) @nya.detect(@cam) ? (puts "yup") : (puts "nope") (0..3).each do |num| ellipse(@nya.pos2d[num][0], @nya.pos2d[num][1], 20, 20) end end end Artooltest.new :title => "Artooltest", :width => 640, :height => 480 ================================== You need to have the camera_para.dat and patt.hiro files in the root folder of the sketch, and NyAR2.jar in library/NyART2/ and NyARToolkit in library/NyARToolkit. Now I'm trying to figure out how to do this part of the example pde sketch: PGraphicsOpenGL pgl = (PGraphicsOpenGL) g; nya.beginTransform(pgl); noFill(); stroke(255,200,0); translate(0,0,20); box(40); nya.endTransform(); PGraphicsOpenGL is apparently derived from PImage, but I'm having some trouble figuring out where it lives. I seems to make a new instance of a class, but I'm not sure what the "g" is all about.