• R/O
  • HTTP
  • SSH
  • HTTPS

nyartoolkit-and: Commit

NyARToolkit for Android v2.x, 3.x mainline.

master: NyARToolkit core.
android-1.6: for Android 1.6. obsolete version.
android-2.2: for Android 2.2. current version.


Commit MetaInfo

Revisionbe72a53b6273675e0941a1b8e52d651cd52c3d7d (tree)
Time2012-05-26 00:54:23
Authornyatla <nyatla@user...>
Commiternyatla

Log Message

backup

Change Summary

Incremental Difference

--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/markersystem/NyARAndMarkerSystem.java
+++ b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/markersystem/NyARAndMarkerSystem.java
@@ -1,6 +1,7 @@
11 package jp.androidgroup.nyartoolkit.markersystem;
22
33 import jp.nyatla.nyartoolkit.core.NyARException;
4+import jp.nyatla.nyartoolkit.jogl.utils.NyARGLUtil;
45 import jp.nyatla.nyartoolkit.markersystem.INyARMarkerSystemConfig;
56 import jp.nyatla.nyartoolkit.markersystem.NyARMarkerSystem;
67
@@ -11,5 +12,47 @@ public class NyARAndMarkerSystem extends NyARMarkerSystem
1112 throws NyARException {
1213 super(i_config);
1314 }
15+ private float[] _projection_mat;
16+ protected void initInstance(INyARMarkerSystemConfig i_config) throws NyARException
17+ {
18+ super.initInstance(i_config);
19+ this._projection_mat=new float[16];
20+ }
1421
22+ /**
23+ * OpenGLスタイルのProjectionMatrixを返します。
24+ * @param i_gl
25+ * @return
26+ * [readonly]
27+ */
28+ public float[] getGlProjectionMatrix()
29+ {
30+ return this._projection_mat;
31+ }
32+ public void setProjectionMatrixClipping(double i_near,double i_far)
33+ {
34+ super.setProjectionMatrixClipping(i_near,i_far);
35+ NyARGLUtil.toCameraFrustumRH(this._ref_param,1,i_near,i_far,this._projection_mat);
36+ }
37+ /**
38+ * この関数は、i_bufに指定idのOpenGL形式の姿勢変換行列を設定して返します。
39+ * @param i_id
40+ * @param i_buf
41+ * @return
42+ */
43+ public void getMarkerMatrix(int i_id,float[] i_buf)
44+ {
45+ NyARGLUtil.toCameraViewRH(this.getMarkerMatrix(i_id),1,i_buf);
46+ }
47+ /**
48+ * この関数はOpenGL形式の姿勢変換行列を新規に割り当てて返します。
49+ * @param i_buf
50+ * @return
51+ */
52+ public float[] getGlMarkerMatrix(int i_id)
53+ {
54+ float[] b=new float[16];
55+ this.getMarkerMatrix(i_id,b);
56+ return b;
57+ }
1558 }
--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/markersystem/NyARAndSensor.java
+++ b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/markersystem/NyARAndSensor.java
@@ -2,14 +2,13 @@ package jp.androidgroup.nyartoolkit.markersystem;
22
33 import java.io.IOException;
44
5-import jp.androidgroup.nyartoolkit.utils.CameraPreview;
65 import jp.androidgroup.nyartoolkit.utils.NyARAndYUV420GsRaster;
76 import jp.androidgroup.nyartoolkit.utils.NyARAndYUV420RgbRaster;
7+import jp.androidgroup.nyartoolkit.utils.camera.CameraPreview;
88 import jp.nyatla.nyartoolkit.core.NyARException;
99 import jp.nyatla.nyartoolkit.core.raster.INyARGrayscaleRaster;
1010 import jp.nyatla.nyartoolkit.core.types.NyARIntSize;
1111 import jp.nyatla.nyartoolkit.markersystem.NyARSensor;
12-import android.hardware.Camera;
1312 /**
1413 * この関数は、非同期カメライベントをラップした{@see NyARSensor}です。
1514 * 画像取得APIにアクセスするときには、オブジェクトをsynchronizedしてください。
--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/sketch/AndSketch.java
+++ b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/sketch/AndSketch.java
@@ -2,31 +2,29 @@ package jp.androidgroup.nyartoolkit.sketch;
22
33 import java.util.ArrayList;
44
5-import javax.microedition.khronos.egl.EGLConfig;
6-import javax.microedition.khronos.opengles.GL10;
7-
85 import jp.androidgroup.nyartoolkit.R;
9-import jp.androidgroup.nyartoolkit.R.layout;
10-
116 import android.app.Activity;
127 import android.content.pm.ActivityInfo;
138 import android.graphics.PixelFormat;
14-import android.opengl.GLSurfaceView;
159 import android.os.Bundle;
1610 import android.util.Log;
17-import android.view.ViewGroup.LayoutParams;
1811 import android.view.Window;
1912 import android.view.WindowManager;
20-import android.widget.FrameLayout;
2113
2214 public class AndSketch extends Activity
2315 {
16+ public interface IAndSketchEventListerner
17+ {
18+ public void onAcResume();
19+ public void onAcPause();
20+ public void onAcDestroy() throws Exception;
21+ public void onAcStop() throws Exception;
22+ }
23+
2424 public ArrayList<IAndSketchEventListerner> _evlistener=new ArrayList<IAndSketchEventListerner>();
2525
2626
27- final static int AST_SETUP=0;
28- final static int AST_RUN =1;
29- int _ast=AST_SETUP;
27+
3028 public AndSketch()
3129 {
3230 }
@@ -34,10 +32,9 @@ public class AndSketch extends Activity
3432 @Override
3533 protected void onResume() {
3634 super.onResume();
37- this._glView.onResume();
3835 try {
3936 for(IAndSketchEventListerner i : this._evlistener) {
40- i.onResume();
37+ i.onAcResume();
4138 }
4239 } catch (Exception e) {
4340 e.printStackTrace();
@@ -46,52 +43,26 @@ public class AndSketch extends Activity
4643 }
4744 protected void onPause() {
4845 super.onPause();
49- this._glView.onPause();
5046 try {
51-// for(IAndSketchEventListerner i : this._evlistener) {
52-// i.onPause();
53-// }
47+ for(IAndSketchEventListerner i : this._evlistener) {
48+ i.onAcPause();
49+ }
5450 } catch (Exception e) {
5551 e.printStackTrace();
5652 }
57-
5853 }
59-
6054 @Override
6155 protected void onCreate(Bundle savedInstanceState)
6256 {
6357 Log.d(this.getClass().getName(), "onCreate");
64- this.setupDefaultActivity();
6558 super.onCreate(savedInstanceState);
59+ this.setupDefaultActivity();
6660 this.setContentView(R.layout.main);
67- this._ast=AST_RUN;
68- }
69- private int _frid=0xffffffff;
70- private int _sw;
71- private int _sh;
72- public void initView(int i_rid)
73- {
74- this.initView(i_rid,LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
75- }
76- public FrameLayout initView(int i_rid,int i_width,int i_height)
77- {
78- this._frid=i_rid;
79- this._sw=i_width;
80- this._sh=i_height;
81- // Create the GL view
82- return this._frame_layout;
8361 }
8462 @Override
8563 protected void onStart()
8664 {
8765 super.onStart();
88- this._frame_layout=((FrameLayout)this.findViewById(this._frid));
89- if(this._frame_layout==null){
90- Log.d(this.getClass().getName(), "Layout not found. Should call initView in constructor!");
91- finish();
92- }
93- this.setupDefaultView();
94- this._frame_layout.addView(this._glView, 0, new LayoutParams(this._sw,this._sh));
9566 return;
9667 }
9768 @Override
@@ -100,7 +71,7 @@ public class AndSketch extends Activity
10071 super.onStop();
10172 try {
10273 for(IAndSketchEventListerner i : this._evlistener) {
103- i.onStop();
74+ i.onAcStop();
10475 }
10576 } catch (Exception e) {
10677 e.printStackTrace();
@@ -111,18 +82,13 @@ public class AndSketch extends Activity
11182 super.onDestroy();
11283 try {
11384 for(IAndSketchEventListerner i : this._evlistener) {
114- i.onDestroy();
85+ i.onAcDestroy();
11586 }
11687 } catch (Exception e) {
11788 e.printStackTrace();
11889 }
11990 }
12091
121- /////////////////////
122- protected GLSurfaceView _glView;
123- private GLSurfaceView.Renderer _render;
124- private FrameLayout _frame_layout;
125-
12692 /**
12793 * onCreate関数からコールします。
12894 */
@@ -137,46 +103,9 @@ public class AndSketch extends Activity
137103 // 画面がスリープに入らないようにする
138104 this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
139105 // 横向き固定
140-// this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
141- }
142- /**
143- * onCreate関数からコールします。
144- */
145- protected void setupDefaultView()
146- {
147- this._glView=new GLSurfaceView(this);
148- this._glView.setEGLConfigChooser( 8, 8, 8, 8, 16, 0);
149- this._glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
150- this._render=new DefaultRenderer(this);
151- this._glView.setRenderer(this._render);
152- }
153-
154-
155-
156-
157-
158-
159-
160-//
161-// 関数ハンドラ
162-//
163-
164- public void setup(GL10 gl)
165- {
166- }
167- /**
168- * 継承したクラスで表示したいものを実装してください
169- * @param gl
170- */
171- public void draw(GL10 gl)
172- {
106+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
173107 }
174108
175- public void addListener(IAndSketchEventListerner i_evl) throws Exception
176- {
177- this._evlistener.add(i_evl);
178- i_evl.onStart();
179- }
180109 public void _finish(Exception e)
181110 {
182111 if(e!=null){
@@ -186,43 +115,3 @@ public class AndSketch extends Activity
186115 }
187116 }
188117
189-
190-
191-/**
192- * Single Marker Detector にのみ対応した OpenGL ES Renderer
193- * モデルデータの読み出しなどが含まれない、純粋にOpenGL ESで処理する場合の基本クラス。
194- * 継承したクラス内で何かしらの描画処理を行わないと何もしないので注意してください。
195- */
196-class DefaultRenderer implements GLSurfaceView.Renderer
197-{
198- private AndSketch _parent;
199- public DefaultRenderer(AndSketch i_parent)
200- {
201- this._parent=i_parent;
202- }
203- /**
204- * Logging Tag
205- */
206- @Override
207- public void onSurfaceCreated(GL10 gl, EGLConfig config)
208- {
209- // Transparent background
210- gl.glClearColor(0.5f, 0.0f, 0.0f, 0.f);
211- gl.glEnable(GL10.GL_DEPTH_TEST);
212- this._parent.setup(gl);
213- }
214-
215- @Override
216- public void onSurfaceChanged(GL10 gl, int width, int height)
217- {
218- for(IAndSketchEventListerner i : this._parent._evlistener) {
219- i.onGlChanged(gl,width,height);
220- }
221- gl.glViewport(0, 0, width, height);
222- }
223- @Override
224- public void onDrawFrame(GL10 gl)
225- {
226- this._parent.draw(gl);
227- }
228-}
--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/sketch/IAndSketchEventListerner.java
+++ /dev/null
@@ -1,11 +0,0 @@
1-package jp.androidgroup.nyartoolkit.sketch;
2-
3-import javax.microedition.khronos.opengles.GL10;
4-
5-public interface IAndSketchEventListerner {
6- public void onResume();
7- public void onStart() throws Exception;
8- public void onDestroy() throws Exception;
9- public void onStop() throws Exception;
10- public void onGlChanged(GL10 i_gl,int i_width,int i_height);
11-}
--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/NyARAndYUV420GsRaster.java
+++ b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/NyARAndYUV420GsRaster.java
@@ -7,7 +7,6 @@ import jp.nyatla.nyartoolkit.core.raster.INyARGrayscaleRaster;
77 import jp.nyatla.nyartoolkit.core.raster.INyARRaster;
88 import jp.nyatla.nyartoolkit.core.raster.NyARGrayscaleRaster;
99 import jp.nyatla.nyartoolkit.core.rasterdriver.INyARHistogramFromRaster;
10-import jp.nyatla.nyartoolkit.core.rasterdriver.NyARHistogramFromRasterFactory;
1110 import jp.nyatla.nyartoolkit.core.squaredetect.NyARContourPickup;
1211 import jp.nyatla.nyartoolkit.core.types.NyARBufferType;
1312 import jp.nyatla.nyartoolkit.core.types.NyARHistogram;
@@ -183,7 +182,8 @@ class NyARContourPickup_YUV420Reader extends NyARContourPickup_Base
183182 }
184183 if (i == 8) {
185184 //8方向全て調べたけどラベルが無いよ?
186- throw new NyARException();// return(-1);
185+ return false;
186+// throw new NyARException();// return(-1);
187187 }
188188 // xcoordとycoordをc,rにも保存
189189 c = c + xdir[dir];
--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/NyARAndYUV420RgbRaster.java
+++ b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/NyARAndYUV420RgbRaster.java
@@ -1,6 +1,5 @@
11 package jp.androidgroup.nyartoolkit.utils;
22
3-import android.util.Log;
43 import jp.nyatla.nyartoolkit.core.NyARException;
54 import jp.nyatla.nyartoolkit.core.pixeldriver.INyARGsPixelDriver;
65 import jp.nyatla.nyartoolkit.core.pixeldriver.INyARRgbPixelDriver;
@@ -12,6 +11,7 @@ import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRgb2GsFilter;
1211 import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRgb2GsFilterRgbAve;
1312 import jp.nyatla.nyartoolkit.core.types.NyARBufferType;
1413 import jp.nyatla.nyartoolkit.core.types.NyARIntSize;
14+import android.util.Log;
1515
1616
1717 /**
similarity index 87%
rename from NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/CameraPreview.java
rename to NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/camera/CameraPreview.java
index b24d55e5b2faef64f00e1a0be30dcff476b16325..4bf9fcb1d126d14f13637d9f01871f5a369bcaab 100644
--- a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/CameraPreview.java
+++ b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/camera/CameraPreview.java
@@ -32,17 +32,12 @@
3232 * Yasuhide Matsumoto
3333 * Fuu Rokubou
3434 */
35-package jp.androidgroup.nyartoolkit.utils;
35+package jp.androidgroup.nyartoolkit.utils.camera;
3636
3737 import java.io.IOException;
3838 import java.util.List;
3939
40-import javax.microedition.khronos.opengles.GL10;
41-
4240 import jp.androidgroup.nyartoolkit.sketch.AndSketch;
43-import jp.androidgroup.nyartoolkit.sketch.IAndSketchEventListerner;
44-
45-import android.content.Context;
4641 import android.graphics.ImageFormat;
4742 import android.hardware.Camera;
4843 import android.hardware.Camera.Size;
@@ -62,7 +57,7 @@ import android.view.SurfaceView;
6257 * @author nyatla
6358 *
6459 */
65-public class CameraPreview extends SurfaceView implements IAndSketchEventListerner,SurfaceHolder.Callback,Camera.PreviewCallback
60+public class CameraPreview extends SurfaceView implements AndSketch.IAndSketchEventListerner,SurfaceHolder.Callback,Camera.PreviewCallback
6661 {
6762 public interface IOnPreviewFrame
6863 {
@@ -75,14 +70,20 @@ public class CameraPreview extends SurfaceView implements IAndSketchEventListern
7570 private int _cap_index;
7671 private IOnPreviewFrame _callback;
7772 /**
73+ * Must call in onSetup
7874 * @param context
79- * @param attrs
8075 */
8176 public CameraPreview(AndSketch context)
8277 {
8378 super(context);
8479 try {
85- context.addListener(this);//called onStart by addlistener
80+ context._evlistener.add(this);
81+ this._camera_ref=Camera.open();
82+ if(this._is_enabled){
83+ this._camera_ref.setPreviewDisplay(this._holder);
84+ this._camera_ref.startPreview();
85+ }
86+
8687 this._holder = getHolder();
8788 this._holder.addCallback(this);
8889 this._holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
@@ -209,17 +210,7 @@ public class CameraPreview extends SurfaceView implements IAndSketchEventListern
209210 ((AndSketch)this.getContext())._finish(e);
210211 }
211212 }
212- @Override
213- public void onStart() throws Exception
214- {
215- this._camera_ref=Camera.open();
216- if(this._is_enabled){
217- this._camera_ref.setPreviewDisplay(this._holder);
218- this._camera_ref.startPreview();
219- }
220- }
221-
222- public synchronized void onStop() throws Exception
213+ public synchronized void onAcStop() throws Exception
223214 {
224215 if(this._camera_ref!=null){
225216 this._camera_ref.stopPreview();
@@ -230,20 +221,16 @@ public class CameraPreview extends SurfaceView implements IAndSketchEventListern
230221 }
231222 }
232223 @Override
233- public void onDestroy() throws Exception
224+ public void onAcDestroy() throws Exception
234225 {
235226 assert(this._camera_ref==null);
236227 }
237228 @Override
238- public void onResume()
229+ public void onAcResume()
239230 {
240- // TODO Auto-generated method stub
241-
242231 }
243232 @Override
244- public void onGlChanged(GL10 i_gl,int i_width,int i_height) {
245- // TODO Auto-generated method stub
246-
233+ public void onAcPause()
234+ {
247235 }
248-
249236 }
Show on old repository browser