ar_param.loadARParamFromFile(PARAM_FILE);
ar_param.changeScreenSize(320, 240);
this._raster = new JmfNyARRaster_RGB(320, 240,this._capture.getCaptureFormat());
- this._detect=new NyARSquareContourDetector_Rle(ar_param.getDistortionFactor(),ar_param.getScreenSize());
+ this._detect=new NyARSquareContourDetector_Rle(ar_param.getScreenSize());
this._filter = new NyARRasterFilter_ARToolkitThreshold(110, _raster.getBufferType());
//キャプチャイメージ用のラスタを準備
return;
\r
private Animator _animator;\r
\r
- private GLNyARRaster_RGB _cap_image;\r
+ private JmfNyARRaster_RGB _cap_image;\r
\r
private JmfCaptureDevice _capture;\r
\r
throw new NyARException();\r
}\r
this._capture.setOnCapture(this);\r
- // GL対応のRGBラスタオブジェクト\r
- this._cap_image = new GLNyARRaster_RGB(this._ar_param, this._capture.getCaptureFormat());\r
+ //JMFラスタオブジェクト\r
+ this._cap_image = new JmfNyARRaster_RGB(this._ar_param, this._capture.getCaptureFormat());\r
\r
// NyARToolkitの準備\r
this._nya = new NyARSingleDetectMarker(this._ar_param, i_ar_code, 80.0,this._cap_image.getBufferType());\r
}\r
// 背景を書く\r
this._gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.\r
- this._glnya.drawBackGround(this._cap_image, 1.0); \r
try{\r
synchronized(this._sync_object){\r
+ this._glnya.drawBackGround(this._cap_image, 1.0); \r
// マーカーがあれば、立方体を描画\r
if (this._is_marker_exist){\r
// マーカーの一致度を調査するならば、ここでnya.getConfidence()で一致度を調べて下さい。\r
\r
private Animator _animator;\r
\r
- private GLNyARRaster_RGB _cap_image;\r
+ private JmfNyARRaster_RGB _cap_image;\r
\r
private JmfCaptureDevice _capture;\r
\r
ar_codes[0].loadARPattFromFile(CARCODE_FILE1);\r
ar_codes[1] = new NyARCode(16, 16);\r
ar_codes[1].loadARPattFromFile(CARCODE_FILE2);\r
- //GL対応のRGBラスタオブジェクト\r
- this._cap_image = new GLNyARRaster_RGB(this._ar_param,_capture.getCaptureFormat());\r
+ //JMFラスタオブジェクト\r
+ this._cap_image = new JmfNyARRaster_RGB(this._ar_param,_capture.getCaptureFormat());\r
\r
this._nya = new NyARDetectMarker(this._ar_param, ar_codes, width, 2,this._cap_image.getBufferType());\r
this._nya.setContinueMode(false);//ここをtrueにすると、transMatContinueモード(History計算)になります。\r
\r
\r
private Animator _animator;\r
- private GLNyARRaster_RGB _cap_image;\r
+ private JmfNyARRaster_RGB _cap_image;\r
private JmfCaptureDevice _capture;\r
\r
private GL _gl;\r
throw new NyARException();\r
}\r
this._capture.setOnCapture(this);\r
- this._cap_image = new GLNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat()); \r
+ this._cap_image = new JmfNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat()); \r
\r
this._code_table[0]=new NyARCode(16,16);\r
this._code_table[0].loadARPattFromFile(CARCODE_FILE1);\r
}\r
// 背景を書く\r
this._gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.\r
- this._glnya.drawBackGround(this._cap_image, 1.0);\r
//OnEnter,OnUpdateの間に、transmatに初回行列がストアされる実行されることを防ぎます。\r
- synchronized(this._sync_object)\r
- {\r
- if(this._processor.current_code<0){\r
- \r
- }else{\r
- try{\r
+ try{\r
+ this._glnya.drawBackGround(this._cap_image, 1.0);\r
+ synchronized(this._sync_object)\r
+ {\r
+ if(this._processor.current_code<0){\r
+ \r
+ }else{\r
// Projection transformation.\r
this._gl.glMatrixMode(GL.GL_PROJECTION);\r
this._gl.glLoadMatrixd(_camera_projection, 0);\r
this._panel.draw("MarkerId:"+this._processor.current_code,0.01f);\r
this._gl.glPopMatrix();\r
Thread.sleep(1);// タスク実行権限を一旦渡す\r
- }catch(Exception e){\r
- e.printStackTrace();\r
}\r
}\r
+ }catch(Exception e){\r
+ e.printStackTrace();\r
}\r
return;\r
\r
{\r
//アプリケーションフレームワークの初期化\r
super();\r
- initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),100,i_raster_format);\r
+ initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),100.0,i_raster_format);\r
this._glnya=i_glutil;\r
return;\r
}\r
public class SingleNyIdMarker implements GLEventListener, JmfCaptureListener\r
{\r
private Animator _animator;\r
- private GLNyARRaster_RGB _cap_image;\r
+ private JmfNyARRaster_RGB _cap_image;\r
private JmfCaptureDevice _capture;\r
\r
private GL _gl;\r
throw new NyARException();\r
}\r
this._capture.setOnCapture(this);\r
- this._cap_image = new GLNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat()); \r
+ this._cap_image = new JmfNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat()); \r
\r
//OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)\r
Frame frame = new Frame("Java simpleLite with NyARToolkit");\r
}\r
// 背景を書く\r
this._gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.\r
- this._glnya.drawBackGround(this._cap_image, 1.0); \r
- synchronized(this._sync_object)\r
- {\r
- if(this._processor.current_id<0){\r
- \r
- }else{\r
- try{\r
+ try{\r
+ this._glnya.drawBackGround(this._cap_image, 1.0); \r
+ synchronized(this._sync_object)\r
+ {\r
+ if(this._processor.current_id<0){\r
+ \r
+ }else{\r
// Projection transformation.\r
this._gl.glMatrixMode(GL.GL_PROJECTION);\r
this._gl.glLoadMatrixd(_camera_projection, 0);\r
this._panel.draw("MarkerId:"+this._processor.current_id,0.01f);\r
this._gl.glPopMatrix();\r
Thread.sleep(1);// タスク実行権限を一旦渡す\r
- }catch(Exception e){\r
- e.printStackTrace();\r
}\r
- }\r
- } \r
+ } \r
+ }catch(Exception e){\r
+ e.printStackTrace();\r
+ }\r
return;\r
\r
}\r
protected boolean _is_attached_buffer;\r
public NyARRGBRaster_BufferedImage(int i_width, int i_height,boolean i_is_alloc) throws NyARException\r
{\r
- super( new NyARIntSize(i_width,i_height),NyARBufferType.OBJECT_Java_BufferedImage);\r
+ super(i_width,i_height,NyARBufferType.OBJECT_Java_BufferedImage);\r
if(!initInstance(this._size,i_is_alloc)){\r
throw new NyARException();\r
}\r
}\r
public NyARRGBRaster_BufferedImage(int i_width, int i_height) throws NyARException\r
{\r
- super( new NyARIntSize(i_width,i_height),NyARBufferType.OBJECT_Java_BufferedImage);\r
+ super(i_width,i_height,NyARBufferType.OBJECT_Java_BufferedImage);\r
if(!initInstance(this._size,true)){\r
throw new NyARException();\r
}\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
-import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-\r
+import jp.nyatla.nyartoolkit.core.param.*;\r
\r
\r
\r
private JmfRGB24RasterHolder _holder;\r
protected NyARIntSize _size;\r
\r
+ public JmfNyARRaster_RGB(NyARParam i_param,VideoFormat i_fmt) throws NyARException\r
+ {\r
+ initMember(i_param.getScreenSize().w,i_param.getScreenSize().h,i_fmt);\r
+ } \r
/**\r
* i_fmtに一致する画素フォーマットのRasterを作成します。\r
* このコンストラクタで作成したクラスは、hasBuffer()がfalseを返すことがあります。\r
+++ /dev/null
-/* \r
- * PROJECT: NyARToolkit JOGL utilities.\r
- * --------------------------------------------------------------------------------\r
- * This work is based on the original ARToolKit developed by\r
- * Hirokazu Kato\r
- * Mark Billinghurst\r
- * HITLab, University of Washington, Seattle\r
- * http://www.hitl.washington.edu/artoolkit/\r
- *\r
- * The NyARToolkit is Java edition ARToolKit class library.\r
- * Copyright (C)2008-2009 Ryo Iizuka\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- * \r
- * For further information please contact.\r
- * http://nyatla.jp/nyatoolkit/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- * \r
- */\r
-package jp.nyatla.nyartoolkit.jogl.utils;\r
-\r
-\r
-import javax.media.opengl.GL;\r
-\r
-import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.jmf.utils.*;\r
-import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
-import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.types.NyARBufferType;\r
-\r
-import javax.media.format.*;\r
-\r
-/**\r
- * NyARRaster_RGBにOpenGL用のデータ変換機能を追加したものです。\r
- */\r
-public class GLNyARRaster_RGB extends JmfNyARRaster_RGB\r
-{\r
- private int _gl_flag;\r
- /**\r
- * コンストラクタです。i_formatを取り込めるi_paramのサイズパラメタを持つ\r
- * ラスタオブジェクトを作成します。\r
- * @param i_param\r
- * カメラパラメタを指定します。コンストラクタは、画面サイズ以外のパラメタを見ていません。\r
- * @param i_format\r
- * キャプチャ画像のピクセルフォーマットを指定します。\r
- * @throws NyARException\r
- */\r
- public GLNyARRaster_RGB(NyARParam i_param,VideoFormat i_format) throws NyARException\r
- {\r
- super(i_param.getScreenSize(),i_format);\r
- initMember(this.getBufferType());\r
- return;\r
- }\r
- public GLNyARRaster_RGB(int i_width,int i_height,VideoFormat i_format) throws NyARException\r
- {\r
- super(i_width,i_height,i_format);\r
- initMember(this.getBufferType());\r
- return;\r
- } \r
- private void initMember(int i_buffer_type) throws NyARException\r
- {\r
- switch(i_buffer_type){\r
- case NyARBufferType.BYTE1D_B8G8R8_24:\r
- this._gl_flag = GL.GL_BGR;\r
- break;\r
- case NyARBufferType.BYTE1D_R8G8B8_24:\r
- this._gl_flag = GL.GL_RGB;\r
- break;\r
- default:\r
- throw new NyARException();\r
- }\r
- return;\r
- }\r
- /**\r
- * RGBバイト配列への参照値を返します。\r
- * バッファの並び順は、getGLPixelFlagが返すデータ順で格納されています。\r
- * @return\r
- * RGBバイト配列の参照値です。\r
- */\r
- public byte[] getGLRgbArray()\r
- {\r
- return (byte[])this.getBuffer();\r
- }\r
-\r
- /**\r
- * OpenGLの描画フラグを返します。\r
- * この値は、RGBバッファのバイト並びタイプです。\r
- * @return\r
- * GL.GL_BGR等の、RGBバイト配列の形式を表す値です。\r
- */\r
- public int getGLPixelFlag()\r
- {\r
- return this._gl_flag;\r
- }\r
-\r
-}\r
import javax.media.opengl.glu.GLU;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARMat;\r
+import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
import jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
this._gl = i_gl;\r
this._glu = new GLU();\r
}\r
-\r
+ /**\r
+ * ラスタのGLタイプを取得する。\r
+ * @param i_buffer_type\r
+ * @return\r
+ * @throws NyARException\r
+ */\r
+ final static private int getGlPixelFormat(int i_buffer_type) throws NyARException\r
+ {\r
+ switch(i_buffer_type){\r
+ case NyARBufferType.BYTE1D_B8G8R8_24:\r
+ return GL.GL_BGR;\r
+ case NyARBufferType.BYTE1D_R8G8B8_24:\r
+ return GL.GL_RGB;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ \r
/**\r
* GLNyARRaster_RGBをバックグラウンドに書き出す。\r
* @param image\r
* @param zoom\r
*/\r
- public void drawBackGround(GLNyARRaster_RGB i_raster, double i_zoom)\r
+ public void drawBackGround(INyARRgbRaster i_raster, double i_zoom) throws NyARException\r
{\r
IntBuffer texEnvModeSave = IntBuffer.allocate(1);\r
boolean lightingSave;\r
* @param image\r
* @param zoom\r
*/\r
- private void arglDispImageStateful(GLNyARRaster_RGB i_raster, double zoom)\r
+ private void arglDispImageStateful(INyARRgbRaster i_raster, double zoom) throws NyARException\r
{\r
javax.media.opengl.GL gl_ = this._gl;\r
final NyARIntSize rsize = i_raster.getSize();\r
gl_.glPixelZoom(zoomf * ((float) (params.get(2)) / (float) rsize.w), -zoomf * ((float) (params.get(3)) / (float) rsize.h));\r
gl_.glWindowPos2f(0.0f, (float) rsize.h);\r
gl_.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);\r
- ByteBuffer buf = ByteBuffer.wrap(i_raster.getGLRgbArray());\r
- gl_.glDrawPixels(rsize.w,rsize.h, i_raster.getGLPixelFlag(), GL.GL_UNSIGNED_BYTE, buf);\r
+ ByteBuffer buf = ByteBuffer.wrap((byte[])i_raster.getBuffer());\r
+ gl_.glDrawPixels(rsize.w,rsize.h,getGlPixelFormat(i_raster.getBufferType()), GL.GL_UNSIGNED_BYTE, buf);\r
}\r
\r
private double view_scale_factor = 0.025;\r
\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
this._buffer=(byte[])i_ref_buf;\r
this._reader.switchBuffer(i_ref_buf);\r
}\r
- /**\r
- * @deprecated hasBuffer()関数を使ってください。\r
- * \r
- */\r
- final public boolean hasData()\r
- {\r
- return this.hasBuffer();\r
- }\r
}\r
this.table_operator.updateMarker(item,sq);\r
}\r
}\r
+ /**\r
+ * 基準頂点i_baseと新規矩形情報i_sqを比較して、i_sqの適切なdirection値を計算する。\r
+ * (運動量で計算したら?)\r
+ * @param i_base_vertex\r
+ * @param i_base_center\r
+ * @param i_sq\r
+ * @param i_sqcenter\r
+ * @return\r
+ */\r
private int getNearVertexIndex(NyARDoublePoint2d i_base_vertex,NyARDoublePoint2d i_base_center,NyARIntPoint2d[] i_sq,NyARDoublePoint2d i_sqcenter)\r
{\r
double bx,by;\r
//観察座標の中央位置からのベクトル\r
- bx=i_base_vertex.x-i_sqcenter.x;\r
- by=i_base_vertex.y-i_sqcenter.y;\r
+ bx=i_base_vertex.x;\r
+ by=i_base_vertex.y;\r
\r
//一番近い頂点を探す.\r
- double d=NyARMath.sqNorm(bx,by,i_sq[3].x-i_sqcenter.x,i_sq[3].y-i_sqcenter.y);\r
+ double d=NyARMath.sqNorm(bx,by,i_sq[3].x,i_sq[3].y);\r
int ret=3;\r
for(int i=2;i>=0;i--)\r
{\r
//予測座標の中央位置からのベクトルの長さを計算\r
- double d2=NyARMath.sqNorm(bx,by,i_sq[i].x-i_sqcenter.x,i_sq[i].y-i_sqcenter.y);\r
+ double d2=NyARMath.sqNorm(bx,by,i_sq[i].x,i_sq[i].y);\r
if(d2<d){\r
d=d2;\r
ret=i;\r
import jp.nyatla.nyartoolkit.core.transmat.NyARTransMat;\r
import jp.nyatla.nyartoolkit.jmf.utils.JmfCaptureDevice;\r
import jp.nyatla.nyartoolkit.jmf.utils.JmfCaptureDeviceList;\r
-import jp.nyatla.nyartoolkit.jmf.utils.JmfCaptureListener;\r
-import jp.nyatla.nyartoolkit.jogl.utils.GLNyARRaster_RGB;\r
+import jp.nyatla.nyartoolkit.jmf.utils.*;\r
import jp.nyatla.nyartoolkit.utils.j2se.NyARRasterImageIO;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
super();\r
initInstance(\r
new NyARColorPatt_Perspective_O2(i_code.getWidth(), i_code.getHeight(),4,25),\r
- new NyARSquareContourDetector_Rle(i_param.getDistortionFactor(),i_param.getScreenSize()),\r
+ new NyARSquareContourDetector_Rle(i_param.getScreenSize()),\r
new NyARTransMat(i_param),\r
new NyARRasterFilter_ARToolkitThreshold(120,i_input_raster_type),\r
i_param,\r
\r
private JmfCaptureDevice _capture;\r
\r
- private GLNyARRaster_RGB _capraster;\r
+ private JmfNyARRaster_RGB _capraster;\r
\r
private int W = 320;\r
\r
\r
NyARCode code = new NyARCode(16, 16);\r
code.loadARPattFromFile(CARCODE_FILE);\r
- this._capraster = new GLNyARRaster_RGB(ar_param, this._capture.getCaptureFormat());\r
+ this._capraster = new JmfNyARRaster_RGB(ar_param, this._capture.getCaptureFormat());\r
this._capture.setOnCapture(this);\r
\r
addMouseMotionListener(this);\r
\r
\r
\r
- public void draw(GLNyARRaster_RGB i_raster)\r
+ public void draw(JmfNyARRaster_RGB i_raster)\r
{\r
try {\r
Insets ins = this.getInsets();\r