{"id":473,"date":"2012-02-09T14:55:15","date_gmt":"2012-02-09T05:55:15","guid":{"rendered":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/?p=473"},"modified":"2012-02-09T22:01:59","modified_gmt":"2012-02-09T13:01:59","slug":"nyartoolkitv4%e3%81%af%e3%81%9f%e3%81%b6%e3%82%93%e3%81%93%e3%81%86%e3%81%aa%e3%82%8a%e3%81%be%e3%81%99%e3%80%82","status":"publish","type":"post","link":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/?p=473","title":{"rendered":"NyARToolkitV4\u306f\u305f\u3076\u3093\u3053\u3046\u306a\u308a\u307e\u3059\u3002"},"content":{"rendered":"<p>NyARToolkitV4\u3092\u4f5c\u3063\u3066\u307e\u3059\u3002<\/p>\n<p>processing\u7248\u3067\u5c0e\u5165\u3057\u305fAPI\u304c\u597d\u8a55\u3060\u3063\u305f\u306e\u3067\u3001\u540c\u3058\u3088\u3046\u306b\u4f7f\u3046\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3067\u8907\u6570\u306e\u30de\u30fc\u30ab\u304c\u8a8d\u8b58\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\uff08\u306f\u305a\uff09\u3067\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.nyatla.nyartoolkit.jogl.sample.sketch;\r\n\r\nimport javax.media.opengl.*;\r\nimport jp.nyatla.nyartoolkit.*;\r\nimport jp.nyatla.nyartoolkit.core.param.*;\r\nimport jp.nyatla.nyartoolkit.jmf.utils.*;\r\nimport jp.nyatla.nyartoolkit.jogl.sample.NyARGlMarkerSystem;\r\nimport jp.nyatla.nyartoolkit.jogl.utils.*;\r\n\r\n\r\n\r\n\/**\r\n * JMF\u304b\u3089\u306e\u6620\u50cf\u5165\u529b\u304b\u3089\u30de\u30fc\u30ab2\u7a2e\u3092\u691c\u51fa\u3057\u3001\u305d\u3053\u306b\u7acb\u65b9\u4f53\u3092\u91cd\u306d\u307e\u3059\u3002\r\n * AR\u30de\u30fc\u30ab\u306b\u306f\u3001patt.hiro\/patt.kanji\u3092\u4f7f\u7528\u3057\u3066\u4e0b\u3055\u3044\u3002\r\n *\/\r\npublic class SimpleLite extends GlSketch\r\n{\r\n  private NyARJmfCamera camera;\r\n  private NyARGlMarkerSystem nyar;\r\n  public void setup(GL gl)throws NyARException\r\n  {\r\n    this.size(640,480);\r\n    NyARParam param=new NyARParam();\r\n    param.loadDefaultParameter();\r\n    param.changeScreenSize(640,480);\r\n    this.camera=new NyARJmfCamera(param,30.0f);\/\/create sensor system\r\n    this.nyar=new NyARGlMarkerSystem(param);   \/\/create MarkerSystem\r\n    this.ids&#x5B;0]=this.nyar.addARMarker(ARCODE_FILE2,16,25,80);\r\n    this.ids&#x5B;1]=this.nyar.addARMarker(ARCODE_FILE,16,25,80);\r\n    gl.glMatrixMode(GL.GL_PROJECTION);\r\n    gl.glLoadMatrixd(this.nyar.getGlProjectionMatrix(),0);\r\n    gl.glEnable(GL.GL_DEPTH_TEST);\r\n    this.camera.start();\r\n  }\r\n  private final static String ARCODE_FILE = &quot;..\/..\/Data\/patt.hiro&quot;;\r\n  private final static String ARCODE_FILE2 = &quot;..\/..\/Data\/patt.kanji&quot;;\r\n  private int&#x5B;] ids=new int&#x5B;2];\r\n  \r\n  public void draw(GL gl)\r\n  {\r\n    synchronized(this.camera){\r\n      try {\r\n        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); \/\/ Clear the buffers for new frame.\r\n        NyARGLDrawUtil.drawBackGround(gl,this.camera.getSourceImage(), 1.0);        \r\n        this.nyar.update(this.camera);\r\n        if(this.nyar.isExistMarker(this.ids&#x5B;0])){\r\n          gl.glMatrixMode(GL.GL_MODELVIEW);\r\n          gl.glPushMatrix();\r\n          gl.glLoadMatrixd(this.nyar.getGlMarkerTransMat(this.ids&#x5B;0]),0);\r\n          NyARGLDrawUtil.drawColorCube(gl,40);\r\n          gl.glPopMatrix();\r\n        }\r\n        if(this.nyar.isExistMarker(this.ids&#x5B;1])){\r\n          gl.glMatrixMode(GL.GL_MODELVIEW);\r\n          gl.glPushMatrix();\r\n          gl.glLoadMatrixd(this.nyar.getGlMarkerTransMat(this.ids&#x5B;1]),0);\r\n          NyARGLDrawUtil.drawColorCube(gl,40);\r\n          gl.glPopMatrix();\r\n        }\r\n        Thread.sleep(1);\r\n      } catch (Exception e) {\r\n        e.printStackTrace();\r\n      }\r\n    }\r\n  }  \r\n  public static void main(String&#x5B;] args)\r\n  {\r\n    try {\r\n      new SimpleLite();\r\n    } catch (Exception e) {\r\n      e.printStackTrace();\r\n    }\r\n    return;\r\n  }\r\n}\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NyARToolkitV4\u3092\u4f5c\u3063\u3066\u307e\u3059\u3002 processing\u7248\u3067\u5c0e\u5165\u3057\u305fAPI\u304c\u597d\u8a55\u3060\u3063\u305f\u306e\u3067\u3001\u540c\u3058\u3088\u3046\u306b\u4f7f\u3046\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3092\u5b9f\u88c5\u3057\u3066\u3044\u307e\u3059\u3002 \u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3067\u8907\u6570\u306e\u30de\u30fc\u30ab\u304c\u8a8d\u8b58\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\uff08\u306f\u305a\uff09\u3067\u3059\u3002 pac [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts\/473"}],"collection":[{"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=473"}],"version-history":[{"count":2,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":475,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts\/473\/revisions\/475"}],"wp:attachment":[{"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}