2 * VFM+ARToolkitテストプログラム
3 * カメラから取り込んだデータからマーカーを検出して、一致度と変換行列を表示します。
5 * airmail(at)ebony.plala.or.jp
8 package jp.nyatla.nyartoolkit.qt.sample;
10 import jp.nyatla.nyartoolkit.NyARException;
11 import jp.nyatla.nyartoolkit.qt.utils.*;
15 import jp.nyatla.nyartoolkit.core.*;
16 import jp.nyatla.nyartoolkit.detector.*;
19 public class NyarToolkitLinkTest extends Frame implements QtCaptureListener
21 private final String CARCODE_FILE ="../../Data/patt.hiro";
22 private final String PARAM_FILE ="../../Data/camera_para.dat";
23 private QtCameraCapture capture;
24 private NyARSingleDetectMarker nya;
25 private QtNyARRaster_RGB raster;
26 private NyARTransMatResult trans_mat_result=new NyARTransMatResult();
28 public NyarToolkitLinkTest() throws NyARException,NyARException
30 setTitle("QtCaptureTest");
31 setBounds(0,0,320+64,240+64);
33 capture=new QtCameraCapture(320,240,30f);
34 capture.setCaptureListener(this);
37 NyARParam ar_param=new NyARParam();
38 NyARCode ar_code =new NyARCode(16,16);
39 ar_param.loadFromARFile(PARAM_FILE);
40 ar_param.changeSize(320,240);
41 nya=new NyARSingleDetectMarker(ar_param,ar_code,80.0);
42 ar_code.loadFromARFile(CARCODE_FILE);
44 raster=new QtNyARRaster_RGB(320,240);
49 public void onUpdateBuffer(byte[] pixels)
53 raster.setBuffer(pixels);
56 Image img= raster.createImage();
58 Graphics g = getGraphics();
62 boolean is_marker_exist=nya.detectMarkerLite(raster,100);
65 nya.getTransmationMatrix(this.trans_mat_result);
66 atm=this.trans_mat_result.getArray();
69 g.drawImage(img, 32, 32,this);
71 g.drawString("マーカー検出:"+nya.getConfidence(),32,50);
73 for(int i2=0;i2<4;i2++){
74 g.drawString("["+i+"]["+i2+"]"+atm[i][i2],32,50+(1+i2*3+i)*16);
79 g.drawString("マーカー未検出:",32,100);
89 private void startCapture()
97 public static void main(String[] args) {
99 NyarToolkitLinkTest mainwin = new NyarToolkitLinkTest();
100 mainwin.setVisible(true);
101 mainwin.startCapture();