import jp.nyatla.nyartoolkit.jmf.utils.*;
import java.awt.*;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import jp.nyatla.nyartoolkit.core.*;
import jp.nyatla.nyartoolkit.core.param.NyARParam;
setBounds(0, 0, 320 + 64, 240 + 64);
//キャプチャの準備
JmfCaptureDeviceList devlist=new JmfCaptureDeviceList();
- _capture=devlist.getDevice(0);
+ this._capture=devlist.getDevice(0);
//JmfNyARRaster_RGBはYUVよりもRGBで高速に動作します。
- if(!_capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_RGB,320, 240,15f)){
- if(!_capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_YUV,320, 240,15f)){
+ if(!this._capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_RGB,320, 240,15f)){
+ if(!this._capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_YUV,320, 240,15f)){
throw new NyARException("キャプチャフォーマットが見つかりません");
}
}
- _capture.setOnCapture(this);
-
+ this._capture.setOnCapture(this);
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e)
+ {
+ System.exit(0);
+ }
+ });
//NyARToolkitの準備
NyARParam ar_param = new NyARParam();
NyARCode ar_code = new NyARCode(16, 16);
ar_param.loadARParamFromFile(PARAM_FILE);
ar_param.changeScreenSize(320, 240);
- this._nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0);
+ this._raster = new JmfNyARRaster_RGB(320, 240,this._capture.getCaptureFormat());
+ this._nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0,this._raster.getBufferReader().getBufferType());
ar_code.loadARPattFromFile(CARCODE_FILE);
//キャプチャイメージ用のラスタを準備
- this._raster = new JmfNyARRaster_RGB(320, 240,_capture.getCaptureFormat());
return;
}
this._ar_param = i_param;\r
\r
Frame frame = new Frame("Java simpleLite with NyARToolkit");\r
- this._nya = new NyARSingleDetectMarker(this._ar_param, i_ar_code, 80.0);\r
\r
\r
// キャプチャの準備\r
throw new NyARException();\r
}\r
this._capture.setOnCapture(this);\r
- // NyARToolkitの準備\r
- this._nya.setContinueMode(true);// ここをtrueにすると、transMatContinueモード(History計算)になります。\r
// GL対応のRGBラスタオブジェクト\r
this._cap_image = new GLNyARRaster_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.getBufferReader().getBufferType());\r
+ this._nya.setContinueMode(true);// ここをtrueにすると、transMatContinueモード(History計算)になります。\r
\r
// 3Dを描画するコンポーネント\r
GLCanvas canvas = new GLCanvas();\r
ar_codes[0].loadARPattFromFile(CARCODE_FILE1);\r
ar_codes[1] = new NyARCode(16, 16);\r
ar_codes[1].loadARPattFromFile(CARCODE_FILE2);\r
- _nya = new NyARDetectMarker(_ar_param, ar_codes, width, 2);\r
- _nya.setContinueMode(false);//ここをtrueにすると、transMatContinueモード(History計算)になります。\r
- //NyARToolkit用の支援クラス\r
- _glnya = new NyARGLUtil(_gl);\r
//GL対応のRGBラスタオブジェクト\r
- _cap_image = new GLNyARRaster_RGB(_ar_param,_capture.getCaptureFormat());\r
+ this._cap_image = new GLNyARRaster_RGB(this._ar_param,_capture.getCaptureFormat());\r
+\r
+ this._nya = new NyARDetectMarker(this._ar_param, ar_codes, width, 2,this._cap_image.getBufferReader().getBufferType());\r
+ this._nya.setContinueMode(false);//ここをtrueにすると、transMatContinueモード(History計算)になります。\r
+ //NyARToolkit用の支援クラス\r
+ this._glnya = new NyARGLUtil(_gl);\r
//キャプチャ開始\r
- _capture.start();\r
+ this._capture.start();\r
} catch (Exception e) {\r
e.printStackTrace();\r
}\r
//カメラパラメータの計算\r
- _glnya.toCameraFrustumRH(_ar_param,_camera_projection);\r
+ this._glnya.toCameraFrustumRH(_ar_param,_camera_projection);\r
\r
- _animator = new Animator(drawable);\r
- _animator.start();\r
+ this._animator = new Animator(drawable);\r
+ this._animator.start();\r
\r
}\r
\r
--- /dev/null
+/* \r
+ * PROJECT: NyARToolkit JOGL sample program.\r
+ * --------------------------------------------------------------------------------\r
+ * The MIT License\r
+ * Copyright (c) 2008 nyatla\r
+ * airmail(at)ebony.plala.or.jp\r
+ * http://nyatla.jp/nyartoolkit/\r
+ * \r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy\r
+ * of this software and associated documentation files (the "Software"), to deal\r
+ * in the Software without restriction, including without limitation the rights\r
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+ * copies of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ * The above copyright notice and this permission notice shall be included in\r
+ * all copies or substantial portions of the Software.\r
+ * \r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+ * THE SOFTWARE.\r
+ * \r
+ */\r
+package jp.nyatla.nyartoolkit.jogl.sample;\r
+\r
+import jp.nyatla.nyartoolkit.nyidmarker.data.*;\r
+\r
+import java.awt.event.*;\r
+import java.awt.*;\r
+import java.util.Date;\r
+\r
+import javax.media.Buffer;\r
+import javax.media.opengl.*;\r
+\r
+import com.sun.opengl.util.*;\r
+import com.sun.opengl.util.j2d.*;\r
+import jp.nyatla.nyartoolkit.*;\r
+import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.core.param.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.transmat.*;\r
+import jp.nyatla.nyartoolkit.jmf.utils.*;\r
+import jp.nyatla.nyartoolkit.jogl.utils.*;\r
+import jp.nyatla.nyartoolkit.processor.*;\r
+\r
+/*\r
+\r
+\r
+*/\r
+\r
+\r
+public class SingleARMarker implements GLEventListener, JmfCaptureListener\r
+{\r
+ class TextPanel\r
+ {\r
+ private TextRenderer _tr;\r
+ public TextPanel(int i_size)\r
+ {\r
+ this._tr=new TextRenderer(new Font("SansSerif", Font.BOLD, 36));\r
+\r
+ }\r
+ public void draw(String i_str,float i_scale)\r
+ {\r
+ this._tr.begin3DRendering();\r
+ this._tr.setColor(1.0f, 0.2f, 0.2f, 0.8f);\r
+ this._tr.draw3D(i_str, 0f,0f,0f,i_scale);\r
+ this._tr.end3DRendering();\r
+ return;\r
+ }\r
+ } \r
+ /**\r
+ * 1個のRawBit-Idマーカを認識するロジッククラス。\r
+ * detectMarker関数の呼び出しに同期して、transmatとcurrent_idパラメタを更新します。\r
+ * \r
+ *\r
+ */\r
+ class MarkerProcessor extends SingleARMarkerProcesser\r
+ { \r
+ private Object _sync_object=new Object();\r
+ public NyARTransMatResult transmat=null;\r
+ public int current_code=-1;\r
+\r
+ public MarkerProcessor(NyARParam i_cparam,int i_raster_format) throws NyARException\r
+ {\r
+ //アプリケーションフレームワークの初期化\r
+ super();\r
+ initInstance(i_cparam,i_raster_format);\r
+ return;\r
+ }\r
+ protected void onEnterHandler(int i_code)\r
+ {\r
+ synchronized(this._sync_object){\r
+ current_code=i_code;\r
+ }\r
+ }\r
+ protected void onLeaveHandler()\r
+ {\r
+ synchronized(this._sync_object){\r
+ current_code=-1;\r
+ this.transmat=null;\r
+ }\r
+ return; \r
+ }\r
+\r
+ protected void onUpdateHandler(NyARSquare i_square, NyARTransMatResult result)\r
+ {\r
+ synchronized(this._sync_object){\r
+ this.transmat=result;\r
+ } \r
+ }\r
+ }\r
+ \r
+ private final String CARCODE_FILE1 = "../../Data/patt.hiro";\r
+ \r
+ \r
+ private Animator _animator;\r
+ private GLNyARRaster_RGB _cap_image;\r
+ private JmfCaptureDevice _capture;\r
+\r
+ private GL _gl;\r
+ private NyARGLUtil _glnya;\r
+ private TextPanel _panel;\r
+\r
+\r
+ //NyARToolkit関係\r
+ private NyARParam _ar_param;\r
+\r
+ private double[] _camera_projection=new double[16];\r
+ \r
+ private Object _sync_object=new Object();\r
+ private MarkerProcessor _processor;\r
+ private NyARCode[] _code_table=new NyARCode[1];\r
+\r
+ public SingleARMarker(NyARParam i_cparam) throws NyARException\r
+ {\r
+ JmfCaptureDeviceList devlist=new JmfCaptureDeviceList();\r
+ this._ar_param=i_cparam;\r
+\r
+ //キャプチャリソースの準備\r
+ this._capture=devlist.getDevice(0);\r
+ if(!this._capture.setCaptureFormat(SCREEN_X, SCREEN_Y,30.0f)){\r
+ throw new NyARException();\r
+ }\r
+ this._capture.setOnCapture(this);\r
+ this._cap_image = new GLNyARRaster_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
+ this._processor=new MarkerProcessor(i_cparam,this._cap_image.getBufferReader().getBufferType());\r
+ this._processor.setARCodeTable(_code_table,16,80.0);\r
+ \r
+ //OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)\r
+ Frame frame = new Frame("Java simpleLite with NyARToolkit");\r
+ GLCanvas canvas = new GLCanvas();\r
+ frame.add(canvas);\r
+ canvas.addGLEventListener(this);\r
+ frame.addWindowListener(new WindowAdapter() {\r
+ public void windowClosing(WindowEvent e)\r
+ {\r
+ System.exit(0);\r
+ }\r
+ });\r
+ \r
+ //ウインドウサイズの調整\r
+ frame.setVisible(true);\r
+ Insets ins = frame.getInsets();\r
+ frame.setSize(SCREEN_X + ins.left + ins.right, SCREEN_Y + ins.top + ins.bottom);\r
+ canvas.setBounds(ins.left, ins.top, SCREEN_X, SCREEN_Y);\r
+ return;\r
+ }\r
+ public void init(GLAutoDrawable drawable)\r
+ {\r
+ this._panel = new TextPanel(100);\r
+\r
+\r
+ this._gl = drawable.getGL();\r
+ this._gl.glEnable(GL.GL_DEPTH_TEST);\r
+\r
+ this._gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);\r
+ //NyARToolkitの準備\r
+ try {\r
+ this._glnya = new NyARGLUtil(this._gl);\r
+ //カメラパラメータの計算\r
+ this._glnya.toCameraFrustumRH(this._ar_param,this._camera_projection);\r
+ //キャプチャ開始\r
+ this._capture.start();\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ this._animator = new Animator(drawable);\r
+ this._animator.start();\r
+ return;\r
+ }\r
+\r
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)\r
+ {\r
+ \r
+ _gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);\r
+ _gl.glViewport(0, 0, width, height);\r
+\r
+ //視体積の設定\r
+ _gl.glMatrixMode(GL.GL_PROJECTION);\r
+ _gl.glLoadIdentity();\r
+ //見る位置\r
+ _gl.glMatrixMode(GL.GL_MODELVIEW);\r
+ _gl.glLoadIdentity();\r
+ }\r
+ private double[] __display_wk=new double[16];\r
+ \r
+ \r
+ public void display(GLAutoDrawable drawable)\r
+ {\r
+ NyARTransMatResult transmat_result = this._processor.transmat;\r
+ if (!_cap_image.hasData()) {\r
+ return;\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
+ if(this._processor.current_code<0 || transmat_result==null){\r
+ \r
+ }else{\r
+ try{\r
+ synchronized(this._sync_object){\r
+ // Projection transformation.\r
+ this._gl.glMatrixMode(GL.GL_PROJECTION);\r
+ this._gl.glLoadMatrixd(_camera_projection, 0);\r
+ this._gl.glMatrixMode(GL.GL_MODELVIEW);\r
+ // Viewing transformation.\r
+ this._gl.glLoadIdentity();\r
+ // 変換行列をOpenGL形式に変換\r
+ this._glnya.toCameraViewRH(transmat_result, __display_wk);\r
+ this._gl.glLoadMatrixd(__display_wk, 0);\r
+ // All other lighting and geometry goes here.\r
+ this._gl.glPushMatrix();\r
+ this._gl.glDisable(GL.GL_LIGHTING);\r
+\r
+ \r
+ //マーカのXZ平面をマーカの左上、表示開始位置を10cm上空へ。\r
+ //くるーんくるん\r
+ Date d = new Date();\r
+ float r=(d.getTime()/50)%360;\r
+ this._gl.glRotatef(r,0f,0f,1.0f);\r
+ this._gl.glTranslatef(-1.0f,0f,1.0f);\r
+ this._gl.glRotatef(90,1.0f,0f,0f);\r
+ this._panel.draw("MarkerId:"+this._processor.current_code,0.01f);\r
+ this._gl.glPopMatrix();\r
+ }\r
+ Thread.sleep(1);// タスク実行権限を一旦渡す\r
+ }catch(Exception e){\r
+ e.printStackTrace();\r
+ }\r
+ } \r
+ return;\r
+\r
+ }\r
+ /**\r
+ * カメラデバイスからのコールバック\r
+ */\r
+ public void onUpdateBuffer(Buffer i_buffer)\r
+ {\r
+ try {\r
+ synchronized (this._sync_object) {\r
+ this._cap_image.setBuffer(i_buffer);\r
+ //フレームワークに画像を転送\r
+ this._processor.detectMarker(this._cap_image);\r
+ }\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)\r
+ {\r
+ }\r
+\r
+\r
+ private final static int SCREEN_X = 640;\r
+ private final static int SCREEN_Y = 480;\r
+ private final static String PARAM_FILE = "../../Data/camera_para.dat";\r
+ //エントリポイント\r
+ public static void main(String[] args)\r
+ {\r
+ try{\r
+ NyARParam cparam= new NyARParam();\r
+ cparam.loadARParamFromFile(PARAM_FILE);\r
+ cparam.changeScreenSize(SCREEN_X, SCREEN_Y); \r
+ new SingleARMarker(cparam);\r
+ }catch(Exception e){\r
+ e.printStackTrace();\r
+ }\r
+ return;\r
+ }\r
+}\r
+\r
import jp.nyatla.nyartoolkit.*;\r
import jp.nyatla.nyartoolkit.core.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.jmf.utils.*;\r
import jp.nyatla.nyartoolkit.jogl.utils.*;\r
public MarkerProcessor(NyARParam i_cparam,int i_raster_format) throws NyARException\r
{\r
//アプリケーションフレームワークの初期化\r
- super(i_cparam,new NyIdMarkerDataEncoder_RawBit(),i_raster_format);\r
+ super();\r
+ initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),i_raster_format);\r
return;\r
}\r
/**\r
NyARCode ar_code = new NyARCode(16, 16);
ar_param.loadARParamFromFile(PARAM_FILE);
ar_param.changeScreenSize(320, 240);
- nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0);
+ raster = new QtNyARRaster_RGB(320, 240);
+ nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0,raster.getBufferReader().getBufferType());
ar_code.loadARPattFromFile(CARCODE_FILE);
//キャプチャイメージ用のラスタを準備
- raster = new QtNyARRaster_RGB(320, 240);
}
public void onUpdateBuffer(byte[] pixels)
package jp.nyatla.nyartoolkit.sandbox.qrcode;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.INyARSquareDetector;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
-import jp.nyatla.nyartoolkit.core.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.NyARVertexCounter;\r
-import jp.nyatla.nyartoolkit.core.labeling.INyARLabeling;\r
-import jp.nyatla.nyartoolkit.core.labeling.NyARLabelingImage;\r
-import jp.nyatla.nyartoolkit.core.labeling.NyARLabelingLabel;\r
-import jp.nyatla.nyartoolkit.core.labeling.NyARLabelingLabelStack;\r
-import jp.nyatla.nyartoolkit.core.labeling.NyARLabeling_ARToolKit;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabelStack;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;\r
import jp.nyatla.nyartoolkit.core.param.NyARCameraDistortionFactor;\r
-import jp.nyatla.nyartoolkit.core.pca2d.INyARPca2d;\r
import jp.nyatla.nyartoolkit.core.pca2d.*;\r
import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.NyARDoubleMatrix22;\r
\r
*/\r
public final void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack) throws NyARException\r
{\r
- final INyARLabeling labeling_proc = this._labeling;\r
+ final NyARLabeling_ARToolKit labeling_proc = this._labeling;\r
final NyARLabelingImage limage = this._limage;\r
\r
// 初期化\r
}\r
\r
final NyARLabelingLabelStack stack = limage.getLabelStack();\r
- final NyARLabelingLabel[] labels = (NyARLabelingLabel[]) stack.getArray();\r
+ final NyARLabelingLabel[] labels = stack.getArray();\r
\r
// ラベルを大きい順に整列\r
stack.sortByArea();\r
if(number_of_edge<3){\r
return;\r
}\r
- NyARSquare[] sa=(NyARSquare[])i_square_stack.getArray();\r
+ NyARSquare[] sa=i_square_stack.getArray();\r
for(int i=0;i<number_of_edge-2;i++)\r
{ \r
group[0]=sa[i];\r
package jp.nyatla.nyartoolkit.sandbox.qrcode;\r
\r
import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
/**\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core2.rasterfilter.rgb2gs.*;\r
if (number_of_square < 1) {\r
return false;\r
}\r
- this._detected_square=(NyARSquare)l_square_list.getItem(0);\r
+ this._detected_square=l_square_list.getItem(0);\r
return true;\r
}\r
\r
import java.awt.*;
import jp.nyatla.nyartoolkit.core.labeling.*;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.raster.*;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
import jp.nyatla.nyartoolkit.core2.rasterfilter.rgb2gs.*;
import jp.nyatla.nyartoolkit.core2.rasterfilter.gs2bin.*;
import jp.nyatla.utils.j2se.LabelingBufferdImage;
detect.detectMarker(_binraster1, stack);
for (int i = 0; i < stack.getLength(); i++) {
- NyARSquare[] square_ptr = (NyARSquare[]) stack.getArray();
+ NyARSquare[] square_ptr = stack.getArray();
int d=square_ptr[i].direction;
int[] xp=new int[4];
int[] yp=new int[4];
import jp.nyatla.nyartoolkit.core.pickup.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
double confidence = 0;\r
for(int i=0;i<number_of_square;i++){\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i))){\r
+ if (!this._patt.pickFromRaster(i_raster,l_square_list.getItem(i))){\r
continue;\r
}\r
//取得パターンをカラー差分データに変換して評価する。\r
package jp.nyatla.nyartoolkit.sandbox.quadx2;\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.labeling.*;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabelStack;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
\r
private int _width;\r
private int _height;\r
\r
- private INyARLabeling _labeling;\r
+ private NyARLabeling_ARToolKit_X2 _labeling;\r
\r
private NyARLabelingImage _limage;\r
\r
*/\r
public void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack) throws NyARException\r
{\r
- INyARLabeling labeling_proc = this._labeling;\r
+ NyARLabeling_ARToolKit_X2 labeling_proc = this._labeling;\r
NyARLabelingImage limage = this._limage;\r
\r
// 初期化\r
}\r
\r
NyARLabelingLabelStack stack = limage.getLabelStack();\r
- NyARLabelingLabel[] labels = (NyARLabelingLabel[])stack.getArray();\r
+ NyARLabelingLabel[] labels = stack.getArray();\r
\r
\r
// ラベルを大きい順に整列\r
package jp.nyatla.nyartoolkit.sandbox.vertexdetect;\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.labeling.*;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabelStack;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
import jp.nyatla.nyartoolkit.core.*;\r
*/\r
public final void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack) throws NyARException\r
{\r
- final INyARLabeling labeling_proc = this._labeling;\r
+ final NyARLabeling_ARToolKit_X2 labeling_proc = this._labeling;\r
final NyARLabelingImage limage = this._limage;\r
\r
// 初期化\r
}\r
\r
final NyARLabelingLabelStack stack = limage.getLabelStack();\r
- final NyARLabelingLabel[] labels = (NyARLabelingLabel[])stack.getArray();\r
+ final NyARLabelingLabel[] labels = stack.getArray();\r
\r
\r
// ラベルを大きい順に整列\r
NyARCode ar_code = new NyARCode(16, 16);\r
_ar_param.loadARParamFromFile(PARAM_FILE);\r
_ar_param.changeScreenSize(SCREEN_X, SCREEN_Y);\r
- _nya = new NyARSingleDetectMarker_X2(_ar_param, ar_code, 80.0);\r
_nya.setContinueMode(false);//ここをtrueにすると、transMatContinueモード(History計算)になります。\r
ar_code.loadARPattFromFile(CARCODE_FILE);\r
//NyARToolkit用の支援クラス\r
_glnya = new NyARGLUtil(_gl);\r
//GL対応のRGBラスタオブジェクト\r
_cap_image = new GLNyARRaster_RGB(_ar_param,_capture.getCaptureFormat());\r
+ _nya = new NyARSingleDetectMarker_X2(_ar_param, ar_code, 80.0,this._cap_image.getBufferReader().getBufferType());\r
//キャプチャ開始\r
_capture.start();\r
} catch (Exception e) {\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.labeling.*;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabelStack;\r
\r
/**\r
* 計算部から浮動小数点計算を除外したNyARLabeling_ARToolKit\r
* 画面サイズが1600x1600を超えると挙動が怪しくなる。\r
* \r
*/\r
-public class NyARLabeling_ARToolKit_X2 implements INyARLabeling\r
+public class NyARLabeling_ARToolKit_X2\r
{\r
private static final int WORK_SIZE = 1024 * 32;// #define WORK_SIZE 1024*32\r
\r
\r
private NyARIntSize _dest_size;\r
\r
- private INyARLabelingImage _out_image;\r
+ private NyARLabelingImage _out_image;\r
\r
- public void attachDestination(INyARLabelingImage i_destination_image) throws NyARException\r
+ public void attachDestination(NyARLabelingImage i_destination_image) throws NyARException\r
{\r
// サイズチェック\r
NyARIntSize size = i_destination_image.getSize();\r
return;\r
}\r
\r
- public INyARLabelingImage getAttachedDestination()\r
+ public NyARLabelingImage getAttachedDestination()\r
{\r
return this._out_image;\r
}\r
{\r
int m, n; /* work */\r
int i, j, k;\r
- INyARLabelingImage out_image = this._out_image;\r
+ NyARLabelingImage out_image = this._out_image;\r
\r
// サイズチェック\r
NyARIntSize in_size = i_raster.getSize();\r
// ラベルバッファを予約\r
i_stack.reserv(i_number_of_label);\r
// エリアと重心、クリップ領域を計算\r
- final NyARLabelingLabel[] labels = (NyARLabelingLabel[])i_stack.getArray();\r
+ final NyARLabelingLabel[] labels = i_stack.getArray();\r
for (int i = 0; i < i_number_of_label; i++) {\r
final int[] temp_ptr = temp[i];\r
temp_ptr[0]=0;//area\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
\r
\r
/**\r
* ARコードの物理サイズを、ミリメートルで指定します。\r
* @throws NyARException\r
*/\r
- public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width) throws NyARException\r
+ public NyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_raster_type) throws NyARException\r
{\r
final NyARIntSize scr_size=i_param.getScreenSize(); \r
final NyARFixedFloatObserv2IdealMap dist_map = new NyARFixedFloatObserv2IdealMap(i_param.getDistortionFactor(), scr_size);\r
this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
//差分データインスタンスの作成\r
this._deviation_data=new NyARMatchPattDeviationColorData(cw,ch);\r
+ this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,i_raster_type);\r
return;\r
}\r
\r
private NyARBinRaster _bin_raster;\r
- private NyARRasterFilter_ARToolkitThreshold _tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100);\r
+ private NyARRasterFilter_ARToolkitThreshold _tobin_filter;\r
private final NyARMatchPattResult __detectMarkerLite_mr=new NyARMatchPattResult();\r
private NyARMatchPattDeviationColorData _deviation_data;\r
\r
double confidence = 0;\r
for(int i=0;i<number_of_square;i++){\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, (NyARSquare)l_square_list.getItem(i))){\r
+ if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i))){\r
continue;\r
}\r
//取得パターンをカラー差分データに変換して評価する。\r
package jp.nyatla.nyartoolkit.sandbox.x2;\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.labeling.*;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabelStack;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core2.types.*;\r
import jp.nyatla.nyartoolkit.core2.types.matrix.NyARI64Matrix22;\r
private final int _width;\r
private final int _height;\r
\r
- private final INyARLabeling _labeling;\r
+ private final NyARLabeling_ARToolKit_X2 _labeling;\r
\r
private final NyARLabelingImage _limage;\r
\r
*/\r
public final void detectMarker(NyARBinRaster i_raster, NyARSquareStack o_square_stack) throws NyARException\r
{\r
- final INyARLabeling labeling_proc = this._labeling;\r
+ final NyARLabeling_ARToolKit_X2 labeling_proc = this._labeling;\r
final NyARLabelingImage limage = this._limage;\r
\r
// 初期化\r
}\r
\r
final NyARLabelingLabelStack stack = limage.getLabelStack();\r
- final NyARLabelingLabel[] labels = (NyARLabelingLabel[])stack.getArray();\r
+ final NyARLabelingLabel[] labels = stack.getArray();\r
\r
\r
// ラベルを大きい順に整列\r
package jp.nyatla.nyartoolkit.sandbox.x2;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core2.types.*;\r
\r
// 1パターンのみを追跡するクラスを作成\r
// NyARSingleDetectMarker_Quad ar = new NyARSingleDetectMarker_Quad(ap, code, 80.0);\r
- NyARSingleDetectMarker_X2 ar = new NyARSingleDetectMarker_X2(ap, code, 80.0);\r
+ NyARSingleDetectMarker_X2 ar = new NyARSingleDetectMarker_X2(ap, code, 80.0,ra.getBufferReader().getBufferType());\r
NyARTransMatResult result_mat = new NyARTransMatResult();\r
ar.setContinueMode(false);\r
ar.detectMarkerLite(ra, 100);\r
import java.awt.*;
import jp.nyatla.nyartoolkit.core.labeling.*;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.raster.*;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
import jp.nyatla.nyartoolkit.core2.rasterfilter.rgb2gs.*;
import jp.nyatla.nyartoolkit.core2.rasterfilter.gs2bin.*;
import jp.nyatla.utils.j2se.LabelingBufferdImage;
this._capture.setCaptureFormat(scr_size.w, scr_size.h,15f);\r
this._capture.setOnCapture(this); \r
this._nya_raster = new J3dNyARRaster_RGB(this._cparam,this._capture.getCaptureFormat());\r
- this._nya = new NyARSingleDetectMarker(this._cparam, i_ar_code, i_marker_width);\r
+ this._nya = new NyARSingleDetectMarker(this._cparam, i_ar_code, i_marker_width,this._nya_raster.getBufferReader().getBufferType());\r
this._nya_behavior = new NyARBehavior(this._nya, this._nya_raster, i_rate);\r
}\r
\r
}\r
return;\r
}\r
+ public void setPixel(int i_x, int i_y, int[] i_rgb) throws NyARException\r
+ {\r
+ NyARException.notImplement(); \r
+ }\r
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb) throws NyARException\r
+ {\r
+ NyARException.notImplement(); \r
+ }\r
\r
}\r
\r
}\r
return;\r
}\r
+ public void setPixel(int i_x, int i_y, int[] i_rgb) throws NyARException\r
+ {\r
+ NyARException.notImplement(); \r
+ }\r
+ public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb) throws NyARException\r
+ {\r
+ NyARException.notImplement(); \r
+ }\r
+ \r
}\r
\r
\r
+/* \r
+ * PROJECT: NyARToolkit\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 version ARToolkit class library.\r
+ * Copyright (C)2008 R.Iizuka\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (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 framework; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ * \r
+ * For further information please contact.\r
+ * http://nyatla.jp/nyatoolkit/\r
+ * <airmail(at)ebony.plala.or.jp>\r
+ * \r
+ */\r
package jp.nyatla.nyartoolkit.core;\r
\r
/**\r
package jp.nyatla.nyartoolkit.core.labeling;\r
\r
import java.lang.reflect.Array;\r
-import jp.nyatla.nyartoolkit.core.labeling.*;\r
+\r
\r
/**\r
* ラベル同士の重なり(内包関係)を調べるクラスです。 \r
-/* このソースは実験用のソースです。\r
- * 動いたり動かなかったりします。\r
+/* \r
+ * PROJECT: NyARToolkit(Extension)\r
+ * --------------------------------------------------------------------------------\r
+ * The NyARToolkit is Java version ARToolkit class library.\r
+ * Copyright (C)2008 R.Iizuka\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (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 framework; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ * \r
+ * For further information please contact.\r
+ * http://nyatla.jp/nyatoolkit/\r
+ * <airmail(at)ebony.plala.or.jp>\r
* \r
*/\r
package jp.nyatla.nyartoolkit.core.labeling.rlelabeling;\r
v.clip_r=i_rel_img.r-1;\r
v.clip_t=i_row_index;\r
v.clip_b=i_row_index;\r
- v.pos_x+=(len*(2*l+(len-1)))/2;\r
- v.pos_y+=i_row_index*len;\r
+ v.pos_x=(len*(2*l+(len-1)))/2;\r
+ v.pos_y=i_row_index*len;\r
\r
return;\r
}\r
+/* \r
+ * PROJECT: NyARToolkit(Extension)\r
+ * --------------------------------------------------------------------------------\r
+ * The NyARToolkit is Java version ARToolkit class library.\r
+ * Copyright (C)2008 R.Iizuka\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (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 framework; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ * \r
+ * For further information please contact.\r
+ * http://nyatla.jp/nyatoolkit/\r
+ * <airmail(at)ebony.plala.or.jp>\r
+ * \r
+ */\r
package jp.nyatla.nyartoolkit.core.labeling.rlelabeling;\r
\r
\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
\r
/**\r
* AR_TEMPLATE_MATCHING_BWと同等のルールで マーカを評価します。\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
\r
/**\r
* AR_TEMPLATE_MATCHING_COLORかつAR_MATCHING_WITHOUT_PCAと同等のルールで マーカーを評価します。\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.NyARCode;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
\r
/**\r
* AR_TEMPLATE_MATCHING_COLORかつAR_MATCHING_WITH_PCAと同等のルールで マーカーを評価します。\r
package jp.nyatla.nyartoolkit.core.pickup;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
\r
public interface INyARColorPatt extends INyARRgbRaster\r
{\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.NyARMat;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
/**\r
* 24ビットカラーのマーカーを保持するために使うクラスです。 このクラスは、ARToolkitのパターンと、ラスタから取得したパターンを保持します。\r
* 演算順序以外の最適化をしたもの\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.NyARMat;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
/**\r
* 24ビットカラーのマーカーを保持するために使うクラスです。 このクラスは、ARToolkitのパターンと、ラスタから取得したパターンを保持します。\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
*\r
package jp.nyatla.nyartoolkit.core.pickup;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.utils.NyARPerspectiveParamGenerator_O1;\r
\r
*/\r
public class NyARColorPatt_Perspective implements INyARColorPatt\r
{\r
- private int[] _patdata;\r
- private NyARBufferReader _buf_reader;\r
+ protected int[] _patdata;\r
+ protected NyARIntPoint2d _pickup_lt=new NyARIntPoint2d(); \r
+ protected int _resolution;\r
+ protected NyARBufferReader _buf_reader;\r
+ protected NyARIntSize _size;\r
+ protected NyARPerspectiveParamGenerator_O1 _perspective_gen;\r
private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;\r
- private NyARIntSize _size;\r
- NyARPerspectiveParamGenerator_O1 _perspective_gen;\r
private static final int LOCAL_LT=1;\r
- private NyARIntPoint2d _pickup_lt=new NyARIntPoint2d(); \r
+ \r
+ private void initializeInstance(int i_width, int i_height,int i_point_per_pix)\r
+ {\r
+ assert i_width>2 && i_height>2;\r
+ this._resolution=i_point_per_pix; \r
+ this._size=new NyARIntSize(i_width,i_height);\r
+ this._patdata = new int[i_height*i_width];\r
+ this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+ this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);\r
+ return; \r
+ }\r
/**\r
* 例えば、64\r
* @param i_width\r
* 取得画像の解像度幅\r
* @param i_height\r
* 取得画像の解像度高さ\r
+ * @param i_point_per_pix\r
+ * 1ピクセルあたりの縦横サンプリング数。2なら2x2=4ポイントをサンプリングする。\r
*/\r
- public NyARColorPatt_Perspective(int i_width, int i_height)\r
+ public NyARColorPatt_Perspective(int i_width, int i_height,int i_point_per_pix)\r
{\r
- //入力制限\r
- assert i_width>2 && i_height>2;\r
- \r
- this._size=new NyARIntSize(i_width,i_height);\r
- this._patdata = new int[i_height*i_width];\r
- this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
- this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);\r
- setEdgeSize(0,0);\r
+ initializeInstance(i_width,i_height,i_point_per_pix);\r
+ setEdgeSize(0,0,i_point_per_pix);\r
return;\r
}\r
/**\r
* @param i_edge_percentage\r
* エッジ幅の割合(ARToolKit標準と同じなら、25)\r
*/\r
- public NyARColorPatt_Perspective(int i_width, int i_height,int i_edge_percentage)\r
+ public NyARColorPatt_Perspective(int i_width, int i_height,int i_resolution,int i_edge_percentage)\r
{\r
//入力制限\r
- assert i_width>2 && i_height>2;\r
- \r
- this._size=new NyARIntSize(i_width,i_height);\r
- this._patdata = new int[i_height*i_width];\r
- this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
- this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);\r
- setEdgeSizeByPercent(i_edge_percentage,i_edge_percentage);\r
+ initializeInstance(i_width,i_height,i_resolution);\r
+ setEdgeSizeByPercent(i_edge_percentage,i_edge_percentage,i_resolution);\r
return;\r
} \r
/**\r
* @param i_x_edge\r
* @param i_y_edge\r
*/\r
- public void setEdgeSize(int i_x_edge,int i_y_edge)\r
+ public void setEdgeSize(int i_x_edge,int i_y_edge,int i_resolution)\r
{\r
assert(i_x_edge>=0);\r
assert(i_y_edge>=0);\r
//Perspectiveパラメタ計算器を作成\r
- this._perspective_gen=new NyARPerspectiveParamGenerator_O1(LOCAL_LT,LOCAL_LT,i_x_edge*2+this._size.w,i_y_edge*2+this._size.h);\r
+ this._perspective_gen=new NyARPerspectiveParamGenerator_O1(\r
+ LOCAL_LT,LOCAL_LT,\r
+ (i_x_edge*2+this._size.w)*i_resolution,\r
+ (i_y_edge*2+this._size.h)*i_resolution);\r
//ピックアップ開始位置を計算\r
- this._pickup_lt.x=i_x_edge+LOCAL_LT;\r
- this._pickup_lt.y=i_y_edge+LOCAL_LT;\r
+ this._pickup_lt.x=i_x_edge*i_resolution+LOCAL_LT;\r
+ this._pickup_lt.y=i_y_edge*i_resolution+LOCAL_LT;\r
return;\r
}\r
- public void setEdgeSizeByPercent(int i_x_percent,int i_y_percent)\r
+ public void setEdgeSizeByPercent(int i_x_percent,int i_y_percent,int i_resolution)\r
{\r
assert(i_x_percent>=0);\r
assert(i_y_percent>=0);\r
- setEdgeSize(this._size.w*i_x_percent/50,this._size.h*i_y_percent/50);\r
+ setEdgeSize(this._size.w*i_x_percent/50,this._size.h*i_y_percent/50,i_resolution);\r
return;\r
}\r
\r
return this._pixelreader;\r
}\r
private final int[] __pickFromRaster_rgb_tmp = new int[3];\r
+ protected final double[] __pickFromRaster_cpara=new double[8];\r
/**\r
* \r
* @param image\r
public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square)throws NyARException\r
{\r
//遠近法のパラメータを計算\r
- double[] cpara = new double[8];\r
+ final double[] cpara = this.__pickFromRaster_cpara;\r
if (!this._perspective_gen.getParam(i_square.imvertex, cpara)) {\r
return false;\r
}\r
\r
- int img_x = image.getWidth();\r
- int img_y = image.getHeight();\r
+ final int resolution=this._resolution;\r
+ final int img_x = image.getWidth();\r
+ final int img_y = image.getHeight();\r
+ final int res_pix=resolution*resolution;\r
\r
- int[] rgb_tmp = __pickFromRaster_rgb_tmp;\r
+ final int[] rgb_tmp = this.__pickFromRaster_rgb_tmp;\r
\r
//ピクセルリーダーを取得\r
INyARRgbPixelReader reader=image.getRgbPixelReader();\r
-\r
- for(int iy=0;iy<this._size.h;iy++){\r
- for(int ix=0;ix<this._size.w;ix++){\r
- //1ピクセルを作成\r
- int cx=this._pickup_lt.x+ix;\r
- int cy=this._pickup_lt.y+iy;\r
- final double d=cpara[6]*cx+cpara[7]*cy+1.0;\r
- final int x=(int)((cpara[0]*cx+cpara[1]*cy+cpara[2])/d);\r
- final int y=(int)((cpara[3]*cx+cpara[4]*cy+cpara[5])/d);\r
- if (x >= 0 && x < img_x && y >= 0 && y < img_y) {\r
- reader.getPixel(x, y, rgb_tmp);\r
- this._patdata[iy*this._size.w+ix]=(((rgb_tmp[0])&0xff)<<16)|(((rgb_tmp[1])&0xff)<<8)|(((rgb_tmp[2])&0xff));\r
+ int p=0;\r
+ for(int iy=0;iy<this._size.h*resolution;iy+=resolution){\r
+ //解像度分の点を取る。\r
+ for(int ix=0;ix<this._size.w*resolution;ix+=resolution){\r
+ int r,g,b;\r
+ r=g=b=0;\r
+ for(int i2y=iy;i2y<iy+resolution;i2y++){\r
+ int cy=this._pickup_lt.y+i2y;\r
+ for(int i2x=ix;i2x<ix+resolution;i2x++){\r
+ //1ピクセルを作成\r
+ int cx=this._pickup_lt.x+i2x;\r
+ final double d=cpara[6]*cx+cpara[7]*cy+1.0;\r
+ int x=(int)((cpara[0]*cx+cpara[1]*cy+cpara[2])/d);\r
+ int y=(int)((cpara[3]*cx+cpara[4]*cy+cpara[5])/d);\r
+ if(x<0){x=0;}\r
+ if(x>=img_x){x=img_x-1;}\r
+ if(y<0){y=0;}\r
+ if(y>=img_y){y=img_y-1;}\r
+ \r
+ reader.getPixel(x, y, rgb_tmp);\r
+ r+=rgb_tmp[0];\r
+ g+=rgb_tmp[1];\r
+ b+=rgb_tmp[2];\r
+ }\r
}\r
+ r/=res_pix;\r
+ g/=res_pix;\r
+ b/=res_pix;\r
+ this._patdata[p]=((r&0xff)<<16)|((g&0xff)<<8)|((b&0xff));\r
+ p++;\r
}\r
+ }\r
//ピクセル問い合わせ\r
//ピクセルセット\r
- }\r
return true;\r
- } \r
+ }\r
+\r
}
\ No newline at end of file
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\r
* --------------------------------------------------------------------------------\r
* The NyARToolkit is Java version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
import jp.nyatla.nyartoolkit.core.utils.NyARDoubleMatrixProcessor;\r
* <airmail(at)ebony.plala.or.jp>\r
* \r
*/\r
-package jp.nyatla.nyartoolkit.core;\r
+package jp.nyatla.nyartoolkit.core.squaredetect;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster;\r
* <airmail(at)ebony.plala.or.jp>\r
* \r
*/\r
-package jp.nyatla.nyartoolkit.core;\r
+package jp.nyatla.nyartoolkit.core.squaredetect;\r
\r
import jp.nyatla.nyartoolkit.core.types.*;\r
/**\r
package jp.nyatla.nyartoolkit.core.squaredetect;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.INyARSquareDetector;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
-import jp.nyatla.nyartoolkit.core.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.labeling.LabelOverlapChecker;\r
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;\r
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
package jp.nyatla.nyartoolkit.core.squaredetect;\r
\r
\r
-import java.util.Date;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.INyARSquareDetector;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
-import jp.nyatla.nyartoolkit.core.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.labeling.LabelOverlapChecker;\r
import jp.nyatla.nyartoolkit.core.labeling.rlelabeling.*;\r
import jp.nyatla.nyartoolkit.core.param.NyARCameraDistortionFactor;\r
* <airmail(at)ebony.plala.or.jp>\r
* \r
*/\r
-package jp.nyatla.nyartoolkit.core;\r
+package jp.nyatla.nyartoolkit.core.squaredetect;\r
\r
\r
import jp.nyatla.utils.*;\r
package jp.nyatla.nyartoolkit.core.squaredetect;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.NyARVertexCounter;\r
import jp.nyatla.nyartoolkit.core.param.NyARCameraDistortionFactor;\r
import jp.nyatla.nyartoolkit.core.param.NyARObserv2IdealMap;\r
package jp.nyatla.nyartoolkit.core.transmat;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
\r
\r
/**\r
package jp.nyatla.nyartoolkit.core.transmat;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.transmat.fitveccalc.NyARFitVecCalculator;\r
import jp.nyatla.nyartoolkit.core.transmat.optimize.*;\r
import jp.nyatla.nyartoolkit.core.transmat.rotmatrix.*;\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
- * Copyright (C)2008-2009 R.Iizuka\r
+ * Copyright (C)2008 R.Iizuka\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
- * Copyright (C)2008-2009 R.Iizuka\r
+ * Copyright (C)2008 R.Iizuka\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
- * Copyright (C)2008-2009 R.Iizuka\r
+ * Copyright (C)2008 R.Iizuka\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
- * Copyright (C)2008-2009 R.Iizuka\r
+ * Copyright (C)2008 R.Iizuka\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
- *\r
+ * \r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
* as published by the Free Software Foundation; either version 2\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
*\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
*\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
- *\r
+ * \r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
* as published by the Free Software Foundation; either version 2\r
* \r
*/\r
public class NyARCustomSingleDetectMarker\r
-{\r
+{ \r
private static final int AR_SQUARE_MAX = 100;\r
\r
private boolean _is_continue = false;\r
protected INyARRasterFilter_RgbToBin _tobin_filter;\r
\r
private NyARMatchPattDeviationColorData _deviation_data;\r
- /**\r
- * 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。\r
- * \r
- * @param i_param\r
- * カメラパラメータを指定します。\r
- * @param i_code\r
- * 検出するARCodeを指定します。\r
- * @param i_marker_width\r
- * ARコードの物理サイズを、ミリメートルで指定します。\r
- * @param i_filter\r
- * RGB→BIN変換フィルタを指定します。\r
- * @throws NyARException\r
- */\r
- public NyARCustomSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,INyARRasterFilter_RgbToBin i_filter) throws NyARException\r
+\r
+ protected NyARCustomSingleDetectMarker()\r
+ {\r
+ return;\r
+ }\r
+ protected void initInstance(\r
+ INyARColorPatt i_patt_inst,\r
+ INyARSquareDetector i_sqdetect_inst,\r
+ INyARRasterFilter_RgbToBin i_filter,\r
+ NyARParam i_ref_param,\r
+ NyARCode i_ref_code,\r
+ double i_marker_width) throws NyARException\r
{\r
- final NyARIntSize scr_size=i_param.getScreenSize(); \r
+ final NyARIntSize scr_size=i_ref_param.getScreenSize(); \r
// 解析オブジェクトを作る\r
-// this._square_detect = new NyARSquareDetector_ARToolKit(i_param.getDistortionFactor(),scr_size);\r
- this._square_detect = new NyARSquareDetector_Rle(i_param.getDistortionFactor(),scr_size);\r
- this._transmat = new NyARTransMat(i_param);\r
+ this._square_detect = i_sqdetect_inst;\r
+ this._transmat = new NyARTransMat(i_ref_param);\r
+ this._tobin_filter=i_filter;\r
// 比較コードを保存\r
this._marker_width = i_marker_width;\r
//パターンピックアップを作成\r
-// this._patt = new NyARColorPatt_O1(i_code.getWidth(), i_code.getHeight());\r
- this._patt = new NyARColorPatt_O3(i_code.getWidth(), i_code.getHeight());\r
-// this._patt = new NyARColorPatt_Perspective(i_code.getWidth(), i_code.getHeight(),25);\r
+ this._patt = i_patt_inst;\r
//取得パターンの差分データ器を作成\r
- this._deviation_data=new NyARMatchPattDeviationColorData(i_code.getWidth(),i_code.getHeight());\r
+ this._deviation_data=new NyARMatchPattDeviationColorData(i_ref_code.getWidth(),i_ref_code.getHeight());\r
//i_code用の評価器を作成\r
- this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_code);\r
- \r
+ this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code);\r
//2値画像バッファを作る\r
this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
- this._tobin_filter=i_filter;\r
return;\r
+ \r
}\r
\r
private final NyARMatchPattResult __detectMarkerLite_mr=new NyARMatchPattResult();\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareDetector_Rle;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
class NyARDetectMarkerResult\r
*/\r
public NyARDetectMarker(NyARParam i_param,NyARCode[] i_code,double[] i_marker_width, int i_number_of_code,int i_input_raster_type) throws NyARException\r
{\r
- final NyARIntSize scr_size=i_param.getScreenSize();\r
+ initInstance(i_param,i_code,i_marker_width,i_number_of_code,i_input_raster_type);\r
+ return;\r
+ }\r
+ protected void initInstance(\r
+ NyARParam i_ref_param,\r
+ NyARCode[] i_ref_code,\r
+ double[] i_marker_width,\r
+ int i_number_of_code,\r
+ int i_input_raster_type) throws NyARException\r
+ {\r
+\r
+ final NyARIntSize scr_size=i_ref_param.getScreenSize();\r
// 解析オブジェクトを作る\r
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(),scr_size);\r
- this._transmat = new NyARTransMat(i_param);\r
- this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);\r
\r
+ this._transmat = new NyARTransMat(i_ref_param);\r
//各コード用の比較器を作る。\r
this._match_patt=new NyARMatchPatt_Color_WITHOUT_PCA[i_number_of_code];\r
- final int cw = i_code[0].getWidth();\r
- final int ch = i_code[0].getHeight();\r
- this._match_patt[0]=new NyARMatchPatt_Color_WITHOUT_PCA(i_code[0]);\r
+ final int cw = i_ref_code[0].getWidth();\r
+ final int ch = i_ref_code[0].getHeight();\r
+ this._match_patt[0]=new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code[0]);\r
for (int i = 1; i < i_number_of_code; i++){\r
//解像度チェック\r
- if (cw != i_code[i].getWidth() || ch != i_code[i].getHeight()) {\r
+ if (cw != i_ref_code[i].getWidth() || ch != i_ref_code[i].getHeight()) {\r
throw new NyARException();\r
}\r
- this._match_patt[i]=new NyARMatchPatt_Color_WITHOUT_PCA(i_code[i]);\r
- } \r
- // 評価パターンのホルダを作る\r
- this._patt = new NyARColorPatt_O3(cw, ch);\r
+ this._match_patt[i]=new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code[i]);\r
+ }\r
+ //NyARToolkitプロファイル\r
+ this._patt =new NyARColorPatt_Perspective_O2(cw, ch,4,25);\r
+ this._square_detect =new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(),i_ref_param.getScreenSize());\r
+ this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);\r
+\r
//実サイズ保存\r
this._marker_width = i_marker_width;\r
//差分データインスタンスの作成\r
this._deviation_data=new NyARMatchPattDeviationColorData(cw,ch);\r
//2値画像バッファを作る\r
this._bin_raster=new NyARBinRaster(scr_size.w,scr_size.h);\r
- return;\r
+ return; \r
}\r
-\r
+ \r
private NyARBinRaster _bin_raster;\r
\r
- private NyARRasterFilter_ARToolkitThreshold _tobin_filter;\r
+ private INyARRasterFilter_RgbToBin _tobin_filter;\r
private final NyARMatchPattResult __detectMarkerLite_mr=new NyARMatchPattResult();\r
\r
/**\r
}\r
\r
// ラスタを2値イメージに変換する.\r
- this._tobin_filter.setThreshold(i_threshold);\r
+ ((NyARRasterFilter_ARToolkitThreshold)this._tobin_filter).setThreshold(i_threshold);\r
this._tobin_filter.doFilter(i_raster, this._bin_raster);\r
\r
NyARSquareStack l_square_list = this._square_list;\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.*;\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
+import jp.nyatla.nyartoolkit.core.pickup.INyARColorPatt;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;\r
\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
+import jp.nyatla.nyartoolkit.core.pickup.*;\r
/**\r
* 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。\r
* \r
*/\r
public class NyARSingleDetectMarker extends NyARCustomSingleDetectMarker\r
{\r
+ public final static int PF_ARTOOLKIT_CONPATIBLE=1;\r
+ public final static int PF_NYARTOOLKIT=2;\r
+ \r
/**\r
* 検出するARCodeとカメラパラメータから、1個のARCodeを検出するNyARSingleDetectMarkerインスタンスを作ります。\r
* \r
* 入力ラスタのピクセルタイプを指定します。この値は、INyARBufferReaderインタフェイスのgetBufferTypeの戻り値を指定します。\r
* @throws NyARException\r
*/\r
+ public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type,int i_profile_id) throws NyARException\r
+ {\r
+ super();\r
+ initInstance(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);\r
+ return;\r
+ }\r
public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type) throws NyARException\r
{\r
- super(i_param,i_code,i_marker_width,new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type));\r
+ super();\r
+ initInstance(i_param,i_code,i_marker_width,i_input_raster_type,PF_NYARTOOLKIT);\r
+ return;\r
}\r
+ /**\r
+ * コンストラクタから呼び出す関数です。\r
+ * @param i_ref_param\r
+ * @param i_ref_code\r
+ * @param i_marker_width\r
+ * @param i_input_raster_type\r
+ * @param i_profile_id\r
+ * @throws NyARException\r
+ */\r
+ protected void initInstance(\r
+ NyARParam i_ref_param,\r
+ NyARCode i_ref_code,\r
+ double i_marker_width,\r
+ int i_input_raster_type,\r
+ int i_profile_id) throws NyARException\r
+ {\r
+ final NyARRasterFilter_ARToolkitThreshold th=new NyARRasterFilter_ARToolkitThreshold(100,i_input_raster_type);\r
+ INyARColorPatt patt_inst;\r
+ INyARSquareDetector sqdetect_inst;\r
\r
+ switch(i_profile_id){\r
+ case PF_ARTOOLKIT_CONPATIBLE:\r
+ patt_inst=new NyARColorPatt_O3(i_ref_code.getWidth(), i_ref_code.getHeight());\r
+ sqdetect_inst=new NyARSquareDetector_ARToolKit(i_ref_param.getDistortionFactor(),i_ref_param.getScreenSize());\r
+ break;\r
+ case PF_NYARTOOLKIT:\r
+ patt_inst=new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(),4,25);\r
+ sqdetect_inst=new NyARSquareDetector_Rle(i_ref_param.getDistortionFactor(),i_ref_param.getScreenSize()); \r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ super.initInstance(patt_inst,sqdetect_inst,th,i_ref_param,i_ref_code,i_marker_width);\r
+ \r
+ }\r
\r
/**\r
* i_imageにマーカー検出処理を実行し、結果を記録します。\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
*\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
*\r
/* \r
- * PROJECT: NyARToolkit\r
+ * PROJECT: NyARToolkit(Extension)\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 version ARToolkit class library.\r
* Copyright (C)2008 R.Iizuka\r
*\r
package jp.nyatla.nyartoolkit.nyidmarker;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.utils.*;\r
\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
\r
/**\r
* このクラスは、同時に1個のマーカを処理することのできる、アプリケーションプロセッサです。\r
\r
private int _lost_delay = 5;\r
\r
- private NyARSquareDetector _square_detect;\r
+ private INyARSquareDetector _square_detect;\r
\r
protected NyARTransMat _transmat;\r
\r
\r
private NyARSquareStack _square_list = new NyARSquareStack(100);\r
\r
- private NyARColorPatt_O3 _patt = null;\r
+ private INyARColorPatt _patt = null;\r
\r
private double _cf_threshold_new = 0.30;\r
-\r
private double _cf_threshold_exist = 0.15;\r
\r
private int _threshold = 110;\r
protected int _current_arcode_index = -1;\r
\r
private NyARMatchPattDeviationColorData _deviation_data;\r
+ \r
+ protected SingleARMarkerProcesser()\r
+ {\r
+ return;\r
+ }\r
\r
\r
- public SingleARMarkerProcesser(NyARParam i_param,int i_raster_type) throws NyARException\r
+ protected void initInstance(NyARParam i_param,int i_raster_type) throws NyARException\r
{\r
NyARIntSize scr_size = i_param.getScreenSize();\r
// 解析オブジェクトを作る\r
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);\r
+ this._square_detect = new NyARSquareDetector_Rle(i_param.getDistortionFactor(), scr_size);\r
this._transmat = new NyARTransMat(i_param);\r
this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(110,i_raster_type);\r
\r
return;\r
}\r
\r
+ \r
public void setThreshold(int i_threshold)\r
{\r
this._threshold = i_threshold;\r
// 強制リセット\r
reset(true);\r
}\r
- // 検出するマーカセット、情報、検出器を作り直す。\r
- this._patt = new NyARColorPatt_O3(i_code_resolution, i_code_resolution);\r
+ //検出するマーカセット、情報、検出器を作り直す。(1ピクセル4ポイントサンプリング,マーカのパターン領域は50%)\r
+ this._patt = new NyARColorPatt_Perspective_O2(i_code_resolution, i_code_resolution,4,25);\r
this._deviation_data=new NyARMatchPattDeviationColorData(i_code_resolution, i_code_resolution);\r
this._marker_width = i_marker_width;\r
\r
import jp.nyatla.nyartoolkit.nyidmarker.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.data.*;\r
import jp.nyatla.nyartoolkit.core2.rasteranalyzer.threshold.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
\r
public abstract class SingleNyIdMarkerProcesser\r
{\r
private int _lost_delay_count = 0;\r
private int _lost_delay = 5;\r
\r
- private NyARSquareDetector _square_detect;\r
+ private NyARSquareDetector_Rle _square_detect;\r
protected NyARTransMat _transmat;\r
private double _marker_width=100;\r
\r
private NyIdMarkerPickup _id_pickup = new NyIdMarkerPickup();\r
\r
\r
- protected SingleNyIdMarkerProcesser(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format) throws NyARException\r
+ protected SingleNyIdMarkerProcesser()\r
+ {\r
+ return;\r
+ }\r
+ protected void initInstance(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format) throws NyARException\r
{\r
NyARIntSize scr_size = i_param.getScreenSize();\r
// 解析オブジェクトを作る\r
- this._square_detect = new NyARSquareDetector(i_param.getDistortionFactor(), scr_size);\r
+ this._square_detect = new NyARSquareDetector_Rle(i_param.getDistortionFactor(), scr_size);\r
this._transmat = new NyARTransMat(i_param);\r
this._encoder=i_encoder;\r
\r
this._tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110,i_raster_format);\r
this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,i_raster_format,4);\r
return;\r
+ \r
}\r
\r
public void setMarkerWidth(int i_width)\r
\r
private final NyIdMarkerPattern _marker_data=new NyIdMarkerPattern();\r
private final NyIdMarkerParam _marker_param=new NyIdMarkerParam();\r
- private final NyARRasterThresholdAnalyzer_SlidePTile _threshold_detect;\r
+ private NyARRasterThresholdAnalyzer_SlidePTile _threshold_detect;\r
\r
/**新規マーカ検索 現在認識中のマーカがないものとして、最も認識しやすいマーカを1個認識します。\r
*/\r
package jp.nyatla.nyartoolkit.sample;\r
\r
import java.io.*;\r
-import java.util.*;\r
\r
-import jp.nyatla.nyartoolkit.core.*;\r
+\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.transmat.*;\r
-import jp.nyatla.nyartoolkit.nyidmarker.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.data.*;\r
import jp.nyatla.nyartoolkit.processor.*;\r
\r
\r
public MarkerProcessor(NyARParam i_cparam, int i_raster_format) throws Exception\r
{\r
- super(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format);\r
+ super();//\r
+ initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format);\r
//アプリケーションフレームワークの初期化\r
return;\r
}\r
// Blank_Raster ra=new Blank_Raster(320, 240);\r
\r
// 1パターンのみを追跡するクラスを作成\r
- NyARSingleDetectMarker ar = new NyARSingleDetectMarker(ap, code, 80.0,ra.getBufferReader().getBufferType());\r
+ NyARSingleDetectMarker ar = new NyARSingleDetectMarker(\r
+ ap, code, 80.0,ra.getBufferReader().getBufferType(),NyARSingleDetectMarker.PF_NYARTOOLKIT);\r
NyARTransMatResult result_mat = new NyARTransMatResult();\r
ar.setContinueMode(false);\r
ar.detectMarkerLite(ra, 100);\r
package jp.nyatla.nyartoolkit.dev;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.utils.*;\r
-import jp.nyatla.nyartoolkit.core.labeling.NyARLabelingLabel;\r
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;\r
import jp.nyatla.nyartoolkit.core.pickup.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.MarkerPattEncoder;\r
import jp.nyatla.nyartoolkit.nyidmarker.PerspectivePixelReader;\r
{\r
private int[] _patdata;\r
private NyARBufferReader _buf_reader;\r
- private NyARRgbPixelReader_INT1D_GLAY_8 _pixelreader;\r
+ private NyARRgbPixelReader_INT1D_GRAY_8 _pixelreader;\r
private NyARIntSize _size;\r
PerspectivePixelReader2 _perspective_gen;\r
private static final int LOCAL_LT=1;\r
this._size=new NyARIntSize(resolution,resolution);\r
this._patdata = new int[resolution*resolution];\r
this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8);\r
- this._pixelreader=new NyARRgbPixelReader_INT1D_GLAY_8(this._patdata,this._size);\r
+ this._pixelreader=new NyARRgbPixelReader_INT1D_GRAY_8(this._patdata,this._size);\r
this._perspective_gen=new PerspectivePixelReader2(LOCAL_LT,LOCAL_LT,100,100);\r
return;\r
} \r
import java.awt.*;
-import jp.nyatla.nyartoolkit.core.INyARSquareDetector;
import jp.nyatla.nyartoolkit.core.labeling.*;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingImage;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabel;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabelingLabelStack;
+import jp.nyatla.nyartoolkit.core.labeling.artoolkit.NyARLabeling_ARToolKit;
import jp.nyatla.nyartoolkit.core.match.*;
import jp.nyatla.nyartoolkit.core.param.*;
import jp.nyatla.nyartoolkit.core.pca2d.INyARPca2d;
import jp.nyatla.utils.NyObjectStack;
import jp.nyatla.utils.j2se.LabelingBufferdImage;
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareDetector;
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
import jp.nyatla.nyartoolkit.core.transmat.*;
import jp.nyatla.nyartoolkit.core.types.*;
import jp.nyatla.nyartoolkit.core.types.matrix.NyARDoubleMatrix22;
}
final NyARLabelingLabelStack stack = limage.getLabelStack();
- final NyARLabelingLabel[] labels = (NyARLabelingLabel[]) stack.getArray();
+ final NyARLabelingLabel[] labels = stack.getArray();
// ラベルを大きい順に整列
stack.sortByArea();
if(number_of_edge<3){
return;
}
- NyARSquare[] sa=(NyARSquare[])i_square_stack.getArray();
+ NyARSquare[] sa=i_square_stack.getArray();
for(int i=0;i<number_of_edge;i++)
{
for(int i2=i+1;i2<number_of_edge;i2++)
labeling.attachDestination(limage);
labeling.labeling(_binraster1);
this._bimg.drawImage(this._gsraster1);
- NyARLabelingLabel[] labels = (NyARLabelingLabel[]) limage.getLabelStack().getArray();
+ NyARLabelingLabel[] labels = limage.getLabelStack().getArray();
NyARSquareStack stack = new NyARSquareStack(100);
NyARQRCodeDetector detect = new NyARQRCodeDetector(ap.getDistortionFactor(), new NyARIntSize(320,240));
package jp.nyatla.nyartoolkit.dev;\r
\r
import java.awt.Frame;\r
+import java.awt.*;\r
+import java.awt.event.WindowAdapter;\r
+import java.awt.event.WindowEvent;\r
import java.io.File;\r
import java.io.FileInputStream;\r
\r
+import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.NyARRgbRaster_BGRA;\r
-import jp.nyatla.nyartoolkit.core.labeling.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
+\r
\r
-import jp.nyatla.nyartoolkit.core2.rasteranalyzer.*;\r
import jp.nyatla.utils.j2se.*;\r
\r
public class LabelingTest extends Frame\r
{\r
- private final String data_file ="../Data/320x240ABGR.raw";\r
- public void drawImage() throws Exception\r
- {\r
- File f=new File(data_file);\r
- FileInputStream fs=new FileInputStream(data_file);\r
- byte[] buf=new byte[(int)f.length()];\r
- fs.read(buf);\r
- NyARRgbRaster_BGRA ra=NyARRgbRaster_BGRA.wrap(buf, 320, 240);\r
- NyARLabelingImage limage=new NyARLabelingImage(320,240);\r
- INyARLabeling labeling=new NyARLabeling_ARToolKit();\r
-// INyARLabeling labeling=new NyLineLabeling();\r
- INyARRasterReaderFactory rf=new NyARRasterReaderFactory_RgbTotal();\r
- labeling.attachDestination(limage);\r
- labeling.labeling(rf.createReader(ra));\r
- LabelingBufferdImage img=new LabelingBufferdImage(320,240,LabelingBufferdImage.COLOR_125_COLOR);\r
- img.setLabelingImage(limage);\r
- this.getGraphics().drawImage(img, 32,32,this);\r
- }\r
- public static void main(String[] args)\r
- {\r
- try{\r
- LabelingTest app=new LabelingTest();\r
- app.setVisible(true);\r
- app.setBounds(0,0,640,480);\r
- app.drawImage();\r
- }catch(Exception e){\r
- e.printStackTrace();\r
+ private final String data_file = "../Data/320x240ABGR.raw";\r
+\r
+ final int W=10;\r
+ final int H=10;\r
+ public void drawImage() throws Exception\r
+ {\r
+ File f = new File(data_file);\r
+ FileInputStream fs = new FileInputStream(data_file);\r
+ byte[] buf = new byte[(int) f.length()];\r
+ fs.read(buf);\r
+ NyARRgbRaster_BGRA ra = NyARRgbRaster_BGRA.wrap(buf, W, H);\r
+ // 二値化\r
+ NyARRasterFilter_ARToolkitThreshold filter = new NyARRasterFilter_ARToolkitThreshold(110, ra.getBufferReader().getBufferType());\r
+ NyARBinRaster bin = new NyARBinRaster(W,240);\r
+ filter.doFilter(ra, bin);\r
+ int[] t = (int[]) bin.getBufferReader().getBuffer();\r
+ int[] s = {\r
+ 1,1,1,1,1,1,1,1,1,1,\r
+\r
+ 1,0,0,0,0,1,0,1,1,1,\r
+ 1,0,1,1,0,1,0,1,1,1,\r
+ 1,1,1,1,1,0,1,1,1,1,\r
+ 1,1,1,1,1,1,1,1,1,1,\r
+ 1,1,1,1,1,1,1,1,1,1,\r
+ 1,1,1,1,1,1,1,1,1,1,\r
+ 1,1,1,1,1,1,1,1,1,1,\r
+ 1,1,1,1,1,1,1,1,1,1,\r
+ 1,1,1,1,1,1,1,1,1,1, 0};\r
+ System.arraycopy(s, 0, t, 0, 10*10);\r
+ NyARRasterImageIO sink = new NyARRasterImageIO(W, H);\r
+ RleImage rle = new RleImage(bin.getWidth(),bin.getHeight());\r
+ RleLabelingTable table=createRelTable(rle,bin,sink);\r
+ for(int i=0;;i++){\r
+ int nof=i%table.number_of_fragment;\r
+ if(table._fragment_area[nof]==0){\r
+ continue;\r
+ }\r
+ drawLabelingImage(nof,rle,table,bin,sink);\r
+ Graphics g;\r
+ g=this.getGraphics();\r
+ g.drawImage(sink, 100, 100,100,100, this);\r
+ Thread.sleep(500);\r
+ }\r
+ }\r
+ public void drawLabelingImage(int id,RleImage rle, RleLabelingTable i_table,NyARBinRaster i_source,NyARRasterImageIO i_img)\r
+ {\r
+// RleImage rle = new RleImage(i_source.getWidth(),i_source.getHeight());\r
+// i_table.labeling(rle,0,10);\r
+ int p=0;\r
+ for(int i=0;i<H;i++){\r
+ for(int i2=0;i2<W;i2++){\r
+ i_img.setRGB(i2,i,0xffffff);\r
+ }\r
+ for(int i2=0;i2<rle.row_length[i];i2++){\r
+ for(int i3=rle.rle_img_l[rle.row_index[i]+i2];i3<rle.rle_img_r[rle.row_index[i]+i2];i3++)\r
+ {\r
+ int c=0x0000ff;\r
+ int tid=i_table._fragment_id[i_table.rle_img_id[p]];\r
+ if(tid==id){\r
+ c=0x00ff00;\r
+ }\r
+ i_img.setRGB(i3,i,c);\r
+ }\r
+ p++;\r
+ }\r
+ }\r
+\r
+ i_img.setRGB(i_table._flagment_entry_x[id],i_table._flagment_entry_y[id],0xff0000);\r
+// i_img.setRGB(i_table._flagment_entry_x[id]+1,i_table._flagment_entry_y[id],0xff0000);\r
+// i_img.setRGB(i_table._flagment_entry_x[id],i_table._flagment_entry_y[id]+1,0xff0000);\r
+// i_img.setRGB(i_table._flagment_entry_x[id]+1,i_table._flagment_entry_y[id]+1,0xff0000);\r
+ }\r
+ \r
+ public RleLabelingTable createRelTable(RleImage rle,NyARBinRaster i_source,NyARRasterImageIO i_img)\r
+ {\r
+ // RELイメージの作成\r
+ rle.toRel(i_source);\r
+ // 1行目のテーブル登録\r
+ RleLabelingTable table = new RleLabelingTable(10000);\r
+ table.labeling(rle,0,H);\r
+ return table;\r
+ }\r
+\r
+ public LabelingTest() throws NyARException\r
+ {\r
+ this.addWindowListener(new WindowAdapter() {\r
+ public void windowClosing(WindowEvent e)\r
+ {\r
+ System.exit(0);\r
+ }\r
+ });\r
+ }\r
+\r
+ public static void main(String[] args)\r
+ {\r
+ try {\r
+ LabelingTest app = new LabelingTest();\r
+ app.setVisible(true);\r
+ app.setBounds(0, 0, 640, 480);\r
+ app.drawImage();\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ class RleImage\r
+ {\r
+ int _width;\r
+\r
+ int _height;\r
+\r
+ // RELデータ\r
+ short[] rle_img_l;// RELのフラグメント左\r
+\r
+ short[] rle_img_r;// RELのフラグメント右\r
+\r
+ // Rowデータ\r
+ int[] row_index;\r
+\r
+ short[] row_length;\r
+\r
+ int rle_buf_size;\r
+\r
+ public RleImage(int i_width, int i_height)\r
+ {\r
+ final int size = i_width * i_height / 2;\r
+ // 1/2に圧縮できることを想定。\r
+ this.rle_img_l = new short[size]; // RELのフラグメント長\r
+ this.rle_img_r = new short[size]; // RELの開始位置\r
+ this.rle_buf_size = size;\r
+\r
+ this.row_index = new int[i_height];\r
+ this.row_length = new short[i_height];\r
+ this._width = i_width;\r
+ this._height = i_height;\r
+ return;\r
+ }\r
+\r
+ /**\r
+ * binラスタからRELに変換する\r
+ * \r
+ * @param i_bin_raster\r
+ */\r
+ public void toRel(NyARBinRaster i_bin_raster)\r
+ {\r
+ final int width = this._width;\r
+ final int height = this._height;\r
+ int[] in_buf = (int[]) i_bin_raster.getBufferReader().getBuffer();\r
+\r
+ short current = 0;\r
+ short r = -1;\r
+ for (int y = 0; y < height; y++) {\r
+ this.row_index[y] = current;\r
+ // 行確定開始\r
+ int row_index = y * width;\r
+ int x = row_index;\r
+ final int right_edge = (y + 1) * width - 1;\r
+ while (x < right_edge) {\r
+ // 暗点(0)スキャン\r
+ if (in_buf[x] != 0) {\r
+ x++;\r
+ continue;\r
+ }\r
+ // 暗点発見→暗点長を調べる\r
+ r = (short) (x - row_index);\r
+ this.rle_img_l[current] = r;\r
+ r++;// 暗点+1\r
+ x++;\r
+ while (x < right_edge) {\r
+ if (in_buf[x] != 0) {\r
+ // 明点(1)→暗点(0)配列終了>登録\r
+ this.rle_img_r[current] = r;\r
+ current++;\r
+ x++;// 次点の確認。\r
+ r = -1;// 右端の位置を0に。\r
+ break;\r
+ } else {\r
+ // 暗点(0)長追加\r
+ r++;\r
+ x++;\r
+ }\r
+ }\r
+ }\r
+ // 最後の1点だけ判定方法が少し違うの。\r
+ if (in_buf[x] != 0) {\r
+ // 明点→rカウント中なら暗点配列終了>登録\r
+ if (r >= 0) {\r
+ this.rle_img_r[current] = r;\r
+ current++;\r
+ }\r
+ } else {\r
+ // 暗点→カウント中でなければl1で追加\r
+ if (r >= 0) {\r
+ this.rle_img_r[current] = (short) (x + 1);\r
+ } else {\r
+ // 最後の1点の場合\r
+ this.rle_img_l[current] = (short) (width - 1);\r
+ this.rle_img_r[current] = (short) (width);\r
+ }\r
+ current++;\r
+ }\r
+ // 行確定\r
+ this.row_length[y] = (short) (current - this.row_index[y]);\r
+ }\r
+ }\r
+\r
+ public void fromRel(NyARBinRaster i_bin_raster)\r
+ {\r
+\r
+ }\r
+ }\r
+\r
+ // RleImageをラベリングする。\r
+ class RleLabelingTable\r
+ {\r
+ short[] rle_img_id;\r
+\r
+ short[] _fragment_id; // フラグメントラベルのインデクス\r
+\r
+ int[] _fragment_area; // フラグメントラベルの領域数\r
+\r
+ int[] _fragment_pos_x; // フラグメントラベルの位置\r
+\r
+ int[] _fragment_pos_y; // フラグメントラベルの位置\r
+\r
+ short[] _flagment_entry_x; // フラグメントラベルの位置\r
+\r
+ short[] _flagment_entry_y; // フラグメントラベルの位置\r
+\r
+ short number_of_fragment; // 現在のフラグメントの数\r
+\r
+ public RleLabelingTable(int i_max_fragment)\r
+ {\r
+ this.rle_img_id = new short[i_max_fragment];\r
+ this._fragment_id = new short[i_max_fragment];\r
+ this._fragment_area = new int[i_max_fragment];\r
+ this._fragment_pos_x = new int[i_max_fragment];\r
+ this._fragment_pos_y = new int[i_max_fragment];\r
+ this._flagment_entry_x = new short[i_max_fragment];\r
+ this._flagment_entry_y = new short[i_max_fragment];\r
+ }\r
+\r
+ private void addFragment(RleImage i_rel_img, short i_nof, int i_row_index, int i_rel_index)\r
+ {\r
+ this.rle_img_id[i_rel_index] = i_nof;// REL毎の固有ID\r
+ this._fragment_id[i_nof] = i_nof;\r
+ this._flagment_entry_x[i_nof] = i_rel_img.rle_img_l[i_rel_index];\r
+ this._flagment_entry_y[i_nof] = (short) i_row_index;\r
+ this._fragment_area[i_nof] = i_rel_img.rle_img_r[i_rel_index] - i_rel_img.rle_img_l[i_rel_index];\r
+ return;\r
+ }\r
+\r
+\r
+\r
+ // 指定した行のフラグメントをマージします。\r
+ public void labeling(RleImage i_rel_img, int i_top, int i_bottom)\r
+ {\r
+ short[] rle_l = i_rel_img.rle_img_l;\r
+ short[] rle_r = i_rel_img.rle_img_r;\r
+ short nof = this.number_of_fragment;\r
+ // 初段登録\r
+ int index = i_rel_img.row_index[i_top];\r
+ int eol = i_rel_img.row_length[i_top];\r
+ for (int i = index; i < index + eol; i++) {\r
+ // フラグメントID=フラグメント初期値、POS=Y値、RELインデクス=行\r
+ addFragment(i_rel_img, nof, i_top, i);\r
+ nof++;\r
+ // nofの最大値チェック\r
+ }\r
+ // 次段結合\r
+ for (int y = i_top+1; y < i_bottom; y++) {\r
+ int index_prev = i_rel_img.row_index[y - 1];\r
+ int eol_prev = index_prev + i_rel_img.row_length[y - 1];\r
+ index = i_rel_img.row_index[y];\r
+ eol = index + i_rel_img.row_length[y];\r
+\r
+ SCAN_CUR:for (int i = index; i < eol; i++) {\r
+ // index_prev,len_prevの位置を調整する\r
+ short id = -1;\r
+ //チェックすべきprevがあれば確認\r
+ SCAN_PREV: while (index_prev < eol_prev) {\r
+ if (rle_l[i] - rle_r[index_prev] > 0) {// 0なら8方位ラベリング\r
+ // prevがcurの左方にある→次のフラグメントを探索\r
+ index_prev++;\r
+ continue;\r
+ } else if (rle_l[index_prev] - rle_r[i] > 0) {// 0なら8方位ラベリングになる\r
+ // prevがcur右方にある→独立フラグメント\r
+ addFragment(i_rel_img, nof, y, i);\r
+ nof++;\r
+ // 次のindexをしらべる\r
+ continue SCAN_CUR;\r
+ }\r
+ // 結合対象->prevのIDをコピーして、対象フラグメントの情報を更新\r
+ id = this._fragment_id[this.rle_img_id[index_prev]];\r
+ this.rle_img_id[i] = id;\r
+ this._fragment_area[id] += (rle_r[i] - rle_l[i]);\r
+ // エントリポイントの情報をコピー\r
+ this._flagment_entry_x[id] = this._flagment_entry_x[this.rle_img_id[index_prev]];\r
+ this._flagment_entry_y[id] = this._flagment_entry_y[this.rle_img_id[index_prev]];\r
+ //多重リンクの確認\r
+\r
+ index_prev++;\r
+ while (index_prev < eol_prev) {\r
+ if (rle_l[i] - rle_r[index_prev] > 0) {// 0なら8方位ラベリング\r
+ // prevがcurの左方にある→prevはcurに連結していない。\r
+ break SCAN_PREV;\r
+ } else if (rle_l[index_prev] - rle_r[i] > 0) {// 0なら8方位ラベリングになる\r
+ // prevがcurの右方にある→prevはcurに連結していない。\r
+ index_prev--;\r
+ continue SCAN_CUR;\r
+ }\r
+ // prevとcurは連結している。\r
+ final short prev_id = this.rle_img_id[index_prev];\r
+ if (id != prev_id) {\r
+ this._fragment_area[id] += this._fragment_area[prev_id];\r
+ this._fragment_area[prev_id] = 0;\r
+ // 結合対象->現在のidをインデクスにセット\r
+ this._fragment_id[prev_id]=id;\r
+ // エントリポイントを訂正\r
+ if (this._flagment_entry_y[id] > this._flagment_entry_y[prev_id]) {\r
+ // 現在のエントリポイントの方が下にある。(何もしない)\r
+ }\r
+ if (this._flagment_entry_y[id] < this._flagment_entry_y[prev_id]) {\r
+ // 現在のエントリポイントの方が上にある。(エントリポイントの交換)\r
+ this._flagment_entry_y[id] = this._flagment_entry_y[prev_id];\r
+ this._flagment_entry_x[id] = this._flagment_entry_x[prev_id];\r
+ } else {\r
+ // 水平方向で小さい方がエントリポイント。\r
+ if (this._flagment_entry_x[id] > this._flagment_entry_x[prev_id]) {\r
+ this._flagment_entry_y[id] = this._flagment_entry_y[prev_id];\r
+ this._flagment_entry_x[id] = this._flagment_entry_x[prev_id];\r
+ }\r
+ }\r
+ }\r
+ index_prev++;\r
+ }\r
+ index_prev--;\r
+ break;\r
+ }\r
+ // curにidが割り当てられたかを確認\r
+ // 右端独立フラグメントを追加\r
+ if (id < 0) {\r
+ addFragment(i_rel_img, nof, y, i);\r
+ nof++;\r
+ }\r
+\r
+ }\r
+ }\r
+ // フラグメントの数を更新\r
+ this.number_of_fragment = nof;\r
+ }\r
}\r
- }\r
}\r
+\r
+// REL圧縮配列を作成\r
+// REL結合\r
+// 面積計算\r
+// 参照インデクス化\r
+// ラベルイメージ化\r
\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
import jp.nyatla.nyartoolkit.core.pickup.*;\r
import javax.media.Buffer;\r
import javax.media.format.VideoFormat;\r
import javax.media.util.BufferToImage;\r
+\r
+import java.awt.color.ColorSpace;\r
import java.awt.image.*;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.util.Date;\r
+\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.jmf.utils.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.NyIdMarkerPickup;\r
import jp.nyatla.nyartoolkit.core.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
import jp.nyatla.nyartoolkit.core.pickup.*;\r
-import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
import jp.nyatla.utils.j2se.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.*;\r
+import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
\r
public class PattPickupTest extends Frame implements JmfCaptureListener\r
{\r
private JmfCaptureDevice _capture;\r
\r
private JmfNyARRaster_RGB _capraster;\r
+ private int W=320;\r
+ private int H=240;\r
\r
- private NyARSquareDetector _detector;\r
\r
- protected INyARRasterFilter_RgbToBin _tobin_filter;\r
\r
private NyARBinRaster _bin_raster;\r
\r
private NyARSquareStack _stack = new NyARSquareStack(100);\r
-\r
+ private NyARSquareDetector_Rle detect;\r
public PattPickupTest() throws NyARException\r
{\r
setTitle("JmfCaptureTest");\r
this.setSize(640 + ins.left + ins.right, 480 + ins.top + ins.bottom);\r
JmfCaptureDeviceList dl = new JmfCaptureDeviceList();\r
this._capture = dl.getDevice(0);\r
- if (!this._capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_RGB, 320, 240, 30.0f)) {\r
- if (!this._capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_YUV, 320, 240, 30.0f)) {\r
+ if (!this._capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_RGB, W, H, 30.0f)) {\r
+ if (!this._capture.setCaptureFormat(JmfCaptureDevice.PIXEL_FORMAT_YUV, W, H, 30.0f)) {\r
throw new NyARException("キャプチャフォーマットが見つかりません。");\r
}\r
}\r
NyARParam ar_param = new NyARParam();\r
ar_param.loadARParamFromFile(PARAM_FILE);\r
- ar_param.changeScreenSize(320, 240);\r
- this._capraster = new JmfNyARRaster_RGB(320, 240, this._capture.getCaptureFormat());\r
+ ar_param.changeScreenSize(W, H);\r
+ this.detect=new NyARSquareDetector_Rle(ar_param.getDistortionFactor(),ar_param.getScreenSize());\r
+ this._capraster = new JmfNyARRaster_RGB(W, H, this._capture.getCaptureFormat());\r
this._capture.setOnCapture(this);\r
- this._detector = new NyARSquareDetector(ar_param.getDistortionFactor(), ar_param.getScreenSize());\r
- this._bin_raster = new NyARBinRaster(320, 240);\r
- this._tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110);\r
+ this._bin_raster = new NyARBinRaster(W, H);\r
return;\r
}\r
\r
return (int) Math.sqrt((lx1 * lx1) + (ly1 * ly1)) * (int) Math.sqrt(((lx2 * lx2) + (ly2 * ly2)));\r
}\r
\r
+ private final String data_file = "../Data/320x240ABGR.raw";\r
+\r
private INyARColorPatt _patt1 = new NyARColorPatt_O3(16, 16);\r
\r
- private INyARColorPatt _patt2 = new NyARColorPatt_Perspective(100,100);\r
+ private INyARColorPatt _patt2 = new NyARColorPatt_Perspective_O2(16,16,4,25);\r
\r
- private NyIdMarkerPickup _patt3 = new NyIdMarkerPickup();\r
+ private INyARColorPatt _patt3 = new NyARColorPatt_Perspective(16,16,4,25);\r
\r
- public void onUpdateBuffer(Buffer i_buffer)\r
+ public void draw(INyARRgbRaster i_raster)\r
{\r
try {\r
Insets ins = this.getInsets();\r
\r
{// ピックアップ画像の表示\r
// 矩形抽出\r
- this._capraster.setBuffer(i_buffer);\r
- this._tobin_filter.doFilter(this._capraster, this._bin_raster);\r
- this._detector.detectMarker(this._bin_raster, this._stack);\r
+ INyARRasterFilter_RgbToBin to_binfilter= new NyARRasterFilter_ARToolkitThreshold(110,i_raster.getBufferReader().getBufferType()); \r
+ to_binfilter.doFilter(i_raster, this._bin_raster);\r
+ this.detect.detectMarker(this._bin_raster, this._stack);\r
\r
int max_point = 0;\r
NyARSquare t = null;\r
// ど れ に し よ う か なー\r
for (int i = this._stack.getLength() - 1; i >= 0; i--) {\r
- NyARSquare sq = (NyARSquare) this._stack.getItem(i);\r
+ NyARSquare sq = this._stack.getItem(i);\r
int wp = getSQPoint(sq);\r
if (wp < max_point) {\r
continue;\r
}\r
t = sq;\r
}\r
+// NyARSquare t=new NyARSquare();\r
if (t != null) {\r
+ BufferedImage sink=new BufferedImage(this._patt1.getWidth(),this._patt1.getHeight(),ColorSpace.TYPE_RGB);\r
+ BufferedImage sink2=new BufferedImage(this._patt2.getWidth(),this._patt2.getHeight(),ColorSpace.TYPE_RGB);\r
+/* t.imvertex[0].x=(int)483.0639377595418;\r
+ t.imvertex[0].y=(int)303.17616747966747;\r
+\r
+ t.imvertex[1].x=(int)506.1019505415998;\r
+ t.imvertex[1].y=(int)310.5313224526344;\r
+\r
+ t.imvertex[2].x=(int)589.3605435960492;\r
+ t.imvertex[2].y=(int)258.46261716798523;\r
\r
- BufferedImageSink sink = new BufferedImageSink(this._patt1.getWidth(), this._patt1.getHeight());\r
- BufferedImageSink sink2 = new BufferedImageSink(this._patt2.getWidth(), this._patt2.getHeight());\r
-// BufferedImageSink sink3 = new BufferedImageSink(this._patt3.getWidth(), this._patt3.getHeight());\r
+ t.imvertex[3].x=(int)518.1385869954609;\r
+ t.imvertex[3].y=(int)325.1434618295405;\r
+*/ \r
Graphics g1,g2,g3;\r
{// ARToolkit\r
// 一番それっぽいパターンを取得\r
- this._patt1.pickFromRaster(this._capraster, t);\r
+ this._patt1.pickFromRaster(i_raster, t);\r
+ Date d2 = new Date();\r
+ for (int i = 0; i < 10000; i++) {\r
+ this._patt1.pickFromRaster(i_raster, t);\r
+ }\r
+ Date d = new Date();\r
+ System.out.println(d.getTime() - d2.getTime()); \r
+\r
+ \r
// パターンを書く\r
- sink.sinkFromRaster(this._patt1);\r
+ NyARRasterImageIO.copy(this._patt1,sink);\r
g1=sink.getGraphics();\r
g1.setColor(Color.red);\r
- g1.drawLine(this._patt1.getWidth()/2,0,this._patt1.getWidth()/2,this._patt1.getHeight());\r
- g1.drawLine(0,this._patt1.getHeight()/2,this._patt1.getWidth(),this._patt1.getHeight()/2);\r
}\r
{// 疑似アフィン変換\r
// 一番それっぽいパターンを取得\r
- this._patt2.pickFromRaster(this._capraster, t);\r
+ for(int i2=0;i2<5;i2++){\r
+ Date d2 = new Date();\r
+ for (int i = 0; i < 10000; i++) {\r
+ this._patt2.pickFromRaster(i_raster, t);\r
+ }\r
+ Date d = new Date();\r
+ System.out.println(d.getTime() - d2.getTime()); \r
// パターンを書く\r
- sink2.sinkFromRaster(this._patt2);\r
+ }\r
+ NyARRasterImageIO.copy(this._patt2,sink2); \r
g2=sink2.getGraphics();\r
g2.setColor(Color.red);\r
- g2.drawLine(this._patt1.getWidth()/2,0,this._patt1.getWidth()/2,this._patt1.getHeight());\r
- g2.drawLine(0,this._patt1.getHeight()/2,this._patt1.getWidth(),this._patt1.getHeight()/2);\r
- }\r
- {// IDマーカ\r
- NyIdMarkerPattern data =new NyIdMarkerPattern();\r
- NyIdMarkerParam param =new NyIdMarkerParam();\r
- \r
- // 一番それっぽいパターンを取得\r
- this._patt3.pickFromRaster(this._capraster, t,data,param);\r
- System.out.println("model="+data.model);\r
- System.out.println("domain="+data.ctrl_domain);\r
- System.out.println("maskl="+data.ctrl_mask);\r
- System.out.println("data= "+data.data[0]+","+data.data[1]+","+data.data[2]);\r
- // パターンを書く\r
-/* sink3.sinkFromRaster(this._patt3);\r
- g3=sink.getGraphics();\r
- g3.setColor(Color.red);\r
- g2.drawRect(10,10,10,10);\r
- g2.drawRect(80,10,10,10);\r
- g2.drawRect(10,80,10,10);\r
- g2.drawRect(80,80,10,10);*/\r
-// g2.drawLine(this._patt3.sv[0]-1,this._patt3.sv[1],this._patt3.sv[0]+1,this._patt3.sv[1]);\r
-// g2.drawLine(this._patt3.sv[0],this._patt3.sv[1]-1,this._patt3.sv[0],this._patt3.sv[1]+1);\r
-// g2.drawLine(this._patt3.sv[2]-1,this._patt3.sv[3],this._patt3.sv[2]+1,this._patt3.sv[3]);\r
-// g2.drawLine(this._patt3.sv[2],this._patt3.sv[3]-1,this._patt3.sv[2],this._patt3.sv[3]+1);\r
- \r
- BufferedImage img=new BufferedImage(45,256, BufferedImage.TYPE_INT_RGB);\r
-\r
- g.drawImage(img, ins.left, ins.top+240,45,256, null);\r
-/*\r
- g2.setColor(Color.blue);\r
- for (int i = 0; i < 225*4; i++) {\r
- g2.drawRect(this._patt3.vertex_x[i]-1,this._patt3.vertex_y[i]-1, 2, 2);\r
+ this._patt3.pickFromRaster(i_raster, t);\r
+ {//比較\r
+ int[] p2=(int[])this._patt2.getBufferReader().getBuffer();\r
+ int[] p3=(int[])this._patt3.getBufferReader().getBuffer();\r
+ for(int i=0;i<this._patt2.getHeight()*this._patt2.getWidth();i++){\r
+ if(p2[i]!=p3[i]){\r
+ System.out.print(i+",");\r
+ }\r
+ }\r
}\r
-*/ g2.setColor(Color.red);\r
+\r
}\r
g.drawImage(sink, ins.left + 320, ins.top, 128, 128, null);\r
- g.drawImage(sink2, ins.left + 320, ins.top + 128, 400, 400, null);\r
+ g.drawImage(sink2, ins.left + 320, ins.top + 128, 128, 128, null);\r
// g.drawImage(sink3, ins.left + 100, ins.top + 240, this._patt3.getWidth() * 10, this._patt3.getHeight() * 10, null);\r
}\r
\r
{// 撮影画像\r
- BufferToImage b2i = new BufferToImage((VideoFormat) i_buffer.getFormat());\r
- Image img = b2i.createImage(i_buffer);\r
- g.drawImage(img, ins.left, ins.top, this);\r
- g.setColor(Color.blue);\r
-\r
- \r
+ BufferedImage sink=new BufferedImage(i_raster.getWidth(),i_raster.getHeight(),ColorSpace.TYPE_RGB);\r
+ NyARRasterImageIO.copy(i_raster, sink);\r
+ g.drawImage(sink, ins.left, ins.top, this); \r
}\r
- /*\r
- * { //輪郭パターン NyARSquare s=new NyARSquare(); for(int i=0;i<4;i++){ s.imvertex[i].x=(int)t.sqvertex[i].x; s.imvertex[i].y=(int)t.sqvertex[i].y; }\r
- * //一番それっぽいパターンを取得 this._patt1.pickFromRaster(this._capraster,s); //パターンを書く BufferedImageSink sink=new\r
- * BufferedImageSink(this._patt1.getWidth(),this._patt1.getHeight()); sink.sinkFromRaster(this._patt1);\r
- * g.drawImage(sink,ins.left+320,ins.top+128,128,128,null); }\r
- */\r
+\r
{// 信号取得テスト\r
\r
}\r
e.printStackTrace();\r
}\r
}\r
+ public void onUpdateBuffer(Buffer i_buffer)\r
+ {\r
+ try {\r
+\r
+ {// ピックアップ画像の表示\r
+ // 矩形抽出\r
+ this._capraster.setBuffer(i_buffer);\r
+ draw(this._capraster);\r
+ }\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
\r
public void startCapture()\r
{\r
e.printStackTrace();\r
}\r
}\r
+ public void startImage()\r
+ {\r
+ try {\r
+ // 試験イメージの読み出し(320x240 BGRAのRAWデータ)\r
+ File f = new File(data_file);\r
+ FileInputStream fs = new FileInputStream(data_file);\r
+ byte[] buf = new byte[(int) f.length()*4];\r
+ fs.read(buf);\r
+ INyARRgbRaster ra = NyARRgbRaster_BGRA.wrap(buf, W, H);\r
+ draw(ra);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ }\r
\r
public static void main(String[] args)\r
{\r
try {\r
PattPickupTest mainwin = new PattPickupTest();\r
mainwin.setVisible(true);\r
- mainwin.startCapture();\r
+ //mainwin.startCapture();\r
+ mainwin.startImage();\r
} catch (Exception e) {\r
e.printStackTrace();\r
}\r