{"id":670,"date":"2012-05-30T16:53:39","date_gmt":"2012-05-30T07:53:39","guid":{"rendered":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/?p=670"},"modified":"2015-09-13T21:46:01","modified_gmt":"2015-09-13T12:46:01","slug":"nyartoolkit-for-android-4-0-3-released","status":"publish","type":"post","link":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/?p=670","title":{"rendered":"NyARToolkit for Android 4.0.3 released"},"content":{"rendered":"<p>NyARToolkit for Android 4.0.3\u306e\u30ea\u30ea\u30fc\u30b9\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/sourceforge.jp\/projects\/nyartoolkit-and\/releases\/?package_id=12943\">http:\/\/sourceforge.jp\/projects\/nyartoolkit-and\/releases\/?package_id=12943<\/a><\/p>\n<h2>\u66f4\u65b0\u5185\u5bb9<\/h2>\n<p>\u66f4\u65b0\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u57fa\u672c\u30e9\u30a4\u30d6\u30e9\u30ea\u3092NyARToolkit4.0.3\u3078\u66f4\u65b0<\/li>\n<li>\u753b\u51e6\u7406\u7cfb\u306e\u66f4\u65b0\u3002YUV\u3001Bitmap\u5f62\u5f0f\u753b\u50cf\u3078\u306e\u5bfe\u5fdc<\/li>\n<li>Android\u56fa\u6709\u306e\u9ad8\u901f\u5316<\/li>\n<li>Processing\u306e\u30b9\u30b1\u30c3\u30c1\u30e9\u30a4\u30af\u306aActivity\u306e\u8ffd\u52a0<\/li>\n<\/ul>\n<p>\u753b\u51e6\u7406\u7cfb\u306e\u6700\u9069\u5316\u306b\u3088\u308a\u3001\u4ee5\u524d\u306e\u3082\u306e\u3088\u308a5-10\u500d\u307b\u3069\u901f\u5ea6\u304c\u5411\u4e0a\u3057\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u30b9\u30b1\u30c3\u30c1\u30b7\u30b9\u30c6\u30e0\u306e\u63a1\u7528\u306b\u3088\u308a\u3001\u7c21\u5358\u306b\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n<p>\u7acb\u65b9\u4f53\u3092\u8868\u793a\u3059\u308bSimpleLite\u306e\u3001\u30b9\u30b1\u30c3\u30c1\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\u4f8b\u3067\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\npackage jp.nyatla.nyartoolkit.and;\r\n\r\nimport javax.microedition.khronos.opengles.GL10;\r\n\r\nimport jp.androidgroup.nyartoolkit.R;\r\nimport jp.androidgroup.nyartoolkit.markersystem.NyARAndMarkerSystem;\r\nimport jp.androidgroup.nyartoolkit.markersystem.NyARAndSensor;\r\nimport jp.androidgroup.nyartoolkit.sketch.AndSketch;\r\nimport jp.androidgroup.nyartoolkit.utils.camera.CameraPreview;\r\nimport jp.androidgroup.nyartoolkit.utils.gl.*;\r\nimport jp.nyatla.nyartoolkit.markersystem.NyARMarkerSystemConfig;\r\nimport android.content.res.AssetManager;\r\nimport android.hardware.Camera;\r\nimport android.view.ViewGroup.LayoutParams;\r\nimport android.widget.FrameLayout;\r\n\r\n\/**\r\n * Hiro\u30de\u30fc\u30ab\u306e\u4e0a\u306b\u30ab\u30e9\u30fc\u30ad\u30e5\u30fc\u30d6\u3092\u8868\u793a\u3057\u307e\u3059\u3002\r\n * \u5b9a\u756a\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002\r\n *\r\n *\/\r\npublic class SimpleLiteActivity extends AndSketch implements AndGLView.IGLFunctionEvent\r\n{\r\n  CameraPreview _camera_preview;\r\n  AndGLView _glv;\r\n  Camera.Size _cap_size;\r\n  \/**\r\n   * onStart\u3067\u306f\u3001View\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n   *\/\r\n  @Override\r\n  public void onStart()\r\n  {\r\n    super.onStart();\r\n    FrameLayout fr=((FrameLayout)this.findViewById(R.id.sketchLayout));\r\n    \/\/\u30ab\u30e1\u30e9\u306e\u53d6\u5f97\r\n    this._camera_preview=new CameraPreview(this);\r\n    this._cap_size=this._camera_preview.getRecommendPreviewSize(320,240);\r\n    \/\/\u753b\u9762\u30b5\u30a4\u30ba\u306e\u8a08\u7b97\r\n    int h = this.getWindowManager().getDefaultDisplay().getHeight();\r\n    int screen_w,screen_h;\r\n    screen_w=(this._cap_size.width*h\/this._cap_size.height);\r\n    screen_h=h;\r\n    \/\/camera\r\n    fr.addView(this._camera_preview, 0, new LayoutParams(screen_w,screen_h));\r\n    \/\/GLview\r\n    this._glv=new AndGLView(this);\r\n    fr.addView(this._glv, 0,new LayoutParams(screen_w,screen_h));\r\n  }\r\n\r\n  NyARAndSensor _ss;\r\n  NyARAndMarkerSystem _ms;\r\n  private int _mid;\r\n  AndGLTextLabel text;\r\n  AndGLBox box;\r\n  AndGLFpsLabel fps;\r\n\r\n  public void setupGL(GL10 gl)\r\n  {\r\n    try\r\n    {\r\n      AssetManager assetMng = getResources().getAssets();\r\n      \/\/create sensor controller.\r\n      this._ss=new NyARAndSensor(this._camera_preview,this._cap_size.width,this._cap_size.height,30);\r\n      \/\/create marker system\r\n      this._ms=new NyARAndMarkerSystem(new NyARMarkerSystemConfig(this._cap_size.width,this._cap_size.height));\r\n      this._mid=this._ms.addARMarker(assetMng.open(&quot;AR\/data\/hiro.pat&quot;),16,25,80);\r\n      this._ss.start();\r\n      \/\/setup openGL Camera Frustum\r\n      gl.glMatrixMode(GL10.GL_PROJECTION);\r\n      gl.glLoadMatrixf(this._ms.getGlProjectionMatrix(),0);\r\n      this.text=new AndGLTextLabel(this._glv);\r\n      this.box=new AndGLBox(this._glv,40);\r\n      this._debug=new AndGLDebugDump(this._glv);\r\n      this.fps=new AndGLFpsLabel(this._glv,&quot;MarkerPlaneActivity&quot;);\r\n      this.fps.prefix=this._cap_size.width+&quot;x&quot;+this._cap_size.height+&quot;:&quot;;\r\n\r\n    } catch (Exception e) {\r\n      \/\/ TODO Auto-generated catch block\r\n      e.printStackTrace();\r\n      this.finish();\r\n    }\r\n  }\r\n  AndGLDebugDump _debug=null;\r\n\r\n  public void drawGL(GL10 gl)\r\n  {\r\n    try{\r\n      \/\/\u80cc\u666f\u5857\u308a\u6f70\u3057\u8272\u306e\u6307\u5b9a\r\n      gl.glClearColor(0,0,0,0);\r\n          \/\/\u80cc\u666f\u5857\u308a\u6f70\u3057\r\n          gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH_BUFFER_BIT);\r\n          if(ex!=null){\r\n            _debug.draw(ex);\r\n            return;\r\n          }\r\n          fps.draw(0, 0);\r\n      synchronized(this._ss){\r\n        this._ms.update(this._ss);\r\n        if(this._ms.isExistMarker(this._mid)){\r\n              this.text.draw(&quot;found&quot;+this._ms.getConfidence(this._mid),0,16);\r\n          gl.glMatrixMode(GL10.GL_MODELVIEW);\r\n          gl.glLoadMatrixf(this._ms.getGlMarkerMatrix(this._mid),0);\r\n          this.box.draw(0,0,20);\r\n        }\r\n    }\r\n    }catch(Exception e)\r\n    {\r\n      ex=e;\r\n    }\r\n  }\r\n  Exception ex=null;\r\n}\r\n\r\n<\/pre>\n<p>AndSketch\u306f\u3001\u30b9\u30b1\u30c3\u30c1\u30b7\u30b9\u30c6\u30e0\u306e\u30d9\u30fc\u30b9\u30af\u30e9\u30b9\u3067\u3059\u3002Activity\u3092\u7d99\u627f\u3057\u3066\u3044\u307e\u3059\u3002\u95a2\u6570\u306f\u3001OnStart,setupGL,drawGL\u306e\uff13\u3064\u3067\u3059\u3002<\/p>\n<ol>\n<li>OnStart &#8211; Activity\u306eOnStart\u3092\u30aa\u30fc\u30d0\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u30ec\u30a4\u30a2\u30a6\u30c8\u3068\u3001\u30d3\u30e5\u30fc\u3092\u69cb\u7bc9\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<li>setupGL &#8211; OpenGL\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u3092\u66f8\u304d\u307e\u3059\u3002text,box,debug\u306f\u305d\u308c\u305e\u308c\u3001OpenGL\u5411\u3051\u306e\u63cf\u753b\u30af\u30e9\u30b9\u3067\u3059\u3002<\/li>\n<li>drawGL &#8211; OpenGL\u306e\u63cf\u753b\u51e6\u7406\u3092\u66f8\u304d\u307e\u3059\u3002 synchronized\u306e\u5834\u6240\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u975e\u540c\u671f\u306b\u66f4\u65b0\u3055\u308c\u308bNyARAndSensor\u3068\u540c\u671f\u3092\u53d6\u308b\u70ba\u306b\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u304d\u306fsynchronized\u304c\u5fc5\u8981\u3067\u3059\u3002<\/li>\n<\/ol>\n<p>\u30b5\u30f3\u30d7\u30eb\u306e\u69cb\u9020\u306f\u3001\u4ed6\u306eNyAR\u30b7\u30ea\u30fc\u30ba\u306e\u30b9\u30b1\u30c3\u30c1\u30b7\u30b9\u30c6\u30e0\u3068\u307b\u307c\u540c\u3058\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NyARToolkit for Android 4.0.3\u306e\u30ea\u30ea\u30fc\u30b9\u3057\u307e\u3059\u3002 http:\/\/sourceforge.jp\/projects\/nyartoolkit-and\/releases\/?package_id=129 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,13],"tags":[],"_links":{"self":[{"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts\/670"}],"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=670"}],"version-history":[{"count":3,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":1609,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions\/1609"}],"wp:attachment":[{"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nyatla.jp\/nyartoolkit\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}