<classpath>\r
<classpathentry kind="src" path=""/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
- <classpathentry kind="lib" path="C:/Program Files/Java/Java3D/1.5.1/lib/ext/j3dcore.jar"/>\r
- <classpathentry kind="lib" path="C:/Program Files/Java/Java3D/1.5.1/lib/ext/j3dutils.jar"/>\r
- <classpathentry kind="lib" path="C:/Program Files/Java/Java3D/1.5.1/lib/ext/vecmath.jar"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/NyARToolKit"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.utils.jmf"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.utils.java3d"/>\r
<classpathentry kind="lib" path="C:/Program Files (x86)/JMF2.1.1e/lib/jmf.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/Java3D/1.5.1/lib/ext/j3dcore.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/Java3D/1.5.1/lib/ext/j3dutils.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/Java3D/1.5.1/lib/ext/vecmath.jar"/>\r
<classpathentry kind="output" path=""/>\r
</classpath>\r
--- /dev/null
+/*
+ * PROJECT: NyARToolkit JMF sample program.
+ * --------------------------------------------------------------------------------
+ * The MIT License
+ * Copyright (c) 2008 nyatla
+ * airmail(at)ebony.plala.or.jp
+ * http://nyatla.jp/nyartoolkit/
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package jp.nyatla.nyartoolkit.jmf.sample;
+
+import javax.media.*;
+
+import javax.media.util.BufferToImage;
+import javax.media.format.*;
+
+import jp.nyatla.nyartoolkit.NyARException;
+import jp.nyatla.nyartoolkit.jmf.utils.*;
+
+import java.awt.*;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import jp.nyatla.nyartoolkit.core.labeling.rlelabeling.RleLabelFragmentInfoStack;
+import jp.nyatla.nyartoolkit.core.param.NyARParam;
+import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster;
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.NyARRasterFilter_ARToolkitThreshold;
+import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareContourDetector;
+import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareContourDetector_Rle;
+
+/**
+ * VFM+ARToolkitテストプログラム
+ * カメラから取り込んだデータからマーカーを検出して、一致度と変換行列を表示します。
+ */
+public class LabelingViewer extends Frame implements JmfCaptureListener
+{
+ private static final long serialVersionUID = 6471434231970804953L;
+
+ private final String PARAM_FILE = "../../Data/camera_para.dat";
+
+ private JmfCaptureDevice _capture;
+
+
+ private JmfNyARRaster_RGB _raster;
+
+ public LabelingViewer() throws NyARException
+ {
+ setTitle("JmfCaptureTest");
+ setBounds(0, 0, 320 + 64, 240 + 64);
+ //キャプチャの準備
+ JmfCaptureDeviceList devlist=new JmfCaptureDeviceList();
+ this._capture=devlist.getDevice(0);
+ //JmfNyARRaster_RGBはYUVよりもRGBで高速に動作します。
+ 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("キャプチャフォーマットが見つかりません");
+ }
+ }
+ this._capture.setOnCapture(this);
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e)
+ {
+ System.exit(0);
+ }
+ });
+ //NyARToolkitの準備
+ NyARParam ar_param = new NyARParam();
+ ar_param.loadARParamFromFile(PARAM_FILE);
+ ar_param.changeScreenSize(320, 240);
+ this._raster = new JmfNyARRaster_RGB(320, 240,this._capture.getCaptureFormat());
+ this._detect=new NyARSquareContourDetector_Rle(ar_param.getDistortionFactor(),ar_param.getScreenSize());
+ this._filter = new NyARRasterFilter_ARToolkitThreshold(110, _raster.getBufferType());
+ //キャプチャイメージ用のラスタを準備
+ return;
+ }
+ private NyARSquareContourDetector_Rle _detect;
+ private NyARBinRaster _bi=new NyARBinRaster(320,240);
+ private NyARRasterFilter_ARToolkitThreshold _filter;
+ /**
+ * detectMarkerのコールバック関数
+ */
+ private class DetectSquareCB implements INyARSquareContourDetector.DetectMarkerCallback
+ {
+ public DetectSquareCB()
+ {
+ return;
+ }
+ /**
+ * 矩形が見付かるたびに呼び出されます。
+ * 発見した矩形のパターンを検査して、方位を考慮した頂点データを確保します。
+ */
+ public void onSquareDetect(INyARSquareContourDetector i_sender,int[] i_coordx,int[] i_coordy,int i_coor_num,int[] i_vertex_index) throws NyARException
+ {
+ }
+ }
+
+ public void onUpdateBuffer(Buffer i_buffer)
+ {
+ try {
+ NyARBinRaster bin = this._bi;
+ //キャプチャしたバッファをラスタにセット
+ this._raster.setBuffer(i_buffer);
+
+ //キャプチャしたイメージを表示用に加工
+ BufferToImage b2i = new BufferToImage((VideoFormat) i_buffer.getFormat());
+ Image img = b2i.createImage(i_buffer);
+ this._filter.doFilter(this._raster,bin);
+
+ Graphics g = getGraphics();
+
+ NyARParam param=new NyARParam();
+ param.loadARParamFromFile(PARAM_FILE);
+ param.changeScreenSize(320,240);
+ try{
+ this._detect.detectMarkerCB(bin,new DetectSquareCB());
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ RleLabelFragmentInfoStack ls=this._detect._getFragmentStack();
+ for(int i=0;i<ls.getLength();i++){
+ RleLabelFragmentInfoStack.RleLabelFragmentInfo label=ls.getItem(i);
+// if(label.area==0){break;}
+ Graphics g2=img.getGraphics();
+ g2.setColor(Color.RED);
+ g2.drawRect(label.clip_l,label.clip_t,label.clip_r-label.clip_l,label.clip_b-label.clip_t);
+ }
+
+
+ g.drawImage(img,50,50,null);
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ private void startCapture()
+ {
+ try {
+ this._capture.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ try {
+ LabelingViewer mainwin = new LabelingViewer();
+ mainwin.setVisible(true);
+ mainwin.startCapture();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
ar_param.loadARParamFromFile(PARAM_FILE);
ar_param.changeScreenSize(320, 240);
this._raster = new JmfNyARRaster_RGB(320, 240,this._capture.getCaptureFormat());
- this._nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0,this._raster.getBufferReader().getBufferType());
+ this._nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0,this._raster.getBufferType());
ar_code.loadARPattFromFile(CARCODE_FILE);
//キャプチャイメージ用のラスタを準備
return;
Graphics g = getGraphics();
//マーカー検出
- boolean is_marker_exist = this._nya.detectMarkerLite(this._raster, 100);
+ boolean is_marker_exist = this._nya.detectMarkerLite(this._raster, 110);
if (is_marker_exist) {
//変換行列を取得
this._nya.getTransmationMatrix(this._trans_mat_result);
}
- //情報を画面に書く
- g.drawImage(img, 32, 32, this);
+ //情報を画面に書く
+ Graphics image_g=img.getGraphics();
+ image_g.setColor(Color.red);
if (is_marker_exist) {
- g.drawString("マーカー検出:" + this._nya.getConfidence(), 32, 50);
- g.drawString("[m00]" +this._trans_mat_result.m00, 32, 50 + 16*1);
- g.drawString("[m01]" +this._trans_mat_result.m01, 32, 50 + 16*2);
- g.drawString("[m02]" +this._trans_mat_result.m02, 32, 50 + 16*3);
- g.drawString("[m03]" +this._trans_mat_result.m03, 32, 50 + 16*4);
- g.drawString("[m10]" +this._trans_mat_result.m10, 32, 50 + 16*5);
- g.drawString("[m11]" +this._trans_mat_result.m11, 32, 50 + 16*6);
- g.drawString("[m12]" +this._trans_mat_result.m12, 32, 50 + 16*7);
- g.drawString("[m13]" +this._trans_mat_result.m13, 32, 50 + 16*8);
- g.drawString("[m20]" +this._trans_mat_result.m20, 32, 50 + 16*9);
- g.drawString("[m21]" +this._trans_mat_result.m21, 32, 50 + 16*10);
- g.drawString("[m22]" +this._trans_mat_result.m22, 32, 50 + 16*11);
- g.drawString("[m23]" +this._trans_mat_result.m23, 32, 50 + 16*12);
+ image_g.drawString("マーカー検出:" + this._nya.getConfidence(), 4, 20);
+ image_g.drawString("[m00]" +this._trans_mat_result.m00, 4, 20 + 16*1);
+ image_g.drawString("[m01]" +this._trans_mat_result.m01, 4, 20 + 16*2);
+ image_g.drawString("[m02]" +this._trans_mat_result.m02, 4, 20 + 16*3);
+ image_g.drawString("[m03]" +this._trans_mat_result.m03, 4, 20 + 16*4);
+ image_g.drawString("[m10]" +this._trans_mat_result.m10, 4, 20 + 16*5);
+ image_g.drawString("[m11]" +this._trans_mat_result.m11, 4, 20 + 16*6);
+ image_g.drawString("[m12]" +this._trans_mat_result.m12, 4, 20 + 16*7);
+ image_g.drawString("[m13]" +this._trans_mat_result.m13, 4, 20 + 16*8);
+ image_g.drawString("[m20]" +this._trans_mat_result.m20, 4, 20 + 16*9);
+ image_g.drawString("[m21]" +this._trans_mat_result.m21, 4, 20 + 16*10);
+ image_g.drawString("[m22]" +this._trans_mat_result.m22, 4, 20 + 16*11);
+ image_g.drawString("[m23]" +this._trans_mat_result.m23, 4, 20 + 16*12);
} else {
g.drawString("マーカー未検出:", 32, 100);
}
+ g.drawImage(img, 32, 32, this);
} catch (Exception e) {
e.printStackTrace();
}
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 = new NyARSingleDetectMarker(this._ar_param, i_ar_code, 80.0,this._cap_image.getBufferType());\r
this._nya.setContinueMode(false);// ここをtrueにすると、transMatContinueモード(History計算)になります。\r
\r
// 3Dを描画するコンポーネント\r
public void display(GLAutoDrawable drawable)\r
{\r
NyARTransMatResult transmat_result = __display_transmat_result;\r
- if (!_cap_image.hasData()) {\r
+ if (!_cap_image.hasBuffer()) {\r
return;\r
}\r
// 背景を書く\r
//GL対応のRGBラスタオブジェクト\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 = new NyARDetectMarker(this._ar_param, ar_codes, width, 2,this._cap_image.getBufferType());\r
this._nya.setContinueMode(false);//ここをtrueにすると、transMatContinueモード(History計算)になります。\r
//NyARToolkit用の支援クラス\r
this._glnya = new NyARGLUtil(_gl);\r
NyARTransMatResult transmat_result=__display_transmat_result;\r
\r
try {\r
- if (!_cap_image.hasData()) {\r
+ if (!_cap_image.hasBuffer()) {\r
return;\r
}\r
_gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame. \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=new MarkerProcessor(i_cparam,this._cap_image.getBufferType());\r
this._processor.setARCodeTable(_code_table,16,80.0);\r
\r
//OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)\r
public void display(GLAutoDrawable drawable)\r
{\r
NyARTransMatResult transmat_result = this._processor.transmat;\r
- if (!_cap_image.hasData()) {\r
+ if (!_cap_image.hasBuffer()) {\r
return;\r
}\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
this._cap_image = new GLNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat()); \r
\r
//プロセッサの準備\r
- this._processor=new MarkerProcessor(i_cparam,100,this._cap_image.getBufferReader().getBufferType());\r
+ this._processor=new MarkerProcessor(i_cparam,100,this._cap_image.getBufferType());\r
\r
//OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)\r
Frame frame = new Frame("Java simpleLite with NyARToolkit");\r
public void display(GLAutoDrawable drawable)\r
{\r
NyARTransMatResult transmat_result = this._processor.transmat;\r
- if (!_cap_image.hasData()) {\r
+ if (!_cap_image.hasBuffer()) {\r
return;\r
}\r
// 背景を書く\r
<?xml version="1.0" encoding="UTF-8"?>\r
<classpath>\r
- <classpathentry path="" kind="src"/>\r
- <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/>\r
- <classpathentry path="C:/Program Files/JMF2.1.1e/lib/jmf.jar" kind="lib"/>\r
- <classpathentry path="C:/Program Files/QuickTime/QTSystem/QTJava.zip" kind="lib"/>\r
- <classpathentry path="/NyARToolKit" combineaccessrules="false" kind="src"/>\r
- <classpathentry path="/NyARToolkit.utils.qt" combineaccessrules="false" kind="src"/>\r
- <classpathentry path="bin" kind="output"/>\r
+ <classpathentry kind="src" path=""/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolKit"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.utils.qt"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/jre6/lib/ext/QTJava.zip"/>\r
+ <classpathentry kind="output" path="bin"/>\r
</classpath>\r
import jp.nyatla.nyartoolkit.NyARException;
import jp.nyatla.nyartoolkit.qt.utils.*;
import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.WritableRaster;
+
import jp.nyatla.nyartoolkit.core.*;
import jp.nyatla.nyartoolkit.core.param.NyARParam;
import jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult;
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;
import jp.nyatla.nyartoolkit.detector.NyARSingleDetectMarker;
/**
* VFM+ARToolkitテストプログラム
ar_param.loadARParamFromFile(PARAM_FILE);
ar_param.changeScreenSize(320, 240);
raster = new QtNyARRaster_RGB(320, 240);
- nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0,raster.getBufferReader().getBufferType());
+ nya = new NyARSingleDetectMarker(ar_param, ar_code, 80.0,raster.getBufferType());
ar_code.loadARPattFromFile(CARCODE_FILE);
//キャプチャイメージ用のラスタを準備
}
{
try {
//キャプチャしたバッファをラスタにセット
- raster.setBuffer(pixels);
-
- //キャプチャしたイメージを表示用に加工
- Image img = raster.createImage();
+ raster.wrapBuffer(pixels);
+
+ Image img;
+ {
+ //キャプチャしたイメージを表示用に加工
+ NyARIntSize s=raster.getSize();
+ WritableRaster wr = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE, s.w,s.h, s.w * 3, 3, new int[] { 0, 1, 2 }, null);
+ BufferedImage bi = new BufferedImage(s.w, s.h, BufferedImage.TYPE_3BYTE_BGR);
+
+ wr.setDataElements(0, 0, s.w, s.h,raster.getBuffer());
+ bi.setData(wr);
+ img=bi;
+ }
Graphics g = getGraphics();
nya.getTransmationMatrix(this.trans_mat_result);
}
//情報を画面に書く
- g.drawImage(img, 32, 32, this);
+ Graphics image_g=img.getGraphics();
+ image_g.setColor(Color.red);
if (is_marker_exist) {
- g.drawString("マーカー検出:" + nya.getConfidence(), 32, 50);
- g.drawString("[m00]" + this.trans_mat_result.m00, 32, 50 + 16 * 1);
- g.drawString("[m01]" + this.trans_mat_result.m01, 32, 50 + 16 * 2);
- g.drawString("[m02]" + this.trans_mat_result.m02, 32, 50 + 16 * 3);
- g.drawString("[m03]" + this.trans_mat_result.m03, 32, 50 + 16 * 4);
- g.drawString("[m10]" + this.trans_mat_result.m10, 32, 50 + 16 * 5);
- g.drawString("[m11]" + this.trans_mat_result.m11, 32, 50 + 16 * 6);
- g.drawString("[m12]" + this.trans_mat_result.m12, 32, 50 + 16 * 7);
- g.drawString("[m13]" + this.trans_mat_result.m13, 32, 50 + 16 * 8);
- g.drawString("[m20]" + this.trans_mat_result.m20, 32, 50 + 16 * 9);
- g.drawString("[m21]" + this.trans_mat_result.m21, 32, 50 + 16 * 10);
- g.drawString("[m22]" + this.trans_mat_result.m22, 32, 50 + 16 * 11);
- g.drawString("[m23]" + this.trans_mat_result.m23, 32, 50 + 16 * 12);
-
+ image_g.drawString("マーカー検出:" + nya.getConfidence(), 4, 20);
+ image_g.drawString("[m00]" + this.trans_mat_result.m00, 4, 20 + 16 * 1);
+ image_g.drawString("[m01]" + this.trans_mat_result.m01, 4, 20 + 16 * 2);
+ image_g.drawString("[m02]" + this.trans_mat_result.m02, 4, 20 + 16 * 3);
+ image_g.drawString("[m03]" + this.trans_mat_result.m03, 4, 20 + 16 * 4);
+ image_g.drawString("[m10]" + this.trans_mat_result.m10, 4, 20 + 16 * 5);
+ image_g.drawString("[m11]" + this.trans_mat_result.m11, 4, 20 + 16 * 6);
+ image_g.drawString("[m12]" + this.trans_mat_result.m12, 4, 20 + 16 * 7);
+ image_g.drawString("[m13]" + this.trans_mat_result.m13, 4, 20 + 16 * 8);
+ image_g.drawString("[m20]" + this.trans_mat_result.m20, 4, 20 + 16 * 9);
+ image_g.drawString("[m21]" + this.trans_mat_result.m21, 4, 20 + 16 * 10);
+ image_g.drawString("[m22]" + this.trans_mat_result.m22, 4, 20 + 16 * 11);
+ image_g.drawString("[m23]" + this.trans_mat_result.m23, 4, 20 + 16 * 12);
} else {
- g.drawString("マーカー未検出:", 32, 100);
+ image_g.drawString("マーカー未検出:", 32, 100);
}
+ g.drawImage(img, 32, 32, this);
} catch (Exception e) {
e.printStackTrace();
}
import jp.nyatla.nyartoolkit.NyARException;
import jp.nyatla.nyartoolkit.qt.utils.*;
+import jp.nyatla.nyartoolkit.core.types.*;
import java.awt.*;
+import java.awt.image.*;
/**
* QuickTimeキャプチャプログラム
*
+ * On windows, You might get couldntGetRequiredComponent error.
+ * If you got error try to install WinVDIG.
+ * http://www.eden.net.nz/7/20071008/
+ * --
+ * Windowsの場合、WinVDIGが無いとキャプチャプログラムが動かないことがあります。
+ * couldntGetRequiredComponentエラーが出たら、WinVDIGをインストールしてみてね。
+ * WinVIDGはとりあえずここから入手可能。http://www.eden.net.nz/7/20071008/
+ *
+ *
*/
public class QtCaptureTest extends Frame implements QtCaptureListener
{
}
private QtCameraCapture capture;
-
private QtNyARRaster_RGB raster;
-
+
public void onUpdateBuffer(byte[] pixels)
{
- raster.setBuffer(pixels);
- Image img = raster.createImage();
+ try{
+ this.raster.wrapBuffer(pixels);
+ }catch(Exception e){
+ e.printStackTrace();
+ return;
+ }
+ //Imageに変換してみよう!
+
+
+ NyARIntSize s=raster.getSize();
+ WritableRaster wr = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE, s.w,s.h, s.w * 3, 3, new int[] { 0, 1, 2 }, null);
+ BufferedImage bi = new BufferedImage(s.w, s.h, BufferedImage.TYPE_3BYTE_BGR);
+
+ wr.setDataElements(0, 0, s.w, s.h,raster.getBuffer());
+ bi.setData(wr);
+
Graphics g = getGraphics();
- g.drawImage(img, 32, 32, this);
+ g.drawImage(bi, 32, 32, this);
}
private void startCapture()
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.types.stack.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
\r
/**\r
* QRコードの4頂点候補を探そうとするクラス。\r
{\r
private NyARIntRectStack _result;\r
\r
- public NyARRasterDetector_QrCodeEdge(int i_result_max)\r
+ public NyARRasterDetector_QrCodeEdge(int i_result_max) throws NyARException\r
{\r
this._result = new NyARIntRectStack(i_result_max);\r
return;\r
} \r
public void analyzeRaster(INyARRaster i_input) throws NyARException\r
{\r
- INyARBufferReader buffer_reader=i_input.getBufferReader();\r
- assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
\r
// 結果をクリア\r
this._result.clear();\r
w1 = b1 = w2 = b2 = w3 = b3 = 0;\r
\r
NyARIntRect item;\r
- int[] raster_buf=(int[])buffer_reader.getBuffer();\r
+ int[] raster_buf=(int[])i_input.getBuffer();\r
int line_ptr;\r
int s_pos, b2_spos,b3_spos;\r
b2_spos=0;\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.analyzer.raster.threshold.INyARRasterThresholdAnalyzer;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
/**\r
\r
public int analyzeRaster(INyARRaster i_input) throws NyARException\r
{\r
- final INyARBufferReader buffer_reader=i_input.getBufferReader(); \r
- assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] histgram = new int[256];\r
- return createHistgram((int[])buffer_reader.getBuffer(),i_input.getSize(), histgram);\r
+ return createHistgram((int[])i_input.getBuffer(),i_input.getSize(), histgram);\r
}\r
\r
/**\r
*/\r
public void debugDrawHistgramMap(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
- assert (in_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
NyARIntSize size = i_output.getSize();\r
\r
- int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
// 0で塗りつぶし\r
for (int y = 0; y < size.h; y++) {\r
for (int x = 0; x < size.w; x++) {\r
}\r
// ヒストグラムを計算\r
int[] histgram = new int[256];\r
- int threshold = createHistgram((int[])in_buffer_reader.getBuffer(),i_input.getSize(), histgram);\r
+ int threshold = createHistgram((int[])i_input.getBuffer(),i_input.getSize(), histgram);\r
\r
// ヒストグラムの最大値を出す\r
int max_v = 0;\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.INyARRasterFilter;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
{\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
- assert (in_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
\r
- int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
- int[] in_buf = (int[]) in_buffer_reader.getBuffer();\r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
+ int[] in_buf = (int[]) i_input.getBuffer();\r
\r
int bp = 0;\r
NyARIntSize size = i_output.getSize();\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
public NyARRasterOperator_Mul(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._dofilterimpl=new IdoFilterImpl_INT1D_GRAY_8();\r
break;\r
default:\r
{\r
assert (i_input_a.getSize().isEqualSize(i_output.getSize()) == true);\r
assert (i_input_b.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._dofilterimpl.doFilter(i_input_a.getBufferReader(),i_input_b.getBufferReader(),i_output.getBufferReader(),i_output.getSize());\r
+ this._dofilterimpl.doFilter(i_input_a,i_input_b,i_output,i_output.getSize());\r
}\r
\r
abstract class IdoFilterImpl\r
{\r
int[] _window_ref;\r
- public abstract void doFilter(INyARBufferReader i_input_a,INyARBufferReader i_input_b,INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public abstract void doFilter(INyARRaster i_input_a,INyARRaster i_input_b,INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
\r
}\r
class IdoFilterImpl_INT1D_GRAY_8 extends IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input_a,INyARBufferReader i_input_b,INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input_a,INyARRaster i_input_b,INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert(i_input_a.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert(i_input_b.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_input_a.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_input_b.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
int[] in_buf1 = (int[]) i_input_a.getBuffer();\r
package jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.raster.NyARGrayscaleRaster;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
* f(x):=exp(-x^2/s^2) 窓関数\r
* p :=Y*f(cr)*f(cb)\r
*/\r
-public class NyARRasterFilter_Rgb2Gs_CbCrCut implements INyARRasterFilter_RgbToGs\r
+public class NyARRasterFilter_Rgb2Gs_CbCrCut implements INyARRasterFilter_Rgb2Gs\r
{\r
private IdoFilterImpl _dofilterimpl;\r
/**\r
public NyARRasterFilter_Rgb2Gs_CbCrCut(int i_raster_type,double i_sigma) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
default:\r
throw new NyARException();\r
}\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._dofilterimpl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
abstract class IdoFilterImpl\r
{\r
int[] _window_ref;\r
- public abstract void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public abstract void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
\r
}\r
class IdoFilterImpl_BYTE1D_B8G8R8_24 extends IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
- assert( i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert( i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ assert( i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_Rgb2Gs;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
-public class NyARRasterFilter_Rgb2Gs_RgbOr implements INyARRasterFilter_RgbToGs\r
+public class NyARRasterFilter_Rgb2Gs_RgbOr implements INyARRasterFilter_Rgb2Gs\r
{\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
- assert( out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert( i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
\r
- final int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
- final byte[] in_buf = (byte[]) in_buffer_reader.getBuffer();\r
+ final int[] out_buf = (int[]) i_output.getBuffer();\r
+ final byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
NyARIntSize size = i_output.getSize();\r
- switch (in_buffer_reader.getBufferType()) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ switch (i_input.getBufferType()) {\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
convert24BitRgb(in_buf, out_buf, size);\r
break;\r
default:\r
*/\r
package jp.nyatla.nyartoolkit.core.types;\r
\r
-import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARFixedFloat16Point3d;\r
import jp.nyatla.nyartoolkit.core.types.NyARI64Point3d;\r
\r
*/\r
package jp.nyatla.nyartoolkit.core.types.matrix;\r
\r
-import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.NyARFixedFloat24Matrix33;\r
import jp.nyatla.nyartoolkit.core.types.matrix.NyARI64Matrix33;\r
\r
final int[] xcoord = this._xcoord;\r
final int[] ycoord = this._ycoord;\r
final int coord_max = this._max_coord;\r
- final int[] buf = (int[]) limage.getBufferReader().getBuffer();\r
+ final int[] buf = (int[]) limage.getBuffer();\r
final int[] indextable = limage.getIndexArray();\r
\r
int label_area;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
/**\r
* 平均移動法を使った2値化フィルタ\r
* \r
*/\r
-public class NyARRasterFilter_QrAreaAverage implements INyARRasterFilter_GsToBin\r
+public class NyARRasterFilter_QrAreaAverage implements INyARRasterFilter_Gs2Bin\r
{\r
private int _area = 8;\r
\r
public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output) throws NyARException\r
{\r
final NyARIntSize size = i_output.getSize();\r
- final int[] out_buf = (int[]) i_output.getBufferReader().getBuffer();\r
- final int[] in_buf = (int[]) i_input.getBufferReader().getBuffer();\r
+ final int[] out_buf = (int[]) i_output.getBuffer();\r
+ final int[] in_buf = (int[]) i_input.getBuffer();\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
assert (size.h % 8 == 0 && size.w % 8 == 0);//暫定実装なので。\r
\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.squaredetect.INyARSquareContourDetector;\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
\r
/**\r
* 画像からARCodeに最も一致するマーカーを1個検出し、その変換行列を計算するクラスです。\r
private NyARBinRaster _bin_raster;\r
private NyARGrayscaleRaster _gs_raster;\r
//画処理フィルター\r
- private INyARRasterFilter_RgbToGs _rgb2gs_filter=new NyARRasterFilter_RgbAve();\r
- private INyARRasterFilter_GsToBin _gstobin_filter=new NyARRasterFilter_QrAreaAverage();\r
+ private INyARRasterFilter_Rgb2Gs _rgb2gs_filter=new NyARRasterFilter_Rgb2Gs_AveAdd();\r
+ private INyARRasterFilter_Gs2Bin _gstobin_filter=new NyARRasterFilter_QrAreaAverage();\r
\r
/**\r
* i_imageにマーカー検出処理を実行し、結果を記録します。\r
import jp.nyatla.nyartoolkit.core.raster.*;
import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistgram;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.*;
+import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;
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.nyartoolkit.core.types.*;
-import jp.nyatla.nyartoolkit.core2.rasteranalyzer.threshold.*;
this.getGraphics().drawImage(img, 32, 32, this);
// 画像1
- INyARRasterFilter_RgbToGs filter_rgb2gs = new NyARRasterFilter_RgbAve();
+ INyARRasterFilter_Rgb2Gs filter_rgb2gs = new NyARRasterFilter_AveAdd();
// INyARRasterFilter_RgbToGs filter_rgb2gs = new NyARRasterFilter_RgbMul();
filter_rgb2gs.doFilter(_raster, _gsraster1);
this._bimg.drawImage(this._gsraster1);
this.getGraphics().drawImage(this._bimg, 32 + 320, 32, 320 + 320 + 32, 240 + 32, 0, 240, 320, 0, this);
_tha.analyzeRaster(_gsraster1);
- NyARRasterFilter_Threshold gs2bin=new NyARRasterFilter_Threshold(_tha.getThreshold());
+ NyARRasterFilter_ConstantThreshold gs2bin=new NyARRasterFilter_ConstantThreshold(_tha.getThreshold());
// 画像2
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin.*;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
\r
/**\r
* 1/4のサイズの画像に変換しながら閾値判定する関数\r
* \r
*/\r
-public class NyARRasterFilter_ARTTh_Quad implements INyARRasterFilter_Bin\r
+public class NyARRasterFilter_ARTTh_Quad implements INyARRasterFilter_Rgb2Bin\r
{\r
private int _threshold;\r
\r
\r
public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output) throws NyARException\r
{\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader();\r
- int in_buf_type=in_buffer_reader.getBufferType();\r
+ int in_buf_type=i_input.getBufferType();\r
\r
NyARIntSize size = i_output.getSize();\r
- assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
assert (checkInputType(in_buf_type)==true); \r
assert (i_input.getSize().isEqualSize(size.w*2,size.h*2) == true);\r
\r
- int[] out_buf = (int[]) out_buffer_reader.getBuffer();\r
- byte[] in_buf = (byte[]) in_buffer_reader.getBuffer();\r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
+ byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
- switch (in_buffer_reader.getBufferType()) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ switch (i_input.getBufferType()) {\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
convert24BitRgb(in_buf, out_buf, size);\r
break;\r
// case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
private boolean checkInputType(int i_input_type) throws NyARException\r
{\r
switch(i_input_type){\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
-// case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
-// case INyARBufferReader.BUFFERFORMAT_BYTE1D_R5G6B5_16LE:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+// case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+// case INyARRaster.BUFFERFORMAT_BYTE1D_R5G6B5_16LE:\r
return true;\r
default:\r
return false;\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
+ _nya = new NyARSingleDetectMarker_X2(_ar_param, ar_code, 80.0,this._cap_image.getBufferType());\r
_nya.setContinueMode(false);//ここをtrueにすると、transMatContinueモード(History計算)になります。\r
//キャプチャ開始\r
_capture.start();\r
{\r
NyARTransMatResult transmat_result=__display_transmat_result;\r
try {\r
- if (!_cap_image.hasData()) {\r
+ if (!_cap_image.hasBuffer()) {\r
return;\r
}\r
_gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame. \r
import jp.nyatla.nyartoolkit.core.raster.*;
import jp.nyatla.nyartoolkit.core.rasteranalyzer.threshold.NyARRasterThresholdAnalyzer_DiffHistgram;
import jp.nyatla.nyartoolkit.core.rasterfilter.*;
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_Rgb2Gs;
import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquareStack;
import jp.nyatla.nyartoolkit.core2.rasterfilter.rgb2gs.*;
import jp.nyatla.nyartoolkit.core2.rasterfilter.gs2bin.*;
this.getGraphics().drawImage(img, 32, 32, this);
// 画像1
- INyARRasterFilter_RgbToGs filter_rgb2gs = new NyARRasterFilter_RgbAve();
+ INyARRasterFilter_Rgb2Gs filter_rgb2gs = new NyARRasterFilter_RgbAve();
// INyARRasterFilter_RgbToGs filter_rgb2gs = new NyARRasterFilter_RgbMul();
filter_rgb2gs.doFilter(_raster, _gsraster1);
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+\r
+import java.awt.color.ColorSpace;\r
import java.awt.image.BufferedImage;\r
\r
\r
-public class NyARRGBRaster_BufferedImage implements INyARRgbRaster\r
+public class NyARRGBRaster_BufferedImage extends NyARRgbRaster_BasicClass\r
{\r
- protected INyARRgbPixelReader _reader;\r
- protected INyARBufferReader _buffer_reader; \r
- final protected NyARIntSize _size;\r
- final public int getWidth()\r
+ private INyARRgbPixelReader _reader;\r
+ private BufferedImage _buf; \r
+ \r
+ /**\r
+ * バッファオブジェクトがアタッチされていればtrue\r
+ */\r
+ protected boolean _is_attached_buffer;\r
+ public NyARRGBRaster_BufferedImage(int i_width, int i_height,boolean i_is_alloc) throws NyARException\r
{\r
- return this._size.w;\r
+ super( new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_OBJECT_Java_BufferedImage);\r
+ if(!initInstance(this._size,i_is_alloc)){\r
+ throw new NyARException();\r
+ }\r
}\r
-\r
- final public int getHeight()\r
+ public NyARRGBRaster_BufferedImage(int i_width, int i_height) throws NyARException\r
{\r
- return this._size.h;\r
+ super( new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_OBJECT_Java_BufferedImage);\r
+ if(!initInstance(this._size,true)){\r
+ throw new NyARException();\r
+ }\r
}\r
+ protected boolean initInstance(NyARIntSize i_size,boolean i_is_alloc)\r
+ {\r
+ this._buf=i_is_alloc?new BufferedImage(i_size.w,i_size.h, ColorSpace.TYPE_RGB):null;\r
+ this._reader=new PixelReader((BufferedImage)this._buf);\r
+ this._is_attached_buffer=i_is_alloc;\r
+ return true;\r
+ } \r
+ \r
\r
- final public NyARIntSize getSize()\r
+ public INyARRgbPixelReader getRgbPixelReader() throws NyARException\r
{\r
- return this._size;\r
+ return this._reader;\r
}\r
- /**\r
- * i_imageをラップするRGBラスタを定義する。\r
- * @param i_image\r
- */\r
- protected NyARRGBRaster_BufferedImage(BufferedImage i_image)\r
+ public Object getBuffer()\r
{\r
- this._buffer_reader=new NyARBufferReader(i_image,INyARBufferReader.BUFFERFORMAT_OBJECT_Java_BufferedImage);\r
- this._reader=new PixelReader(i_image);\r
- this._size= new NyARIntSize(i_image.getWidth(),i_image.getHeight());\r
+ return this._buf;\r
}\r
- public INyARRgbPixelReader getRgbPixelReader() throws NyARException\r
+ public boolean hasBuffer()\r
{\r
- return this._reader;\r
+ return this._buf!=null;\r
}\r
- public INyARBufferReader getBufferReader()\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
{\r
- return this._buffer_reader;\r
+ assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。\r
+ BufferedImage buf=(BufferedImage)i_ref_buf;\r
+ assert(buf.getWidth()==this._size.w && buf.getHeight()==this._size.h);\r
+ this._buf=buf;\r
+ //ピクセルリーダーの参照バッファを切り替える。\r
+ this._reader.switchBuffer(i_ref_buf);\r
}\r
\r
\r
{\r
NyARException.notImplement(); \r
}\r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ this._ref_buf = (BufferedImage)i_ref_buffer;\r
+ }\r
\r
} \r
\r
<?xml version="1.0" encoding="UTF-8"?>\r
<classpath>\r
- <classpathentry path="" kind="src"/>\r
- <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/>\r
- <classpathentry path="/NyARToolKit" combineaccessrules="false" kind="src"/>\r
- <classpathentry path="C:/Program Files/Java/Java3D/1.5.1/lib/ext/j3dcore.jar" kind="lib"/>\r
- <classpathentry path="C:/Program Files/Java/Java3D/1.5.1/lib/ext/j3dutils.jar" kind="lib"/>\r
- <classpathentry path="C:/Program Files/Java/Java3D/1.5.1/lib/ext/vecmath.jar" kind="lib"/>\r
- <classpathentry path="C:/Program Files/JMF2.1.1e/lib/jmf.jar" kind="lib"/>\r
- <classpathentry path="/NyARToolkit.utils.jmf" combineaccessrules="false" kind="src"/>\r
- <classpathentry path="" kind="output"/>\r
+ <classpathentry kind="src" path=""/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolKit"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.utils.jmf"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/Java3D/1.5.1/lib/ext/j3dcore.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/Java3D/1.5.1/lib/ext/j3dutils.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/Java3D/1.5.1/lib/ext/vecmath.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/JMF2.1.1e/lib/jmf.jar"/>\r
+ <classpathentry kind="output" path=""/>\r
</classpath>\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
import jp.nyatla.nyartoolkit.jmf.utils.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
/**\r
* \r
* このクラスは、Java3Dと互換性のあるNyARToolkitのラスタイメージを保持します。\r
*/\r
public void setBuffer(javax.media.Buffer i_buffer) throws NyARException\r
{\r
- this._reader.changeBuffer(i_buffer);\r
+ super.setBuffer(i_buffer);\r
synchronized (this){\r
//キャプチャデータをi2dのバッファにコピーする。\r
//現在はJmfNyARRaster_RGBでRGB画像がノーマライズされているので、\r
//ここでもう一度flipする。(これ省略したいなあ…。)\r
- byte[] src=(byte[])this._reader.getBuffer();\r
+ byte[] src=(byte[])this.getBuffer();\r
final int length = this._size.w * 3;\r
int src_idx = 0;\r
int dest_idx = (this._size.h - 1) * length; \r
{\r
super(i_cparam.getScreenSize(),i_format);\r
//bufferdimageの種類を決める\r
- if(this._reader.getBufferType()!=INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24){\r
+ if(this.getBufferType()!=INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24){\r
throw new NyARException();\r
}\r
//RGBのラスタを作る。\r
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,this._nya_raster.getBufferReader().getBufferType());\r
+ this._nya = new NyARSingleDetectMarker(this._cparam, i_ar_code, i_marker_width,this._nya_raster.getBufferType());\r
this._nya_behavior = new NyARBehavior(this._nya, this._nya_raster, i_rate);\r
}\r
\r
raster.renewImageComponent2D();/*DirectXモードのときの対策*/\r
back_ground.setImage(raster.getImageComponent2D());\r
}\r
- if (raster.hasData()) {\r
+ if (raster.hasBuffer()) {\r
is_marker_exist = related_nya.detectMarkerLite(raster, 100);\r
if (is_marker_exist)\r
{\r
+++ /dev/null
-/* \r
- * PROJECT: NyARToolkit JMF utilities.\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.jmf.utils;\r
-\r
-import javax.media.*;\r
-import javax.media.protocol.*;\r
-import javax.media.control.*;\r
-import javax.media.format.*;\r
-import java.awt.*;\r
-import java.util.*;\r
-import javax.media.protocol.DataSource;\r
-\r
-import jp.nyatla.nyartoolkit.NyARException;\r
-\r
-/**\r
- * 簡易JMFキャプチャクラス\r
- * @deprecated このクラスは近い将来削除します。\r
- * JmfCaptureDeviceList/JmfCaptureDeviceを使用してください。\r
- * {@link #JmfCaptureDeviceList()}\r
- *\r
- */\r
-@Deprecated public class JmfCameraCapture\r
-{\r
- private Dimension image_size;\r
-\r
- private JmfCaptureListener capture_listener;\r
-\r
- // private DataSource jmf_data_source;\r
- private MonitorStream jmf_monitor_stream;\r
-\r
- private Processor jmf_processor;\r
-\r
- private VideoFormat jmf_video_format;\r
-\r
- private Buffer read_buf = new Buffer();\r
-\r
- public static final String PIXEL_FORMAT_RGB = "RGB";\r
-\r
- public JmfCameraCapture(int i_width, int i_height, float i_rate, String i_pixcel_format)\r
- {\r
- String encoding = i_pixcel_format;// comboEncoding.getSelectedItem();\r
- image_size = new Dimension(i_width, i_height);\r
- jmf_video_format = new VideoFormat(encoding, image_size, Format.NOT_SPECIFIED, null, i_rate);\r
- }\r
-\r
- public Dimension getSize()\r
- {\r
- return image_size;\r
- }\r
-\r
- public javax.media.Buffer readBuffer() throws NyARException\r
- {\r
- if (jmf_monitor_stream == null) {\r
- throw new NyARException();\r
- }\r
- try {\r
- jmf_monitor_stream.read(read_buf);\r
- } catch (Exception e) {\r
- throw new NyARException(e);\r
- }\r
- return read_buf;\r
- }\r
-\r
- public void setCaptureListener(JmfCaptureListener i_listener) throws NyARException\r
- {\r
- if (jmf_processor != null)\r
- {\r
- throw new NyARException();\r
- }\r
- capture_listener = i_listener;\r
-\r
- }\r
-\r
- public void start() throws NyARException\r
- {\r
-\r
- DataSource ds = getCaptureDS(jmf_video_format);\r
- VideoFormat[] formats = new VideoFormat[] { new VideoFormat(null) };\r
- ProcessorModel pm = new ProcessorModel(ds, formats, null);// ,\r
- // formats,\r
- // ftd);\r
- Processor processor;\r
- try {\r
- processor = Manager.createRealizedProcessor(pm);\r
- } catch (Exception e) {\r
- // Make sure the capture devices are released\r
- ds.disconnect();\r
- throw new NyARException(e);\r
- }\r
- // Get the monitor control:\r
- // Since there are more than one MonitorControl objects\r
- // exported by the DataSource, we get the specific one\r
- // that is also the MonitorStream object.\r
- jmf_monitor_stream = (MonitorStream) ds.getControl("jmfsample.MonitorStream");\r
- jmf_monitor_stream.setCaptureListener(capture_listener);\r
- // jmf_data_source=ds;\r
- jmf_processor = processor;\r
- jmf_processor.start();\r
- }\r
-\r
- public void stop()\r
- {\r
- jmf_processor.stop();\r
- jmf_processor.close();\r
- jmf_processor = null;\r
-\r
- }\r
-\r
- protected void finalize()\r
- {\r
- if (jmf_processor != null) {\r
- jmf_processor.stop();\r
- jmf_processor.close();\r
- jmf_processor = null;\r
- }\r
- }\r
-\r
- private static DataSource getCaptureDS(VideoFormat vf)\r
- {\r
- DataSource dsVideo = null;\r
- DataSource ds = null;\r
-\r
- // Create a capture DataSource for the video\r
- // If there is no video capture device, then exit with null\r
- if (vf != null) {\r
- dsVideo = createDataSource(vf);\r
- if (dsVideo == null)\r
- return null;\r
- }\r
-\r
- // Create the monitoring datasource wrapper\r
- if (dsVideo != null) {\r
- dsVideo = new MonitorCDS(dsVideo);\r
- return dsVideo;\r
- }\r
-\r
- // Merge the data sources, if both audio and video are available\r
- try {\r
- ds = Manager.createMergingDataSource(new DataSource[] { dsVideo });\r
- } catch (IncompatibleSourceException ise) {\r
- return null;\r
- }\r
-\r
- return ds;\r
- }\r
-\r
- private static DataSource createDataSource(Format format)\r
- {\r
- DataSource ds;\r
- Vector devices;\r
- CaptureDeviceInfo cdi;\r
- MediaLocator ml;\r
-\r
- // Find devices for format\r
- devices = CaptureDeviceManager.getDeviceList(format);\r
- if (devices.size() < 1) {\r
- System.err.println("! No Devices for " + format);\r
- return null;\r
- }\r
- // Pick the first device\r
- cdi = (CaptureDeviceInfo) devices.elementAt(0);\r
-\r
- ml = cdi.getLocator();\r
-\r
- try {\r
- ds = Manager.createDataSource(ml);\r
- ds.connect();\r
- if (ds instanceof CaptureDevice) {\r
- setCaptureFormat((CaptureDevice) ds, format);\r
- }\r
- } catch (Exception e) {\r
- System.err.println(e);\r
- return null;\r
- }\r
- return ds;\r
- }\r
-\r
- private static void setCaptureFormat(CaptureDevice cdev, Format format)\r
- {\r
- FormatControl[] fcs = cdev.getFormatControls();\r
- if (fcs.length < 1) {\r
- return;\r
- }\r
- FormatControl fc = fcs[0];\r
- Format[] formats = fc.getSupportedFormats();\r
- for (int i = 0; i < formats.length; i++) {\r
- if (formats[i].matches(format)) {\r
- format = formats[i].intersects(format);\r
- fc.setFormat(format);\r
- break;\r
- }\r
- }\r
- }\r
-}
\ No newline at end of file
*/\r
public class JmfCaptureDeviceList\r
{\r
- private Vector _devices;\r
+ private Vector<CaptureDeviceInfo> _devices;\r
\r
public JmfCaptureDeviceList() throws NyARException\r
- {\r
- this._devices = (Vector) CaptureDeviceManager.getDeviceList(null).clone();\r
+ { \r
+ this._devices = (Vector<CaptureDeviceInfo>)(CaptureDeviceManager.getDeviceList(null).clone());\r
// ビデオソースのデバイスだけ残す\r
try {\r
\r
for (int i = 0; i < this._devices.size();) {\r
- CaptureDeviceInfo cdi = (CaptureDeviceInfo) this._devices.elementAt(i);\r
+ CaptureDeviceInfo cdi =this._devices.elementAt(i);\r
// VideoFormatもってるかな?\r
if (!isCaptureDevice(cdi)) {\r
this._devices.remove(i);\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
\r
\r
+\r
+\r
+/**\r
+ * \r
+ * RGB形式のJMFバッファをラップするNyARRasterです。\r
+ * JMFから得たラスタデータのピクセル並び順を考慮します。\r
+ *\r
+ */\r
+public class JmfNyARRaster_RGB implements INyARRgbRaster\r
+{\r
+ private JmfRGB24RasterHolder _holder;\r
+ protected NyARIntSize _size;\r
+\r
+ /**\r
+ * i_fmtに一致する画素フォーマットのRasterを作成します。\r
+ * このコンストラクタで作成したクラスは、hasBuffer()がfalseを返すことがあります。\r
+ * @param i_width\r
+ * @param i_height\r
+ * @param i_fmt\r
+ * @throws NyARException\r
+ */\r
+ public JmfNyARRaster_RGB(int i_width,int i_height,VideoFormat i_fmt) throws NyARException\r
+ {\r
+ initMember(i_width,i_height,i_fmt);\r
+ }\r
+ /**\r
+ * i_fmtに一致する画素フォーマットのRasterを作成します。\r
+ * このコンストラクタで作成したクラスは、hasBuffer()がfalseを返すことがあります。\r
+ * @param i_size\r
+ * @param i_fmt\r
+ * @throws NyARException\r
+ */\r
+ public JmfNyARRaster_RGB(NyARIntSize i_size,VideoFormat i_fmt) throws NyARException\r
+ {\r
+ initMember(i_size.w,i_size.h,i_fmt);\r
+ }\r
+ private void initMember(int i_width,int i_height,VideoFormat i_fmt) throws NyARException\r
+ {\r
+ this._size= new NyARIntSize(i_width,i_height);\r
+ // データサイズの確認\r
+ final Dimension s = i_fmt.getSize();\r
+ if (!this._size.isEqualSize(s.width,s.height)) {\r
+ throw new NyARException();\r
+ }\r
+ // データ配列の確認\r
+ if(i_fmt instanceof YUVFormat){\r
+ //YUVフォーマット\r
+ this._holder=new NyARGLPixelReader_YUV(this._size,(YUVFormat)i_fmt); \r
+ }else if(i_fmt instanceof RGBFormat){\r
+ //RGBフォーマット\r
+ this._holder=new NyARGLPixelReader_RGB24(this._size,(RGBFormat)i_fmt);\r
+ }else{\r
+ throw new NyARException();\r
+ } \r
+ }\r
+ public void setBuffer(javax.media.Buffer i_buffer) throws NyARException\r
+ {\r
+ this._holder.setMediaBuffer(i_buffer);\r
+ return;\r
+ }\r
+ final public int getWidth()\r
+ {\r
+ return this._size.w;\r
+ }\r
+\r
+ final public int getHeight()\r
+ {\r
+ return this._size.h;\r
+ }\r
+\r
+ final public NyARIntSize getSize()\r
+ {\r
+ return this._size;\r
+ }\r
+ final public int getBufferType()\r
+ {\r
+ return this._holder.buffer_type;\r
+ }\r
+ final public INyARRgbPixelReader getRgbPixelReader()\r
+ {\r
+ return this._holder;\r
+ }\r
+ /**\r
+ * インスタンスがバッファを所有するかを返します。\r
+ * @return\r
+ */ \r
+ final public boolean hasBuffer()\r
+ {\r
+ return this._holder.buffer!=null;\r
+ }\r
+ final public Object getBuffer()\r
+ {\r
+ assert(this._holder.buffer!=null);\r
+ return this._holder.buffer;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return this._holder.buffer_type==i_type_value;\r
+ }\r
+ final public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ }\r
+ /**\r
+ * @deprecated hasBuffer()関数を使ってください。\r
+ * \r
+ */\r
+ final public boolean hasData()\r
+ {\r
+ return this.hasBuffer();\r
+ }\r
+\r
+}\r
+\r
+\r
+/**\r
+ * JMFと汎用バッファを中継する拡張INyARRgbPixelReader\r
+ * @author nyatla\r
+ *\r
+ */\r
+abstract class JmfRGB24RasterHolder implements INyARRgbPixelReader\r
+{\r
+ public int buffer_type;\r
+ public byte[] buffer;\r
+ public abstract void setMediaBuffer(javax.media.Buffer i_buffer);\r
+}\r
+\r
/**\r
* RGB24フォーマットのデータを扱うピクセルリーダ\r
*/\r
-class NyARBufferReader_Reader_RGB24 extends NyARBufferReader_Reader\r
+class NyARGLPixelReader_RGB24 extends JmfRGB24RasterHolder\r
{\r
protected boolean _is_flipped;\r
- public NyARBufferReader_Reader_RGB24(RGBFormat i_input_format,NyARIntSize i_ref_size) throws NyARException\r
+ private NyARIntSize _ref_size;\r
+ public NyARGLPixelReader_RGB24(NyARIntSize i_ref_size,RGBFormat i_input_format) throws NyARException\r
{\r
- super(i_ref_size);\r
+ this._ref_size=i_ref_size;\r
//ピクセルフォーマットを設定(現状は24bitRGBを受けつける。)\r
RGBFormat fm=(RGBFormat)i_input_format;\r
if(fm.getBitsPerPixel()!=24){\r
int r=fm.getRedMask();\r
int b=fm.getBlueMask();\r
if(r==1 && b==3){\r
- this._buf_type=BUFFERFORMAT_BYTE1D_R8G8B8_24;\r
+ this.buffer_type=INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24;\r
}else if(r==3 && b==1){\r
- this._buf_type=BUFFERFORMAT_BYTE1D_B8G8R8_24; \r
+ this.buffer_type=INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24; \r
}else{\r
throw new NyARException();\r
}\r
//vertical反転の有無を確認\r
this._is_flipped=i_input_format.getFlipped()!=0?true:false;\r
- this._ref_buf=new byte[i_ref_size.w*i_ref_size.h*3];\r
+ this.buffer=new byte[i_ref_size.w*i_ref_size.h*3];\r
//RGBフォーマット\r
\r
return;\r
}\r
- public void changeBuffer(javax.media.Buffer i_buffer)\r
+ public void setMediaBuffer(javax.media.Buffer i_buffer)\r
{\r
//vertical反転が必要ならば、反転した画像を作成する。\r
byte[] src=(byte[])i_buffer.getData();\r
int src_idx = 0;\r
int dest_idx = (this._ref_size.h - 1) * length; \r
for (int i = 0; i < this._ref_size.h; i++) {\r
- System.arraycopy(src,src_idx, this._ref_buf, dest_idx, length);\r
+ System.arraycopy(src,src_idx, this.buffer, dest_idx, length);\r
src_idx += length;\r
dest_idx -= length;\r
}\r
}else{\r
- System.arraycopy(src,0,this._ref_buf,0,this._ref_buf.length);\r
- this._ref_buf=(byte[])i_buffer.getData();\r
+ System.arraycopy(src,0,this.buffer,0,this.buffer.length);\r
+ this.buffer=(byte[])i_buffer.getData();\r
}\r
return;\r
}\r
public void getPixel(int i_x, int i_y, int[] o_rgb) throws NyARException\r
{\r
int bp = (i_x + i_y * this._ref_size.w) * 3;\r
- byte[] ref = this._ref_buf;\r
- switch(this._buf_type){\r
- case BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ byte[] ref = this.buffer;\r
+ switch(this.buffer_type){\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
o_rgb[0] = (ref[bp + 0] & 0xff);// R\r
o_rgb[1] = (ref[bp + 1] & 0xff);// G\r
o_rgb[2] = (ref[bp + 2] & 0xff);// B\r
break;\r
- case BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
o_rgb[0] = (ref[bp + 2] & 0xff);// B\r
o_rgb[1] = (ref[bp + 1] & 0xff);// G\r
o_rgb[2] = (ref[bp + 0] & 0xff);// R\r
public void getPixelSet(int[] i_x, int i_y[], int i_num, int[] o_rgb) throws NyARException\r
{\r
int width = this._ref_size.w;\r
- byte[] ref = this._ref_buf;\r
+ byte[] ref = this.buffer;\r
int bp;\r
- switch(this._buf_type){\r
- case BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ switch(this.buffer_type){\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
for (int i = i_num - 1; i >= 0; i--) {\r
bp = (i_x[i] + i_y[i] * width) * 3;\r
o_rgb[i * 3 + 0] = (ref[bp + 0] & 0xff);// R\r
o_rgb[i * 3 + 2] = (ref[bp + 2] & 0xff);// B\r
}\r
break;\r
- case BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
for (int i = i_num - 1; i >= 0; i--) {\r
bp = (i_x[i] + i_y[i] * width) * 3;\r
o_rgb[i * 3 + 0] = (ref[bp + 2] & 0xff);// B\r
{\r
NyARException.notImplement(); \r
}\r
+ public void switchBuffer(Object i_ref_object) throws NyARException\r
+ {\r
+ NyARException.notImplement(); \r
+ }\r
\r
}\r
\r
* ソースデータをセットした時に変換します。\r
* (将来YUVをそのまま素通りさせるように書き換えるかも)\r
*/\r
-class NyARBufferReader_Reader_YUV extends NyARBufferReader_Reader\r
+class NyARGLPixelReader_YUV extends JmfRGB24RasterHolder\r
{\r
- \r
+ private NyARIntSize _ref_size; \r
private YUVToRGB _yuv2rgb;\r
+\r
private javax.media.Buffer _rgb_buf;\r
/**\r
* フォーマットアレイから、BGR24フォーマットを探す\r
}\r
return null;\r
}\r
- public NyARBufferReader_Reader_YUV(YUVFormat i_input_format,NyARIntSize i_ref_size) throws NyARException\r
+ public NyARGLPixelReader_YUV(NyARIntSize i_ref_size,YUVFormat i_input_format) throws NyARException\r
{\r
- super(i_ref_size,BUFFERFORMAT_BYTE1D_B8G8R8_24);\r
+ this._ref_size=i_ref_size;\r
+ this.buffer_type=INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24;\r
+ this.buffer=null;\r
this._yuv2rgb=new YUVToRGB();\r
this._rgb_buf=new javax.media.Buffer();\r
- this._ref_buf=null;\r
//24bit-BGRフォーマットのものを探す\r
Format output_format=pickRGB24Format(this._yuv2rgb.getSupportedOutputFormats(i_input_format));\r
if(output_format==null){\r
}\r
return;\r
}\r
- public void changeBuffer(javax.media.Buffer i_buffer)\r
+ public void setMediaBuffer(javax.media.Buffer i_buffer)\r
{\r
//エラー出した時のトラップ\r
if(this._yuv2rgb.process(i_buffer, this._rgb_buf)!=YUVToRGB.BUFFER_PROCESSED_OK){\r
System.err.println("YUVToRGB.process error:");\r
}\r
- this._ref_buf=(byte[])this._rgb_buf.getData();\r
+ this.buffer=(byte[])this._rgb_buf.getData();\r
return;\r
}\r
public void getPixel(int i_x, int i_y, int[] o_rgb) throws NyARException\r
//IN :BGRBGR\r
// :012012\r
final int bp = (i_x + i_y * this._ref_size.w) * 3;\r
- final byte[] ref = this._ref_buf;\r
+ final byte[] ref = this.buffer;\r
o_rgb[0] = (ref[bp + 2] & 0xff);// R\r
o_rgb[1] = (ref[bp + 1] & 0xff);// G\r
o_rgb[2] = (ref[bp + 0] & 0xff);// B\r
{\r
int bp;\r
final int width = this._ref_size.w;\r
- final byte[] ref = this._ref_buf;\r
+ final byte[] ref = this.buffer;\r
for (int i = i_num - 1; i >= 0; i--) {\r
bp = (i_x[i] + i_y[i] * width) * 3;\r
o_rgb[i * 3 + 0] = (ref[bp + 2] & 0xff);// R\r
{\r
NyARException.notImplement(); \r
}\r
- \r
-}\r
-\r
-\r
-/**\r
- * \r
- * RGB形式のJMFバッファをラップするNyARRasterです。\r
- * JMFから得たラスタデータのピクセル並び順を考慮します。\r
- *\r
- */\r
-public class JmfNyARRaster_RGB extends NyARRgbRaster_BasicClass\r
-{\r
-\r
- protected NyARBufferReader_Reader _reader;\r
- /**\r
- * i_formatに一致する画素フォーマットの\r
- * @param i_size\r
- * @param i_format\r
- * @throws NyARException\r
- */\r
-\r
-\r
- public JmfNyARRaster_RGB(NyARIntSize i_ref_size,VideoFormat i_format) throws NyARException\r
+ public void switchBuffer(Object i_ref_object) throws NyARException\r
{\r
- super(new NyARIntSize(i_ref_size)); \r
- this._reader = createReader(i_format);\r
- }\r
- public JmfNyARRaster_RGB(int i_width,int i_height,VideoFormat i_format) throws NyARException\r
- {\r
- super(new NyARIntSize(i_width,i_height));\r
- this._reader = createReader(i_format);\r
- }\r
- \r
- /**\r
- * フォーマットを解析して、マッチするリーダオブジェクトを返します。\r
- * @param i_fmt\r
- * ビデオフォーマットを指定します。\r
- * @return\r
- * リーダオブジェクト\r
- * @throws NyARException\r
- */\r
- private NyARBufferReader_Reader createReader(VideoFormat i_fmt) throws NyARException\r
- {\r
- // データサイズの確認\r
- final Dimension s = i_fmt.getSize();\r
- if (!this._size.isEqualSize(s.width, s.height)) {\r
- throw new NyARException();\r
- }\r
- // データ配列の確認\r
- if(i_fmt instanceof YUVFormat){\r
- //YUVフォーマット\r
- return new NyARBufferReader_Reader_YUV((YUVFormat)i_fmt,this._size); \r
- }else if(i_fmt instanceof RGBFormat){\r
- //RGBフォーマット\r
- return new NyARBufferReader_Reader_RGB24((RGBFormat)i_fmt,this._size);\r
- }else{\r
- throw new NyARException();\r
- }\r
- }\r
-\r
- /**\r
- * javax.media.Bufferを分析して、その分析結果をNyARRasterに適合する形で保持します。\r
- * 関数実行後に外部でi_bufferの内容変更した場合には、再度setBuffer関数を呼び出してください。\r
- * この関数を実行すると、getRgbPixelReaderで取得したReaderのプロパティが変化することがあります。\r
- * @param i_buffer\r
- * RGB形式のデータを格納したjavax.media.Bufferオブジェクトを指定してください。\r
- * @return i_bufferをラップしたオブジェクトを返します。\r
- * @throws NyARException\r
- */\r
- public void setBuffer(javax.media.Buffer i_buffer) throws NyARException\r
- {\r
- this._reader.changeBuffer(i_buffer);\r
- return;\r
- }\r
- /**\r
- * データを持っているかを返します。\r
- * @return\r
- */\r
- public boolean hasData()\r
- {\r
- return this._reader._ref_buf != null;\r
- }\r
- public INyARRgbPixelReader getRgbPixelReader()\r
- {\r
- return this._reader;\r
- }\r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._reader;\r
- }\r
+ NyARException.notImplement(); \r
+ } \r
}\r
\r
-\r
-\r
+++ /dev/null
-/* \r
- * PROJECT: NyARToolkit JMF utilities.\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.jmf.utils;\r
-\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARRgbPixelReader;\r
-import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
-\r
-public abstract class NyARBufferReader_Reader implements INyARRgbPixelReader,INyARBufferReader\r
-{\r
- protected byte[] _ref_buf;\r
- protected NyARIntSize _ref_size;\r
- protected int _buf_type;\r
- protected NyARBufferReader_Reader(NyARIntSize i_ref_size,int i_buf_type)\r
- {\r
- this._ref_size =i_ref_size;\r
- this._buf_type=i_buf_type;\r
- return;\r
- }\r
- protected NyARBufferReader_Reader(NyARIntSize i_ref_size)\r
- {\r
- this._ref_size =i_ref_size;\r
- return;\r
- }\r
- final public Object getBuffer()\r
- {\r
- return this._ref_buf;\r
- }\r
- final public int getBufferType()\r
- {\r
- return this._buf_type;\r
- }\r
- final public boolean isEqualBufferType(int i_type_value)\r
- {\r
- return this._buf_type==i_type_value;\r
- }\r
- public abstract void changeBuffer(javax.media.Buffer i_buffer);\r
-\r
-}\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.jmf.utils.*;\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import javax.media.format.*;\r
\r
/**\r
public GLNyARRaster_RGB(NyARParam i_param,VideoFormat i_format) throws NyARException\r
{\r
super(i_param.getScreenSize(),i_format);\r
- switch(this._reader.getBufferType()){\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ initMember(this.getBufferType());\r
+ return;\r
+ }\r
+ public GLNyARRaster_RGB(int i_width,int i_height,VideoFormat i_format) throws NyARException\r
+ {\r
+ super(i_width,i_height,i_format);\r
+ initMember(this.getBufferType());\r
+ return;\r
+ } \r
+ private void initMember(int i_buffer_type) throws NyARException\r
+ {\r
+ switch(i_buffer_type){\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
this._gl_flag = GL.GL_BGR;\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
this._gl_flag = GL.GL_RGB;\r
break;\r
default:\r
*/\r
public byte[] getGLRgbArray()\r
{\r
- return (byte[])this._reader.getBuffer();\r
+ return (byte[])this.getBuffer();\r
}\r
\r
/**\r
{\r
return this._gl_flag;\r
}\r
+\r
}\r
<?xml version="1.0" encoding="UTF-8"?>\r
<classpath>\r
- <classpathentry path="" kind="src"/>\r
- <classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/>\r
- <classpathentry path="/NyARToolKit" combineaccessrules="false" kind="src"/>\r
- <classpathentry path="C:/Program Files/QuickTime/QTSystem/QTJava.zip" kind="lib"/>\r
- <classpathentry path="C:/Program Files/JMF2.1.1e/lib/jmf.jar" kind="lib"/>\r
- <classpathentry path="" kind="output"/>\r
+ <classpathentry kind="src" path=""/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolKit"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/JMF2.1.1e/lib/jmf.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/jre6/lib/ext/QTJava.zip"/>\r
+ <classpathentry kind="output" path=""/>\r
</classpath>\r
\r
}\r
\r
+ /**\r
+ * @param input\r
+ * @throws QTException\r
+ */\r
public void prepSetInput(Object input) throws QTException\r
{\r
QTSession.open();\r
} else {\r
grabber = new SequenceGrabber();\r
grabber.setGWorld(graphics, null);\r
+ //Please check WinVDIG if you got couldntGetRequiredComponent exception on Windows.\r
channel = new SGVideoChannel(grabber);\r
channel.setBounds(bounds);\r
\r
*/\r
package jp.nyatla.nyartoolkit.qt.utils;\r
\r
-import java.awt.image.BufferedImage;\r
-import java.awt.image.DataBuffer;\r
-import java.awt.image.WritableRaster;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.raster.rgb.NyARRgbRaster_BasicClass;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+\r
/**\r
* RGB形式のbyte配列をラップするNyARRasterです。\r
* 保持したデータからBufferedImageを出力する機能も持ちます。\r
*/\r
-public class QtNyARRaster_RGB extends NyARRgbRaster_BasicClass\r
+public class QtNyARRaster_RGB implements INyARRgbRaster\r
{\r
- private class PixcelReader extends NyARRgbPixelReader_RGB24 implements INyARBufferReader\r
- {\r
- public PixcelReader(NyARIntSize i_size)\r
- {\r
- super(null, i_size);\r
- return;\r
- }\r
-\r
- public void syncBuffer(byte[] i_ref_buffer)\r
- {\r
- this._ref_buf = i_ref_buffer;\r
- return;\r
- }\r
-\r
- //\r
- // INyARBufferReader\r
- //\r
- public Object getBuffer()\r
- {\r
- return this._ref_buf;\r
- }\r
-\r
- public int getBufferType()\r
- {\r
- return INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24;\r
- }\r
-\r
- public boolean isEqualBufferType(int i_type_value)\r
- {\r
- return i_type_value == INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24;\r
- }\r
- }\r
-\r
- protected byte[] _ref_buf;\r
-\r
- protected PixcelReader _reader;\r
-\r
- private WritableRaster _raster;\r
-\r
- private BufferedImage _image;\r
+ private NyARIntSize _size;\r
+ private byte[] _buffer;\r
+ private NyARRgbPixelReader_BYTE1D_R8G8B8_24 _reader;\r
+ private int _buffer_type;\r
\r
/**\r
- * RGB形式のJMFバッファをラップするオブジェクトをつくります。 生成直後のオブジェクトはデータを持ちません。 メンバ関数はsetBufferを実行後に使用可能になります。\r
+ * QuickTimeオブジェクトからイメージを取得するラスタオブジェクトを作ります。\r
+ * この\r
+ * @param i_width\r
+ * @param i_height\r
*/\r
public QtNyARRaster_RGB(int i_width, int i_height)\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = null;\r
- this._reader = new PixcelReader(this._size);\r
- _raster = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE, i_width, i_height, i_width * 3, 3, new int[] { 0, 1, 2 }, null);\r
- _image = new BufferedImage(i_width, i_height, BufferedImage.TYPE_3BYTE_BGR);\r
+ this._size=new NyARIntSize(i_width,i_height);\r
+ this._buffer= null;\r
+ this._buffer_type=INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24;\r
+ this._reader = new NyARRgbPixelReader_BYTE1D_R8G8B8_24(null,this._size);\r
}\r
-\r
- /**\r
- * javax.media.Bufferを分析して、その分析結果をNyARRasterに適合する形で保持します。 関数実行後に外部でi_bufferの内容変更した場合には、再度setBuffer関数を呼び出してください。\r
- * \r
- * @param i_buffer\r
- * RGB形式のデータを格納したjavax.media.Bufferオブジェクトを指定してください。\r
- * @return i_bufferをラップしたオブジェクトを返します。\r
- * @throws NyARException\r
- */\r
- public void setBuffer(byte[] i_buffer)\r
+ \r
+ final public int getWidth()\r
{\r
- this._ref_buf = i_buffer;\r
- this._reader.syncBuffer(i_buffer);\r
+ return this._size.w;\r
}\r
\r
- public INyARBufferReader getBufferReader()\r
+ final public int getHeight()\r
{\r
- return this._reader;\r
+ return this._size.h;\r
}\r
\r
- public INyARRgbPixelReader getRgbPixelReader()\r
+ final public NyARIntSize getSize()\r
+ {\r
+ return this._size;\r
+ }\r
+ final public int getBufferType()\r
+ {\r
+ return this._buffer_type;\r
+ }\r
+ final public INyARRgbPixelReader getRgbPixelReader()\r
{\r
return this._reader;\r
}\r
-\r
- /**\r
- * データを持っているかを返します。\r
- * \r
- * @return\r
- */\r
- public boolean hasData()\r
+ final public boolean hasBuffer()\r
{\r
- return this._ref_buf != null;\r
+ return this._buffer!=null;\r
+ }\r
+ final public Object getBuffer()\r
+ {\r
+ assert(this._buffer!=null);\r
+ return this._buffer;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return this._buffer_type==i_type_value;\r
+ }\r
+ final public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ this._buffer=(byte[])i_ref_buf;\r
+ this._reader.switchBuffer(i_ref_buf);\r
}\r
-\r
/**\r
- * 保持しているデータからBufferedImageを作って返します。\r
+ * @deprecated hasBuffer()関数を使ってください。\r
* \r
- * @return\r
*/\r
- public BufferedImage createImage()\r
+ final public boolean hasData()\r
{\r
- _raster.setDataElements(0, 0, this._size.w, this._size.h, this._ref_buf);\r
- _image.setData(_raster);\r
- return _image;\r
+ return this.hasBuffer();\r
}\r
-\r
}\r
import jp.nyatla.nyartoolkit.*;\r
import jp.nyatla.nyartoolkit.core.match.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
\r
class NyARCodeFileReader\r
{\r
StreamTokenizer st = new StreamTokenizer(new InputStreamReader(i_stream));\r
//GBRAで一度読みだす。\r
for (int h = 0; h < 4; h++) {\r
- assert o_raster[h].getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+ assert o_raster[h].isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
final NyARRaster ra=o_raster[h];\r
- readBlock(st,ra.getWidth(),ra.getHeight(),(int[])ra.getBufferReader().getBuffer());\r
+ readBlock(st,ra.getWidth(),ra.getHeight(),(int[])ra.getBuffer());\r
}\r
} catch (Exception e) {\r
throw new NyARException(e);\r
{\r
int width=o_code.getWidth();\r
int height=o_code.getHeight();\r
- NyARRaster tmp_raster=new NyARRaster(new NyARIntSize(width,height),INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+ NyARRaster tmp_raster=new NyARRaster(width,height,INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
//4個の要素をラスタにセットする。\r
try {\r
StreamTokenizer st = new StreamTokenizer(new InputStreamReader(i_stream));\r
- int[] buf=(int[])tmp_raster.getBufferReader().getBuffer();\r
+ int[] buf=(int[])tmp_raster.getBuffer();\r
//GBRAで一度読みだす。\r
for (int h = 0; h < 4; h++){\r
readBlock(st,width,height,buf);\r
package jp.nyatla.nyartoolkit.core.analyzer.raster;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.NyARRgbPixelReader_INT1D_X8R8G8B8_32;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.types.NyARHistgram;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
-import jp.nyatla.nyartoolkit.core.analyzer.histgram.*;\r
/**\r
* 画像のヒストグラムを計算します。\r
* RGBの場合、(R+G+B)/3のヒストグラムを計算します。\r
protected boolean initInstance(int i_raster_format,int i_vertical_interval)\r
{\r
switch (i_raster_format) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_BYTE1D_RGB_24();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_GRAY_8();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_BYTE1D_B8G8R8X8_32();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_BYTE1D_X8R8G8B8_32();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
+ case INyARRaster.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_WORD1D_R5G6B5_16LE();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32();\r
break;\r
default:\r
h[i] = 0;\r
}\r
o_histgram.total_of_data=size.w*size.h/this._vertical_skip;\r
- return this._histImpl.createHistgram(i_input.getBufferReader(), size,h,this._vertical_skip); \r
+ return this._histImpl.createHistgram(i_input, size,h,this._vertical_skip); \r
}\r
\r
interface ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip);\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip);\r
}\r
\r
class NyARRasterThresholdAnalyzer_Histgram_INT1D_GRAY_8 implements ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
{\r
- assert (i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
final int[] input=(int[]) i_reader.getBuffer();\r
for (int y = i_size.h-1; y >=0 ; y-=i_skip){\r
int pt=y*i_size.w;\r
}\r
class NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32 implements ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
{\r
- assert (i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32));\r
+ assert (i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32));\r
final int[] input=(int[]) i_reader.getBuffer();\r
for (int y = i_size.h-1; y >=0 ; y-=i_skip){\r
int pt=y*i_size.w;\r
\r
class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_RGB_24 implements ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
{\r
assert (\r
- i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24)||\r
- i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24));\r
+ i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24)||\r
+ i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24));\r
final byte[] input=(byte[]) i_reader.getBuffer();\r
final int pix_count=i_size.w;\r
final int pix_mod_part=pix_count-(pix_count%8);\r
\r
class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_B8G8R8X8_32 implements ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
{\r
- assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));\r
+ assert(i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));\r
byte[] input = (byte[])i_reader.getBuffer();\r
int pix_count = i_size.w;\r
int pix_mod_part = pix_count - (pix_count % 8);\r
\r
class NyARRasterThresholdAnalyzer_Histgram_BYTE1D_X8R8G8B8_32 implements ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
{\r
- assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_X8R8G8B8_32));\r
+ assert(i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_X8R8G8B8_32));\r
byte[] input = (byte[])i_reader.getBuffer();\r
int pix_count = i_size.w;\r
int pix_mod_part = pix_count - (pix_count % 8);\r
\r
class NyARRasterThresholdAnalyzer_Histgram_WORD1D_R5G6B5_16LE implements ICreateHistgramImpl\r
{\r
- public int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
+ public int createHistgram(INyARRaster i_reader,NyARIntSize i_size, int[] o_histgram,int i_skip)\r
{\r
- assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE));\r
+ assert(i_reader.isEqualBufferType(INyARRaster.BUFFERFORMAT_WORD1D_R5G6B5_16LE));\r
short[] input = (short[])i_reader.getBuffer();\r
int pix_count = i_size.w;\r
int pix_mod_part = pix_count - (pix_count % 8);\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
/**\r
*/\r
public class NyARLabelingImage extends NyARRaster_BasicClass\r
{\r
- private final static int MAX_LABELS = 1024*32; \r
+ private final static int MAX_LABELS = 1024*32;\r
+\r
protected int[] _ref_buf;\r
- private INyARBufferReader _buffer_reader;\r
protected NyARLabelingLabelStack _label_list;\r
protected int[] _index_table;\r
protected boolean _is_index_table_enable;\r
public NyARLabelingImage(int i_width, int i_height) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_INT1D);\r
this._ref_buf =new int[i_height*i_width];\r
this._label_list = new NyARLabelingLabelStack(MAX_LABELS);\r
this._index_table=new int[MAX_LABELS];\r
this._is_index_table_enable=false;\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_INT1D);\r
//生成時に枠を書きます。\r
drawFrameEdge();\r
return;\r
}\r
- public INyARBufferReader getBufferReader()\r
+ public Object getBuffer()\r
+ {\r
+ return this._ref_buf;\r
+ }\r
+ public boolean hasBuffer()\r
{\r
- return this._buffer_reader;\r
+ return this._ref_buf!=null;\r
}\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ } \r
/**\r
* エッジを書きます。\r
*/\r
}\r
//あれ?見つからないよ?\r
throw new NyARException();\r
- }\r
+ } \r
}\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
/**\r
*/\r
public int labeling(NyARBinRaster i_raster,NyARLabelingImage o_destination) throws NyARException\r
{\r
- assert(i_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ assert(i_raster.getBufferType()==INyARRaster.BUFFERFORMAT_INT1D_BIN_8);\r
int label_img_ptr1, label_pixel;\r
int i, j;\r
int n, k; /* work */\r
\r
final int lxsize = in_size.w;// lxsize = arUtil_c.arImXsize;\r
final int lysize = in_size.h;// lysize = arUtil_c.arImYsize;\r
- final int[] label_img = (int[]) o_destination.getBufferReader().getBuffer();\r
+ final int[] label_img = (int[]) o_destination.getBuffer();\r
\r
// 枠作成はインスタンスを作った直後にやってしまう。\r
\r
o_destination.reset(true);\r
\r
int[] label_idxtbl = o_destination.getIndexArray();\r
- int[] raster_buf = (int[]) i_raster.getBufferReader().getBuffer();\r
+ int[] raster_buf = (int[]) i_raster.getBuffer();\r
\r
int[] work2_pt;\r
int wk_max = 0;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.stack.NyObjectStack;\r
\r
class RleInfoStack extends NyObjectStack<RleInfoStack.RleInfo>\r
*/\r
public int labeling(NyARBinRaster i_bin_raster, int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
{\r
- assert(i_bin_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert(i_bin_raster.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
return this.imple_labeling(i_bin_raster,0,i_top,i_bottom,o_stack);\r
}\r
/**\r
*/\r
public int labeling(NyARGrayscaleRaster i_gs_raster,int i_th, int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
{\r
- assert(i_gs_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_gs_raster.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
return this.imple_labeling(i_gs_raster,i_th,i_top,i_bottom,o_stack);\r
}\r
private int imple_labeling(INyARRaster i_raster,int i_th,int i_top, int i_bottom,RleLabelFragmentInfoStack o_stack) throws NyARException\r
int len_prev = 0;\r
int len_current = 0;\r
final int width = i_raster.getWidth();\r
- int[] in_buf = (int[]) i_raster.getBufferReader().getBuffer();\r
+ int[] in_buf = (int[]) i_raster.getBuffer();\r
\r
int id_max = 0;\r
int label_count=0;\r
int ave;//<PV/>\r
int rgb;//<PV/>\r
final int[] linput=this._data;//<PV/>\r
- final int[] buf=(int[])i_raster.getBufferReader().getBuffer();\r
+ final int[] buf=(int[])i_raster.getBuffer();\r
\r
// input配列のサイズとwhも更新// input=new int[height][width][3];\r
final int number_of_pixels=this._number_of_pixels;\r
public void setRaster(INyARRaster i_raster)\r
{\r
//画素フォーマット、サイズ制限\r
- assert i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+ assert i_raster.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
assert i_raster.getSize().isEqualSize(i_raster.getSize());\r
\r
- final int[] buf=(int[])i_raster.getBufferReader().getBuffer();\r
+ final int[] buf=(int[])i_raster.getBuffer();\r
//i_buffer[XRGB]→差分[R,G,B]変換 \r
int i;\r
int ave;//<PV/>\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+\r
/**\r
* 24ビットカラーのマーカーを保持するために使うクラスです。 このクラスは、ARToolkitのパターンと、ラスタから取得したパターンを保持します。\r
* 演算順序以外の最適化をしたもの\r
public class NyARColorPatt_O1 implements INyARColorPatt\r
{\r
private static final int AR_PATT_SAMPLE_NUM = 64;\r
- \r
+ private static final int BUFFER_FORMAT=INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32;\r
private int[] _patdata;\r
- private NyARBufferReader _buf_reader;\r
private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;\r
\r
private NyARIntSize _size;\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
return;\r
}\r
{\r
return this._size;\r
}\r
- public final INyARBufferReader getBufferReader()\r
- {\r
- return this._buf_reader;\r
- }\r
public final INyARRgbPixelReader getRgbPixelReader()\r
{\r
return this._pixelreader;\r
}\r
-\r
+ public Object getBuffer()\r
+ {\r
+ return this._patdata;\r
+ }\r
+ public boolean hasBuffer()\r
+ {\r
+ return this._patdata!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ }\r
+ final public int getBufferType()\r
+ {\r
+ return BUFFER_FORMAT;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return BUFFER_FORMAT==i_type_value;\r
+ }\r
private final NyARMat __get_cpara_a = new NyARMat(8, 8);\r
private final NyARMat __get_cpara_b = new NyARMat(8, 1);\r
private final static double[][] __get__cpara_world = {{ 100.0, 100.0 }, { 100.0 + 10.0, 100.0 }, { 100.0 + 10.0, 100.0 + 10.0 },{ 100.0, 100.0 + 10.0 } };\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+\r
/**\r
* 24ビットカラーのマーカーを保持するために使うクラスです。 このクラスは、ARToolkitのパターンと、ラスタから取得したパターンを保持します。\r
* 演算順序を含む最適化をしたもの\r
public class NyARColorPatt_O3 implements INyARColorPatt\r
{\r
private static final int AR_PATT_SAMPLE_NUM = 64;\r
+ private static final int BUFFER_FORMAT=INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32;\r
\r
private int[] _patdata;\r
- private NyARBufferReader _buf_reader;\r
private NyARIntSize _size;\r
private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;\r
\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
}\r
public int getWidth()\r
{\r
return this._size;\r
}\r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._buf_reader;\r
- }\r
public INyARRgbPixelReader getRgbPixelReader()\r
{\r
return this._pixelreader;\r
}\r
+ public Object getBuffer()\r
+ {\r
+ return this._patdata;\r
+ }\r
+ public boolean hasBuffer()\r
+ {\r
+ return this._patdata!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ }\r
+ final public int getBufferType()\r
+ {\r
+ return BUFFER_FORMAT;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return BUFFER_FORMAT==i_type_value;\r
+ }\r
private final NyARMat wk_get_cpara_a = new NyARMat(8, 8);\r
private final NyARMat wk_get_cpara_b = new NyARMat(8, 1);\r
private final NyARMat wk_pickFromRaster_cpara = new NyARMat(8, 1);\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.utils.NyARPerspectiveParamGenerator_O1;\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 static final int LOCAL_LT=1;\r
+ private static final int BUFFER_FORMAT=INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32;\r
\r
private void initializeInstance(int i_width, int i_height,int i_point_per_pix)\r
{\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,INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);\r
return; \r
}\r
{\r
return this._size;\r
}\r
- public final INyARBufferReader getBufferReader()\r
- {\r
- return this._buf_reader;\r
- }\r
public final INyARRgbPixelReader getRgbPixelReader()\r
{\r
return this._pixelreader;\r
}\r
+ public Object getBuffer()\r
+ {\r
+ return this._patdata;\r
+ }\r
+ public boolean hasBuffer()\r
+ {\r
+ return this._patdata!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ }\r
+ final public int getBufferType()\r
+ {\r
+ return BUFFER_FORMAT;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return BUFFER_FORMAT==i_type_value;\r
+ }\r
private final int[] __pickFromRaster_rgb_tmp = new int[3];\r
protected final double[] __pickFromRaster_cpara=new double[8];\r
\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
\r
\r
\r
public class NyARColorPatt_PseudoAffine implements INyARColorPatt\r
{\r
private int[] _patdata;\r
- private NyARBufferReader _buf_reader;\r
private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;\r
private NyARIntSize _size;\r
+ private static final int BUFFER_FORMAT=INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32;\r
\r
public final int getWidth()\r
{\r
{\r
return this._size;\r
}\r
- \r
- public final INyARBufferReader getBufferReader()\r
- {\r
- return this._buf_reader;\r
- }\r
- \r
public final INyARRgbPixelReader getRgbPixelReader()\r
{\r
return this._pixelreader;\r
}\r
+ public Object getBuffer()\r
+ {\r
+ return this._patdata;\r
+ }\r
+ public boolean hasBuffer()\r
+ {\r
+ return this._patdata!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ }\r
+ final public int getBufferType()\r
+ {\r
+ return BUFFER_FORMAT;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return BUFFER_FORMAT==i_type_value;\r
+ } \r
NyARDoubleMatrix44 _invmat=new NyARDoubleMatrix44();\r
/**\r
* @param i_width\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
//疑似アフィン変換のパラメタマトリクスを計算します。\r
//長方形から計算すると、有効要素がm00,m01,m02,m03,m10,m11,m20,m23,m30になります。\r
package jp.nyatla.nyartoolkit.core.raster;\r
\r
\r
+import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+\r
\r
public interface INyARRaster\r
{\r
- public int getWidth();\r
+ public static final int BYTE1D =0x00010000;\r
+ public static final int INT2D =0x00020000;\r
+ public static final int SHORT1D=0x00030000;\r
+ public static final int INT1D =0x00040000;\r
+ public static final int OBJECT =0x00100000;\r
+ public static final int USER =0x00FF0000;\r
+ // 24-31(8)予約\r
+ // 16-27(8)型ID\r
+ // 00:無効/01:byte[]/02:int[][]/03:short[]\r
+ // 08-15(8)ビットフォーマットID\r
+ // 00:24bit/01:32bit/02:16bit\r
+ // 00-07(8)型番号\r
+ //\r
+ /**\r
+ * RGB24フォーマットで、全ての画素が0\r
+ */\r
+ public static final int BUFFERFORMAT_NULL_ALLZERO = 0x00000001;\r
+ /**\r
+ * USER - USER+0xFFFFはユーザー定義型。実験用に。\r
+ */\r
+ public static final int BUFFERFORMAT_USER = USER;\r
\r
- public int getHeight();\r
+ /**\r
+ * byte[]で、R8G8B8の24ビットで画素が格納されている。\r
+ */\r
+ public static final int BUFFERFORMAT_BYTE1D_R8G8B8_24 = BYTE1D|0x0001;\r
+ /**\r
+ * byte[]で、B8G8R8の24ビットで画素が格納されている。\r
+ */\r
+ public static final int BUFFERFORMAT_BYTE1D_B8G8R8_24 = BYTE1D|0x0002;\r
+ /**\r
+ * byte[]で、R8G8B8X8の32ビットで画素が格納されている。\r
+ */\r
+ public static final int BUFFERFORMAT_BYTE1D_B8G8R8X8_32 = BYTE1D|0x0101;\r
+ /**\r
+ * byte[]で、X8R8G8B8の32ビットで画素が格納されている。\r
+ */\r
+ public static final int BUFFERFORMAT_BYTE1D_X8R8G8B8_32 = BYTE1D|0x0102;\r
+\r
+ /**\r
+ * byte[]で、RGB565の16ビット(little/big endian)で画素が格納されている。\r
+ */\r
+ public static final int BUFFERFORMAT_BYTE1D_R5G6B5_16LE = BYTE1D|0x0201;\r
+ public static final int BUFFERFORMAT_BYTE1D_R5G6B5_16BE = BYTE1D|0x0202;\r
+ /**\r
+ * short[]で、RGB565の16ビット(little/big endian)で画素が格納されている。\r
+ */ \r
+ public static final int BUFFERFORMAT_WORD1D_R5G6B5_16LE = SHORT1D|0x0201;\r
+ public static final int BUFFERFORMAT_WORD1D_R5G6B5_16BE = SHORT1D|0x0202;\r
+\r
+ \r
+ /**\r
+ * int[][]で特に値範囲を定めない\r
+ */\r
+ public static final int BUFFERFORMAT_INT2D = INT2D|0x0000;\r
+ /**\r
+ * int[][]で0-255のグレイスケール画像\r
+ */\r
+ public static final int BUFFERFORMAT_INT2D_GRAY_8 = INT2D|0x0001;\r
+ /**\r
+ * int[][]で0/1の2値画像\r
+ * これは、階調値1bitのBUFFERFORMAT_INT2D_GRAY_1と同じです。\r
+ */\r
+ public static final int BUFFERFORMAT_INT2D_BIN_8 = INT2D|0x0002;\r
\r
+ /**\r
+ * int[]で特に値範囲を定めない\r
+ */\r
+ public static final int BUFFERFORMAT_INT1D = INT1D|0x0000;\r
+ /**\r
+ * int[]で0-255のグレイスケール画像\r
+ */\r
+ public static final int BUFFERFORMAT_INT1D_GRAY_8 = INT1D|0x0001;\r
+ /**\r
+ * int[]で0/1の2値画像\r
+ * これは、階調1bitのBUFFERFORMAT_INT1D_GRAY_1と同じです。\r
+ */\r
+ public static final int BUFFERFORMAT_INT1D_BIN_8 = INT1D|0x0002;\r
+ \r
+ \r
+ /**\r
+ * int[]で、XRGB32の32ビットで画素が格納されている。\r
+ */ \r
+ public static final int BUFFERFORMAT_INT1D_X8R8G8B8_32=INT1D|0x0102;\r
+\r
+ /**\r
+ * H:9bit(0-359),S:8bit(0-255),V(0-255)\r
+ */\r
+ public static final int BUFFERFORMAT_INT1D_X7H9S8V8_32=INT1D|0x0103;\r
+ \r
+\r
+ \r
+ /**\r
+ * JavaのBufferedImageを格納するラスタ\r
+ */\r
+ public static final int BUFFERFORMAT_OBJECT_Java= OBJECT|0x0100;\r
+ public static final int BUFFERFORMAT_OBJECT_Java_BufferedImage= BUFFERFORMAT_OBJECT_Java|0x01;\r
+ \r
+ /**\r
+ * C#のBufferedImageを格納するラスタ\r
+ */\r
+ public static final int BUFFERFORMAT_OBJECT_CS= OBJECT|0x0200;\r
+ \r
+ /**\r
+ * ActionScript3のBitmapDataを格納するラスタ\r
+ */\r
+ public static final int BUFFERFORMAT_OBJECT_AS3= OBJECT|0x0300;\r
+ public static final int BUFFERFORMAT_OBJECT_AS3_BitmapData= BUFFERFORMAT_OBJECT_AS3|0x01;\r
+\r
+ \r
+ \r
+ \r
+ \r
+ \r
+ public int getWidth();\r
+ public int getHeight();\r
public NyARIntSize getSize();\r
- public INyARBufferReader getBufferReader();\r
+ /**\r
+ * バッファオブジェクトを返します。\r
+ * @return\r
+ */\r
+ public Object getBuffer();\r
+ /**\r
+ * バッファオブジェクトのタイプを返します。\r
+ * @return\r
+ */\r
+ public int getBufferType();\r
+ /**\r
+ * バッファのタイプがi_type_valueであるか、チェックします。\r
+ * @param i_type_value\r
+ * @return\r
+ */\r
+ public boolean isEqualBufferType(int i_type_value);\r
+ /**\r
+ * getBufferがオブジェクトを返せるかの真偽値です。\r
+ * @return\r
+ */\r
+ public boolean hasBuffer();\r
+ /**\r
+ * i_ref_bufをラップします。できる限り整合性チェックを行います。\r
+ * バッファの再ラッピングが可能な関数のみ、この関数を実装してください。\r
+ * @param i_ref_buf\r
+ */\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException;\r
}
\ No newline at end of file
*/\r
package jp.nyatla.nyartoolkit.core.raster;\r
\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.*;\r
\r
public class NyARBinRaster extends NyARRaster_BasicClass\r
{\r
protected Object _buf;\r
- protected INyARBufferReader _buffer_reader;\r
-\r
- public NyARBinRaster(int i_width, int i_height,int i_raster_type) throws NyARException\r
+ /**\r
+ * バッファオブジェクトがアタッチされていればtrue\r
+ */\r
+ protected boolean _is_attached_buffer;\r
+ public NyARBinRaster(int i_width, int i_height,int i_raster_type,boolean i_is_alloc) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- if(!initInstance(this._size,i_raster_type)){\r
+ super(new NyARIntSize(i_width,i_height),i_raster_type);\r
+ if(!initInstance(this._size,i_raster_type,i_is_alloc)){\r
+ throw new NyARException();\r
+ }\r
+ }\r
+ public NyARBinRaster(int i_width, int i_height,boolean i_is_alloc) throws NyARException\r
+ {\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_INT1D_BIN_8);\r
+ if(!initInstance(this._size,INyARRaster.BUFFERFORMAT_INT1D_BIN_8,i_is_alloc)){\r
throw new NyARException();\r
}\r
}\r
public NyARBinRaster(int i_width, int i_height) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- if(!initInstance(this._size,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8)){\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_INT1D_BIN_8);\r
+ if(!initInstance(this._size,INyARRaster.BUFFERFORMAT_INT1D_BIN_8,true)){\r
throw new NyARException();\r
}\r
} \r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._buffer_reader;\r
- }\r
- protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type,boolean i_is_alloc)\r
{\r
switch(i_buf_type)\r
{\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8:\r
- this._buf = new int[i_size.w*i_size.h];\r
- this._buffer_reader=new NyARBufferReader(this._buf,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ case INyARRaster.BUFFERFORMAT_INT1D_BIN_8:\r
+ this._buf = i_is_alloc?new int[i_size.w*i_size.h]:null;\r
break;\r
default:\r
return false;\r
}\r
- this._buffer_reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ this._is_attached_buffer=i_is_alloc;\r
return true;\r
+ }\r
+ public Object getBuffer()\r
+ {\r
+ return this._buf;\r
+ }\r
+ /**\r
+ * インスタンスがバッファを所有するかを返します。\r
+ * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、\r
+ * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。\r
+ * @return\r
+ */ \r
+ public boolean hasBuffer()\r
+ {\r
+ return this._buf!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf)\r
+ {\r
+ assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。\r
+ this._buf=i_ref_buf;\r
} \r
}\r
package jp.nyatla.nyartoolkit.core.raster;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
public final class NyARGrayscaleRaster extends NyARRaster_BasicClass\r
{\r
\r
protected Object _buf;\r
- protected INyARBufferReader _buffer_reader;\r
+ /**\r
+ * バッファオブジェクトがアタッチされていればtrue\r
+ */\r
+ protected boolean _is_attached_buffer;\r
+\r
public NyARGrayscaleRaster(int i_width, int i_height) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- if(!initInstance(this._size,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8)){\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_INT1D_GRAY_8);\r
+ if(!initInstance(this._size,INyARRaster.BUFFERFORMAT_INT1D_GRAY_8,true)){\r
throw new NyARException();\r
}\r
} \r
- public NyARGrayscaleRaster(int i_width, int i_height,int i_raster_type) throws NyARException\r
+ public NyARGrayscaleRaster(int i_width, int i_height,boolean i_is_alloc) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- if(!initInstance(this._size,i_raster_type)){\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_INT1D_GRAY_8);\r
+ if(!initInstance(this._size,INyARRaster.BUFFERFORMAT_INT1D_GRAY_8,i_is_alloc)){\r
throw new NyARException();\r
}\r
- }\r
- public INyARBufferReader getBufferReader()\r
+ } \r
+ public NyARGrayscaleRaster(int i_width, int i_height,int i_raster_type,boolean i_is_alloc) throws NyARException\r
{\r
- return this._buffer_reader;\r
+ super(new NyARIntSize(i_width,i_height),i_raster_type);\r
+ if(!initInstance(this._size,i_raster_type,i_is_alloc)){\r
+ throw new NyARException();\r
+ }\r
}\r
- protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type,boolean i_is_alloc)\r
{\r
switch(i_buf_type)\r
{\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
- this._buf = new int[i_size.w*i_size.h];\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
+ this._buf =i_is_alloc?new int[i_size.w*i_size.h]:null;\r
break;\r
default:\r
return false;\r
}\r
- this._buffer_reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ this._is_attached_buffer=i_is_alloc;\r
return true;\r
}\r
+ public Object getBuffer()\r
+ {\r
+ return this._buf;\r
+ }\r
+ /**\r
+ * インスタンスがバッファを所有するかを返します。\r
+ * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、\r
+ * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。\r
+ * @return\r
+ */\r
+ public boolean hasBuffer()\r
+ {\r
+ return this._buf!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf)\r
+ {\r
+ assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。\r
+ this._buf=i_ref_buf;\r
+ } \r
}\r
*/\r
package jp.nyatla.nyartoolkit.core.raster;\r
\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
+import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
public final class NyARHsvRaster extends NyARRaster_BasicClass\r
{\r
\r
protected int[] _ref_buf;\r
- private INyARBufferReader _buffer_reader;\r
\r
public NyARHsvRaster(int i_width, int i_height)\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
+ //このクラスは外部参照バッファ/形式多重化が使えない簡易実装です。\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_INT1D_X7H9S8V8_32);\r
this._ref_buf = new int[i_height*i_width];\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_INT1D_X7H9S8V8_32);\r
}\r
- public INyARBufferReader getBufferReader()\r
+ public Object getBuffer()\r
{\r
- return this._buffer_reader;\r
+ return this._ref_buf;\r
}\r
+ public boolean hasBuffer()\r
+ {\r
+ return true;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ NyARException.notImplement();\r
+ } \r
}\r
*/\r
public final class NyARRaster extends NyARRaster_BasicClass\r
{\r
- protected NyARBufferReader _reader;\r
protected Object _buf;\r
- \r
- public NyARRaster(NyARIntSize i_size,int i_buf_type) throws NyARException\r
+ protected int _buf_type;\r
+ /**\r
+ * バッファオブジェクトがアタッチされていればtrue\r
+ */\r
+ protected boolean _is_attached_buffer;\r
+ /**\r
+ * 指定したバッファタイプのラスタを作成します。\r
+ * @param i_width\r
+ * @param i_height\r
+ * @param i_buffer_type\r
+ * @param i_is_alloc\r
+ * @throws NyARException\r
+ */\r
+ public NyARRaster(int i_width, int i_height,int i_buffer_type,boolean i_is_alloc) throws NyARException\r
{\r
- super(i_size);\r
- if(!initInstance(i_size,i_buf_type)){\r
+ super(new NyARIntSize(i_width,i_height),i_buffer_type);\r
+ if(!initInstance(this._size,i_buffer_type,i_is_alloc)){\r
throw new NyARException();\r
}\r
return;\r
- }\r
- protected boolean initInstance(NyARIntSize i_size,int i_buf_type)\r
+ } \r
+\r
+ public NyARRaster(int i_width, int i_height,int i_buffer_type) throws NyARException\r
+ {\r
+ super(new NyARIntSize(i_width,i_height),i_buffer_type);\r
+ if(!initInstance(this._size,i_buffer_type,true)){\r
+ throw new NyARException();\r
+ }\r
+ return;\r
+ } \r
+ protected boolean initInstance(NyARIntSize i_size,int i_buf_type,boolean i_is_alloc)\r
{\r
switch(i_buf_type)\r
{\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
- this._buf=new int[i_size.w*i_size.h];\r
+ case INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ this._buf=i_is_alloc?new int[i_size.w*i_size.h]:null;\r
break;\r
default:\r
return false;\r
}\r
- this._reader=new NyARBufferReader(this._buf,i_buf_type);\r
+ this._is_attached_buffer=i_is_alloc;\r
return true;\r
}\r
- public INyARBufferReader getBufferReader()\r
+ public Object getBuffer()\r
{\r
- return this._reader;\r
- } \r
+ return this._buf;\r
+ }\r
+ /**\r
+ * インスタンスがバッファを所有するかを返します。\r
+ * コンストラクタでi_is_allocをfalseにしてラスタを作成した場合、\r
+ * バッファにアクセスするまえに、バッファの有無をこの関数でチェックしてください。\r
+ * @return\r
+ */ \r
+ public boolean hasBuffer()\r
+ {\r
+ return this._buf!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。\r
+ this._buf=i_ref_buf;\r
+ }\r
}
\ No newline at end of file
\r
public abstract class NyARRaster_BasicClass implements INyARRaster\r
{\r
- final protected NyARIntSize _size;\r
- protected NyARRaster_BasicClass(final NyARIntSize i_size)\r
+ protected NyARIntSize _size;\r
+ private int _buffer_type;\r
+ protected NyARRaster_BasicClass(final NyARIntSize i_size,int i_buffer_type)\r
{\r
this._size= i_size;\r
+ this._buffer_type=i_buffer_type;\r
}\r
\r
final public int getWidth()\r
{\r
return this._size;\r
}\r
+ final public int getBufferType()\r
+ {\r
+ return _buffer_type;\r
+ }\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return this._buffer_type==i_type_value;\r
+ }\r
}\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
\r
public class NyARRgbRaster extends NyARRgbRaster_BasicClass\r
{\r
protected Object _buf;\r
protected INyARRgbPixelReader _reader;\r
- protected INyARBufferReader _buffer_reader;\r
- public NyARRgbRaster(NyARIntSize i_size,int i_raster_type) throws NyARException\r
+ /**\r
+ * バッファオブジェクトがアタッチされていればtrue\r
+ */\r
+ protected boolean _is_attached_buffer;\r
+ public NyARRgbRaster(int i_width, int i_height,int i_raster_type,boolean i_is_alloc) throws NyARException\r
{\r
- super(i_size);\r
- if(!initInstance(i_size,i_raster_type)){\r
+ super(new NyARIntSize(i_width,i_height),i_raster_type);\r
+ if(!initInstance(this._size,i_raster_type,i_is_alloc)){\r
throw new NyARException();\r
}\r
- return;\r
}\r
- public INyARRgbPixelReader getRgbPixelReader()\r
+ public NyARRgbRaster(int i_width, int i_height,int i_raster_type) throws NyARException\r
{\r
- return this._reader;\r
- }\r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._buffer_reader;\r
+ super(new NyARIntSize(i_width,i_height),i_raster_type);\r
+ if(!initInstance(this._size,i_raster_type,true)){\r
+ throw new NyARException();\r
+ }\r
}\r
- protected boolean initInstance(NyARIntSize i_size,int i_raster_type)\r
+ protected boolean initInstance(NyARIntSize i_size,int i_raster_type,boolean i_is_alloc)\r
{\r
switch(i_raster_type)\r
{\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
- this._buf=new int[i_size.w*i_size.h];\r
+ case INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ this._buf=i_is_alloc?new int[i_size.w*i_size.h]:null;\r
this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._buf,i_size);\r
break;\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+ this._buf=i_is_alloc?new byte[i_size.w*i_size.h*4]:null;\r
+ this._reader=new NyARRgbPixelReader_BYTE1D_B8G8R8X8_32((byte[])this._buf,i_size);\r
+ break;\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ this._buf=i_is_alloc?new byte[i_size.w*i_size.h*3]:null;\r
+ this._reader=new NyARRgbPixelReader_BYTE1D_R8G8B8_24((byte[])this._buf,i_size);\r
+ break;\r
default:\r
return false;\r
}\r
- this._buffer_reader=new NyARBufferReader(this._buf,i_raster_type);\r
+ this._is_attached_buffer=i_is_alloc;\r
return true;\r
- } \r
+ }\r
+ public INyARRgbPixelReader getRgbPixelReader() throws NyARException\r
+ {\r
+ return this._reader;\r
+ }\r
+ public Object getBuffer()\r
+ {\r
+ return this._buf;\r
+ }\r
+ public boolean hasBuffer()\r
+ {\r
+ return this._buf!=null;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
+ {\r
+ assert(!this._is_attached_buffer);//バッファがアタッチされていたら機能しない。\r
+ this._buf=i_ref_buf;\r
+ //ピクセルリーダーの参照バッファを切り替える。\r
+ this._reader.switchBuffer(i_ref_buf);\r
+ }\r
}\r
package jp.nyatla.nyartoolkit.core.raster.rgb;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
-import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
\r
-public class NyARRgbRaster_BGRA extends NyARRgbRaster_BasicClass implements INyARRgbRaster\r
+public class NyARRgbRaster_BGRA extends NyARRgbRaster\r
{\r
- private class PixelReader implements INyARRgbPixelReader\r
+ public NyARRgbRaster_BGRA(int i_width, int i_height,Boolean i_is_alloc) throws NyARException\r
{\r
- private NyARRgbRaster_BGRA _parent;\r
-\r
- public PixelReader(NyARRgbRaster_BGRA i_parent)\r
- {\r
- this._parent = i_parent;\r
- }\r
-\r
- public void getPixel(int i_x, int i_y, int[] o_rgb)\r
- {\r
- final byte[] ref_buf = this._parent._ref_buf;\r
- final int bp = (i_x + i_y * this._parent._size.w) * 4;\r
- o_rgb[0] = (ref_buf[bp + 2] & 0xff);// R\r
- o_rgb[1] = (ref_buf[bp + 1] & 0xff);// G\r
- o_rgb[2] = (ref_buf[bp + 0] & 0xff);// B\r
- return;\r
- }\r
-\r
- public void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] o_rgb)\r
- {\r
- int bp;\r
- final int width = _parent._size.w;\r
- final byte[] ref_buf = _parent._ref_buf;\r
- for (int i = i_num - 1; i >= 0; i--) {\r
- bp = (i_x[i] + i_y[i] * width) * 4;\r
- o_rgb[i * 3 + 0] = (ref_buf[bp + 2] & 0xff);// R\r
- o_rgb[i * 3 + 1] = (ref_buf[bp + 1] & 0xff);// G\r
- o_rgb[i * 3 + 2] = (ref_buf[bp + 0] & 0xff);// B\r
- }\r
- return;\r
- }\r
- public void setPixel(int i_x, int i_y, int[] i_rgb) throws NyARException\r
- {\r
- final byte[] ref_buf = this._parent._ref_buf;\r
- final int bp = (i_x + i_y * this._parent._size.w) * 4;\r
- ref_buf[bp+0] = (byte)i_rgb[0];// R\r
- ref_buf[bp+1] = (byte)i_rgb[1];// G\r
- ref_buf[bp+2] = (byte)i_rgb[2];// B \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
- private INyARRgbPixelReader _rgb_reader;\r
- private INyARBufferReader _buffer_reader;\r
- private byte[] _ref_buf;\r
-\r
- public static NyARRgbRaster_BGRA wrap(byte[] i_buffer, int i_width, int i_height)\r
- {\r
- return new NyARRgbRaster_BGRA(i_buffer, i_width, i_height);\r
- }\r
-\r
- private NyARRgbRaster_BGRA(byte[] i_ref_buffer, int i_width, int i_height)\r
- {\r
- super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = i_ref_buffer;\r
- this._rgb_reader = new PixelReader(this);\r
- this._buffer_reader=new NyARBufferReader(i_ref_buffer,INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32);\r
- return;\r
- }\r
- public NyARRgbRaster_BGRA(int i_width, int i_height)\r
+ super(i_width,i_height,INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32,i_is_alloc);\r
+ } \r
+ public NyARRgbRaster_BGRA(int i_width, int i_height) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = new byte[i_width*i_height*4];\r
- this._rgb_reader = new PixelReader(this);\r
- this._buffer_reader=new NyARBufferReader(this._ref_buf,INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32);\r
+ super(i_width,i_height,INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32);\r
return;\r
}\r
- public INyARRgbPixelReader getRgbPixelReader()\r
- {\r
- return this._rgb_reader;\r
- }\r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._buffer_reader;\r
- }\r
}\r
*/\r
package jp.nyatla.nyartoolkit.core.raster.rgb;\r
\r
-import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARRgbPixelReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
public abstract class NyARRgbRaster_BasicClass implements INyARRgbRaster\r
{\r
final protected NyARIntSize _size;\r
+ private int _buffer_type;\r
+ \r
+ protected NyARRgbRaster_BasicClass(final NyARIntSize i_size,int i_buffer_type)\r
+ {\r
+ this._size= i_size;\r
+ this._buffer_type=i_buffer_type;\r
+ }\r
final public int getWidth()\r
{\r
return this._size.w;\r
}\r
-\r
final public int getHeight()\r
{\r
return this._size.h;\r
final public NyARIntSize getSize()\r
{\r
return this._size;\r
- } \r
- protected NyARRgbRaster_BasicClass(final NyARIntSize i_size)\r
- {\r
- this._size= i_size;\r
}\r
- public INyARRgbPixelReader getRgbPixelReader() throws NyARException\r
+ final public int getBufferType()\r
{\r
- NyARException.notImplement();\r
- return null;\r
+ return _buffer_type;\r
}\r
+ final public boolean isEqualBufferType(int i_type_value)\r
+ {\r
+ return this._buffer_type==i_type_value;\r
+ } \r
}\r
package jp.nyatla.nyartoolkit.core.raster.rgb;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.INyARRgbPixelReader;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.NyARBufferReader;\r
-import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
\r
/*\r
* 真っ黒の矩形を定義する。\r
{\r
NyARException.notImplement(); \r
}\r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ NyARException.notImplement(); \r
+ } \r
\r
}\r
\r
private INyARRgbPixelReader _reader;\r
- private INyARBufferReader _buffer_reader;\r
\r
public NyARRgbRaster_Blank(int i_width, int i_height)\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
+ super(new NyARIntSize(i_width,i_height),INyARRaster.BUFFERFORMAT_NULL_ALLZERO);\r
this._reader = new PixelReader();\r
- this._buffer_reader=new NyARBufferReader(null,INyARBufferReader.BUFFERFORMAT_NULL_ALLZERO);\r
return;\r
}\r
- public INyARRgbPixelReader getRgbPixelReader()\r
+ public INyARRgbPixelReader getRgbPixelReader() throws NyARException\r
{\r
return this._reader;\r
}\r
- public INyARBufferReader getBufferReader()\r
+ public Object getBuffer()\r
+ {\r
+ return null;\r
+ }\r
+ public boolean hasBuffer()\r
+ {\r
+ return false;\r
+ }\r
+ public void wrapBuffer(Object i_ref_buf) throws NyARException\r
{\r
- return this._buffer_reader;\r
+ NyARException.notImplement();\r
}\r
}\r
*/\r
package jp.nyatla.nyartoolkit.core.raster.rgb;\r
\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
-import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
\r
-public class NyARRgbRaster_RGB extends NyARRgbRaster_BasicClass\r
+public class NyARRgbRaster_RGB extends NyARRgbRaster\r
{\r
- protected byte[] _ref_buf;\r
-\r
- private NyARRgbPixelReader_RGB24 _reader;\r
- private INyARBufferReader _buffer_reader;\r
- \r
- public static NyARRgbRaster_RGB wrap(byte[] i_buffer, int i_width, int i_height)\r
+ public NyARRgbRaster_RGB(int i_width, int i_height,Boolean i_is_alloc) throws NyARException\r
{\r
- return new NyARRgbRaster_RGB(i_buffer, i_width, i_height);\r
+ super(i_width,i_height,INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24,i_is_alloc);\r
}\r
\r
- private NyARRgbRaster_RGB(byte[] i_ref_buffer, int i_width, int i_height)\r
+ public NyARRgbRaster_RGB(int i_width, int i_height) throws NyARException\r
{\r
- super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = i_ref_buffer;\r
- this._reader = new NyARRgbPixelReader_RGB24(i_ref_buffer, this._size);\r
- this._buffer_reader=new NyARBufferReader(i_ref_buffer,INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24);\r
+ super(i_width,i_height,INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24);\r
return;\r
}\r
- public INyARRgbPixelReader getRgbPixelReader()\r
- {\r
- return this._reader;\r
- }\r
- public INyARBufferReader getBufferReader()\r
- {\r
- return this._buffer_reader;\r
- } \r
}\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
protected NyARRasterFilter_CustomToneTable(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._dofilterimpl=new IdoFilterImpl_INT1D_GRAY_8();\r
break;\r
default:\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._dofilterimpl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
private abstract class IdoFilterImpl\r
{\r
public int[] _table_ref;\r
- public abstract void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public abstract void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
\r
}\r
private class IdoFilterImpl_INT1D_GRAY_8 extends IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert( i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
int[] in_buf = (int[]) i_input.getBuffer();\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
\r
public NyARRasterFilter_GaussianSmooth(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._do_filter_impl=new IdoFilterImpl_GRAY_8();\r
break;\r
default:\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
assert (i_input!=i_output);\r
- this._do_filter_impl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._do_filter_impl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
interface IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
}\r
class IdoFilterImpl_GRAY_8 implements IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert (i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] in_ptr =(int[])i_input.getBuffer();\r
int[] out_ptr=(int[])i_output.getBuffer();\r
int width=i_size.w;\r
public NyARRasterFilter_Reverse(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._do_filter_impl=new IdoFilterImpl_GRAY_8();\r
break;\r
default:\r
}\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
- this._do_filter_impl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._do_filter_impl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
interface IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
}\r
class IdoFilterImpl_GRAY_8 implements IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert (i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] in_ptr =(int[])i_input.getBuffer();\r
int[] out_ptr=(int[])i_output.getBuffer();\r
\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
public NyARRasterFilter_Rgb2Hsv(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
default:\r
throw new NyARException();\r
}\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._dofilterimpl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
abstract class IdoFilterImpl\r
{\r
- public abstract void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public abstract void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
\r
}\r
class IdoFilterImpl_BYTE1D_B8G8R8_24 extends IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_X7H9S8V8_32));\r
+ assert( i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_X7H9S8V8_32));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
public NyARRasterFilter_Roberts(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._do_filter_impl=new IdoFilterImpl_GRAY_8();\r
break;\r
default:\r
}\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
- this._do_filter_impl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._do_filter_impl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
interface IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
}\r
class IdoFilterImpl_GRAY_8 implements IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert (i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] in_ptr =(int[])i_input.getBuffer();\r
int[] out_ptr=(int[])i_output.getBuffer();\r
int width=i_size.w;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.INyARRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
\r
public NyARRasterFilter_SimpleSmooth(int i_raster_type) throws NyARException\r
{\r
switch (i_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
this._do_filter_impl=new IdoFilterImpl_GRAY_8();\r
break;\r
default:\r
public void doFilter(INyARRaster i_input, INyARRaster i_output) throws NyARException\r
{\r
assert (i_input!=i_output);\r
- this._do_filter_impl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._do_filter_impl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
interface IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
}\r
class IdoFilterImpl_GRAY_8 implements IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert (i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] in_ptr =(int[])i_input.getBuffer();\r
int[] out_ptr=(int[])i_output.getBuffer();\r
/* 画像端は捨てる。\r
package jp.nyatla.nyartoolkit.core.rasterfilter.gs2bin;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.NyARGrayscaleRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
-public class NyARRasterFilter_ConstantThrshold implements INyARRasterFilter_Gs2Bin\r
+public class NyARRasterFilter_ConstantThreshold implements INyARRasterFilter_Gs2Bin\r
{\r
public int _threshold;\r
- public NyARRasterFilter_ConstantThrshold(int i_initial_threshold,int i_in_raster_type,int i_out_raster_type) throws NyARException\r
+ public NyARRasterFilter_ConstantThreshold(int i_initial_threshold,int i_in_raster_type,int i_out_raster_type) throws NyARException\r
{\r
- assert(i_in_raster_type==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
- assert(i_out_raster_type==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ assert(i_in_raster_type==INyARRaster.BUFFERFORMAT_INT1D_GRAY_8);\r
+ assert(i_out_raster_type==INyARRaster.BUFFERFORMAT_INT1D_BIN_8);\r
//初期化\r
this._threshold=i_initial_threshold;\r
\r
* 暗点<=th<明点となります。\r
* @throws NyARException\r
*/\r
- public NyARRasterFilter_ConstantThrshold() throws NyARException\r
+ public NyARRasterFilter_ConstantThreshold() throws NyARException\r
{\r
this._threshold=0;\r
}\r
}\r
public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output) throws NyARException\r
{\r
- assert(i_input.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
- assert(i_output.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
- int[] out_buf = (int[]) i_output.getBufferReader().getBuffer();\r
- int[] in_buf = (int[]) i_input.getBufferReader().getBuffer();\r
+ assert(i_input.getBufferType()==INyARRaster.BUFFERFORMAT_INT1D_GRAY_8);\r
+ assert(i_output.getBufferType()==INyARRaster.BUFFERFORMAT_INT1D_BIN_8);\r
+ int[] out_buf = (int[]) i_output.getBuffer();\r
+ int[] in_buf = (int[]) i_input.getBuffer();\r
NyARIntSize s=i_input.getSize();\r
\r
final int th=this._threshold;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
\r
-public interface INyARRasterFilter_RgbToBin\r
+public interface INyARRasterFilter_Rgb2Bin\r
{\r
public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output) throws NyARException;\r
}\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
\r
* 定数閾値による2値化をする。\r
* \r
*/\r
-public class NyARRasterFilter_ARToolkitThreshold implements INyARRasterFilter_RgbToBin\r
+public class NyARRasterFilter_ARToolkitThreshold implements INyARRasterFilter_Rgb2Bin\r
{\r
protected int _threshold;\r
private IdoThFilterImpl _do_threshold_impl;\r
\r
public NyARRasterFilter_ARToolkitThreshold(int i_threshold,int i_in_raster_type) throws NyARException\r
{\r
- if(!initInstance(i_threshold,i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8)){\r
+ if(!initInstance(i_threshold,i_in_raster_type,INyARRaster.BUFFERFORMAT_INT1D_BIN_8)){\r
throw new NyARException();\r
}\r
}\r
protected boolean initInstance(int i_threshold,int i_in_raster_type,int i_out_raster_type)\r
{\r
switch(i_out_raster_type){\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_BIN_8:\r
switch (i_in_raster_type){\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_X8R8G8B8_32:\r
this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
+ case INyARRaster.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE();\r
break;\r
default:\r
\r
public void doFilter(INyARRgbRaster i_input, NyARBinRaster i_output) throws NyARException\r
{\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader();\r
\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._do_threshold_impl.doThFilter(in_buffer_reader,out_buffer_reader,i_output.getSize(), this._threshold);\r
+ this._do_threshold_impl.doThFilter(i_input,i_output,i_output.getSize(), this._threshold);\r
return;\r
}\r
/*\r
*/\r
interface IdoThFilterImpl\r
{\r
- public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold);\r
+ public void doThFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size,int i_threshold);\r
}\r
class doThFilterImpl_BUFFERFORMAT_BYTE1D_RGB_24 implements IdoThFilterImpl\r
{\r
- public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
+ public void doThFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size,int i_threshold)\r
{\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
}\r
class doThFilterImpl_BUFFERFORMAT_BYTE1D_B8G8R8X8_32 implements IdoThFilterImpl\r
{\r
- public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
+ public void doThFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size,int i_threshold)\r
{\r
- assert (i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
class doThFilterImpl_BUFFERFORMAT_BYTE1D_X8R8G8B8_32 implements IdoThFilterImpl\r
{\r
- public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
+ public void doThFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size,int i_threshold)\r
{\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
class doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32 implements IdoThFilterImpl\r
{\r
- public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
+ public void doThFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size,int i_threshold)\r
{\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
int[] in_buf = (int[]) i_input.getBuffer();\r
\r
class doThFilterImpl_BUFFERFORMAT_WORD1D_R5G6B5_16LE implements IdoThFilterImpl\r
{\r
- public void doThFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size,int i_threshold)\r
+ public void doThFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size,int i_threshold)\r
{\r
- assert (i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert (i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
short[] in_buf = (short[]) i_input.getBuffer();\r
* このインタフェイスは、RGBラスタをグレースケールラスタに変換します。\r
*\r
*/\r
-public interface INyARRasterFilter_RgbToGs\r
+public interface INyARRasterFilter_Rgb2Gs\r
{\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException;\r
}\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
* このフィルタは、RGB値の平均値を、(R+G+B)/3で算出します。\r
*\r
*/\r
-public class NyARRasterFilter_Rgb2Gs_AveAdd implements INyARRasterFilter_RgbToGs\r
+public class NyARRasterFilter_Rgb2Gs_AveAdd implements INyARRasterFilter_Rgb2Gs\r
{\r
IdoThFilterImpl _do_filter_impl;\r
public NyARRasterFilter_Rgb2Gs_AveAdd(int i_in_raster_type,int i_out_raster_type) throws NyARException\r
}\r
public NyARRasterFilter_Rgb2Gs_AveAdd(int i_in_raster_type) throws NyARException\r
{\r
- if(!initInstance(i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ if(!initInstance(i_in_raster_type,INyARRaster.BUFFERFORMAT_INT1D_GRAY_8))\r
{\r
throw new NyARException();\r
}\r
protected boolean initInstance(int i_in_raster_type,int i_out_raster_type)\r
{\r
switch(i_out_raster_type){\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
switch (i_in_raster_type){\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
this._do_filter_impl=new doThFilterImpl_BYTE1D_B8G8R8_24();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:\r
this._do_filter_impl=new doThFilterImpl_BYTE1D_B8G8R8X8_32();\r
break;\r
default:\r
\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
- INyARBufferReader in_buffer_reader=i_input.getBufferReader(); \r
- INyARBufferReader out_buffer_reader=i_output.getBufferReader(); \r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._do_filter_impl.doFilter(in_buffer_reader,out_buffer_reader,i_input.getSize());\r
+ this._do_filter_impl.doFilter(i_input,i_output,i_input.getSize());\r
return;\r
}\r
\r
*/\r
interface IdoThFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size);\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size);\r
}\r
class doThFilterImpl_BYTE1D_B8G8R8_24 implements IdoThFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size)\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size)\r
{\r
- assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
}\r
class doThFilterImpl_BYTE1D_B8G8R8X8_32 implements IdoThFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size)\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size)\r
{\r
- assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_Rgb2Gs;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
\r
* この値は、RGB成分の作る立方体の体積を0-255スケールにした値です。\r
*\r
*/\r
-public class NyARRasterFilter_Rgb2Gs_RgbCube implements INyARRasterFilter_RgbToGs\r
+public class NyARRasterFilter_Rgb2Gs_RgbCube implements INyARRasterFilter_Rgb2Gs\r
{\r
private IdoFilterImpl _dofilterimpl;\r
public NyARRasterFilter_Rgb2Gs_RgbCube(int i_in_raster_type) throws NyARException\r
{\r
- if(!initInstance(i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ if(!initInstance(i_in_raster_type,INyARRaster.BUFFERFORMAT_INT1D_GRAY_8))\r
{\r
throw new NyARException();\r
}\r
protected boolean initInstance(int i_in_raster_type,int i_out_raster_type)\r
{\r
switch(i_out_raster_type){\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
switch (i_in_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
break;\r
default:\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._dofilterimpl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
interface IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
}\r
class IdoFilterImpl_BYTE1D_B8G8R8_24 implements IdoFilterImpl\r
{\r
/**\r
* This function is not optimized.\r
*/\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24)\r
- || i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24));\r
- assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert( i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24)\r
+ || i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24));\r
+ assert(i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
package jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
-import jp.nyatla.nyartoolkit.core.raster.NyARGrayscaleRaster;\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_RgbToGs;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2gs.INyARRasterFilter_Rgb2Gs;\r
import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
\r
/**\r
* YCbCr変換して、Y成分のグレースケールの値を計算します。\r
* 変換式は、http://www.tyre.gotdns.org/を参考にしました。\r
*/\r
-public class NyARRasterFilter_Rgb2Gs_YCbCr implements INyARRasterFilter_RgbToGs\r
+public class NyARRasterFilter_Rgb2Gs_YCbCr implements INyARRasterFilter_Rgb2Gs\r
{\r
private IdoFilterImpl _dofilterimpl;\r
public NyARRasterFilter_Rgb2Gs_YCbCr(int i_in_raster_type) throws NyARException\r
{\r
- if(!initInstance(i_in_raster_type,INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ if(!initInstance(i_in_raster_type,INyARRaster.BUFFERFORMAT_INT1D_GRAY_8))\r
{\r
throw new NyARException();\r
}\r
protected boolean initInstance(int i_in_raster_type,int i_out_raster_type)\r
{\r
switch(i_out_raster_type){\r
- case INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8:\r
+ case INyARRaster.BUFFERFORMAT_INT1D_GRAY_8:\r
switch (i_in_raster_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
this._dofilterimpl=new IdoFilterImpl_BYTE1D_B8G8R8_24();\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
default:\r
return false;\r
}\r
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) throws NyARException\r
{\r
assert (i_input.getSize().isEqualSize(i_output.getSize()) == true);\r
- this._dofilterimpl.doFilter(i_input.getBufferReader(),i_output.getBufferReader(),i_input.getSize());\r
+ this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize());\r
}\r
\r
interface IdoFilterImpl\r
{\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException;\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException;\r
}\r
class IdoFilterImpl_BYTE1D_B8G8R8_24 implements IdoFilterImpl\r
{\r
/**\r
* This function is not optimized.\r
*/\r
- public void doFilter(INyARBufferReader i_input, INyARBufferReader i_output,NyARIntSize i_size) throws NyARException\r
+ public void doFilter(INyARRaster i_input, INyARRaster i_output,NyARIntSize i_size) throws NyARException\r
{\r
- assert( i_input.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
- assert(i_output.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert( i_input.isEqualBufferType(INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24));\r
+ assert(i_output.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
\r
int[] out_buf = (int[]) i_output.getBuffer();\r
byte[] in_buf = (byte[]) i_input.getBuffer();\r
+++ /dev/null
-/* \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 edition ARToolKit class library.\r
- * Copyright (C)2008-2009 Ryo Iizuka\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- * \r
- * For further information please contact.\r
- * http://nyatla.jp/nyatoolkit/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- * \r
- */\r
-package jp.nyatla.nyartoolkit.core.rasterreader;\r
-/**\r
- * このインタフェイスは、画素データを格納するバッファオブジェクト\r
- * へのアクセス方法と、その形式を定義します。\r
- *\r
- */\r
-public interface INyARBufferReader\r
-{\r
- public static final int BYTE1D =0x00010000;\r
- public static final int INT2D =0x00020000;\r
- public static final int SHORT1D=0x00030000;\r
- public static final int INT1D =0x00040000;\r
- public static final int OBJECT =0x00100000; // ID規約\r
- // 24-31(8)予約\r
- // 16-27(8)型ID\r
- // 00:無効/01:byte[]/02:int[][]/03:short[]\r
- // 08-15(8)ビットフォーマットID\r
- // 00:24bit/01:32bit/02:16bit\r
- // 00-07(8)型番号\r
- //\r
- /**\r
- * RGB24フォーマットで、全ての画素が0\r
- */\r
- public static final int BUFFERFORMAT_NULL_ALLZERO = 0x00000001;\r
-\r
- /**\r
- * byte[]で、R8G8B8の24ビットで画素が格納されている。\r
- */\r
- public static final int BUFFERFORMAT_BYTE1D_R8G8B8_24 = BYTE1D|0x0001;\r
- /**\r
- * byte[]で、B8G8R8の24ビットで画素が格納されている。\r
- */\r
- public static final int BUFFERFORMAT_BYTE1D_B8G8R8_24 = BYTE1D|0x0002;\r
- /**\r
- * byte[]で、R8G8B8X8の32ビットで画素が格納されている。\r
- */\r
- public static final int BUFFERFORMAT_BYTE1D_B8G8R8X8_32 = BYTE1D|0x0101;\r
- /**\r
- * byte[]で、X8R8G8B8の32ビットで画素が格納されている。\r
- */\r
- public static final int BUFFERFORMAT_BYTE1D_X8R8G8B8_32 = BYTE1D|0x0102;\r
-\r
- /**\r
- * byte[]で、RGB565の16ビット(little/big endian)で画素が格納されている。\r
- */\r
- public static final int BUFFERFORMAT_BYTE1D_R5G6B5_16LE = BYTE1D|0x0201;\r
- public static final int BUFFERFORMAT_BYTE1D_R5G6B5_16BE = BYTE1D|0x0202;\r
- /**\r
- * short[]で、RGB565の16ビット(little/big endian)で画素が格納されている。\r
- */ \r
- public static final int BUFFERFORMAT_WORD1D_R5G6B5_16LE = SHORT1D|0x0201;\r
- public static final int BUFFERFORMAT_WORD1D_R5G6B5_16BE = SHORT1D|0x0202;\r
-\r
- \r
- /**\r
- * int[][]で特に値範囲を定めない\r
- */\r
- public static final int BUFFERFORMAT_INT2D = INT2D|0x0000;\r
- /**\r
- * int[][]で0-255のグレイスケール画像\r
- */\r
- public static final int BUFFERFORMAT_INT2D_GRAY_8 = INT2D|0x0001;\r
- /**\r
- * int[][]で0/1の2値画像\r
- * これは、階調値1bitのBUFFERFORMAT_INT2D_GRAY_1と同じです。\r
- */\r
- public static final int BUFFERFORMAT_INT2D_BIN_8 = INT2D|0x0002;\r
-\r
- /**\r
- * int[]で特に値範囲を定めない\r
- */\r
- public static final int BUFFERFORMAT_INT1D = INT1D|0x0000;\r
- /**\r
- * int[]で0-255のグレイスケール画像\r
- */\r
- public static final int BUFFERFORMAT_INT1D_GRAY_8 = INT1D|0x0001;\r
- /**\r
- * int[]で0/1の2値画像\r
- * これは、階調1bitのBUFFERFORMAT_INT1D_GRAY_1と同じです。\r
- */\r
- public static final int BUFFERFORMAT_INT1D_BIN_8 = INT1D|0x0002;\r
- \r
- \r
- /**\r
- * int[]で、XRGB32の32ビットで画素が格納されている。\r
- */ \r
- public static final int BUFFERFORMAT_INT1D_X8R8G8B8_32=INT1D|0x0102;\r
-\r
- /**\r
- * H:9bit(0-359),S:8bit(0-255),V(0-255)\r
- */\r
- public static final int BUFFERFORMAT_INT1D_X7H9S8V8_32=INT1D|0x0103;\r
- \r
- public static final int BUFFERFORMAT_OBJECT_Java= OBJECT|0x0100;\r
- public static final int BUFFERFORMAT_OBJECT_CS= OBJECT|0x0200;\r
- public static final int BUFFERFORMAT_OBJECT_AS3= OBJECT|0x0300;\r
-\r
- \r
- /**\r
- * JavaのBufferedImageを格納するラスタ\r
- */\r
- public static final int BUFFERFORMAT_OBJECT_Java_BufferedImage= BUFFERFORMAT_OBJECT_Java|0x01;\r
-\r
- /**\r
- * ActionScript3のBitmapDataを格納するラスタ\r
- */\r
-\r
- public static final int BUFFERFORMAT_OBJECT_AS3_BitmapData= BUFFERFORMAT_OBJECT_AS3|0x01;\r
-\r
- \r
- \r
- /**\r
- * バッファオブジェクトを返します。\r
- * @return\r
- */\r
- public Object getBuffer();\r
- /**\r
- * バッファオブジェクトの形式を返します。\r
- * @return\r
- */\r
- public int getBufferType();\r
- /**\r
- * バッファオブジェクトの形式が、i_type_valueにが一致するか返します。\r
- * @param i_type_value\r
- * @return\r
- */\r
- public boolean isEqualBufferType(int i_type_value);\r
-}\r
* @throws NyARException\r
*/\r
public void setPixels(int[] i_x, int[] i_y, int i_num, int[] i_intrgb) throws NyARException;\r
- \r
+ /**\r
+ * 参照しているバッファをi_ref_bufferへ切り替えます。\r
+ * 内部パラメータのチェックは、実装依存です。\r
+ * @param i_ref_buffer\r
+ * @throws NyARException\r
+ */\r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException;\r
}\r
+++ /dev/null
-/* \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 edition ARToolKit class library.\r
- * Copyright (C)2008-2009 Ryo Iizuka\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- * \r
- * For further information please contact.\r
- * http://nyatla.jp/nyatoolkit/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- * \r
- */\r
-package jp.nyatla.nyartoolkit.core.rasterreader;\r
-\r
-public final class NyARBufferReader implements INyARBufferReader\r
-{\r
- private Object _buffer;\r
- private int _buffer_type;\r
- public NyARBufferReader(Object i_buffer,int i_buffer_type)\r
- {\r
- this._buffer=i_buffer;\r
- this._buffer_type=i_buffer_type;\r
- return;\r
- }\r
- public Object getBuffer()\r
- {\r
- return this._buffer;\r
- }\r
- public int getBufferType()\r
- {\r
- return _buffer_type;\r
- }\r
- public boolean isEqualBufferType(int i_type_value)\r
- {\r
- return this._buffer_type==i_type_value;\r
- }\r
-}\r
--- /dev/null
+package jp.nyatla.nyartoolkit.core.rasterreader;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntSize;\r
+\r
+public class NyARRgbPixelReader_BYTE1D_B8G8R8X8_32 implements INyARRgbPixelReader\r
+{\r
+ protected byte[] _ref_buf;\r
+ private NyARIntSize _ref_size;\r
+\r
+ public NyARRgbPixelReader_BYTE1D_B8G8R8X8_32(byte[] i_ref_buf, NyARIntSize i_size)\r
+ {\r
+ this._ref_buf=i_ref_buf;\r
+ this._ref_size = i_size;\r
+ }\r
+\r
+ public void getPixel(int i_x, int i_y, int[] o_rgb)\r
+ {\r
+ final byte[] ref_buf =this._ref_buf;\r
+ final int bp = (i_x + i_y * this._ref_size.w) * 4;\r
+ o_rgb[0] = (ref_buf[bp + 2] & 0xff);// R\r
+ o_rgb[1] = (ref_buf[bp + 1] & 0xff);// G\r
+ o_rgb[2] = (ref_buf[bp + 0] & 0xff);// B\r
+ return;\r
+ }\r
+\r
+ public void getPixelSet(int[] i_x, int[] i_y, int i_num, int[] o_rgb)\r
+ {\r
+ int bp;\r
+ final int width = this._ref_size.w;\r
+ final byte[] ref_buf =this._ref_buf;\r
+ for (int i = i_num - 1; i >= 0; i--) {\r
+ bp = (i_x[i] + i_y[i] * width) * 4;\r
+ o_rgb[i * 3 + 0] = (ref_buf[bp + 2] & 0xff);// R\r
+ o_rgb[i * 3 + 1] = (ref_buf[bp + 1] & 0xff);// G\r
+ o_rgb[i * 3 + 2] = (ref_buf[bp + 0] & 0xff);// B\r
+ }\r
+ return;\r
+ }\r
+ public void setPixel(int i_x, int i_y, int[] i_rgb) throws NyARException\r
+ {\r
+ final byte[] ref_buf =this._ref_buf;\r
+ final int bp = (i_x + i_y * this._ref_size.w) * 4;\r
+ ref_buf[bp+0] = (byte)i_rgb[0];// R\r
+ ref_buf[bp+1] = (byte)i_rgb[1];// G\r
+ ref_buf[bp+2] = (byte)i_rgb[2];// B \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
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ assert(((byte[])i_ref_buffer).length>=this._ref_size.w*this._ref_size.h*4);\r
+ this._ref_buf=(byte[])i_ref_buffer;\r
+ } \r
+}
\ No newline at end of file
* バッファに使用できるピクセルリーダー\r
*\r
*/\r
-public class NyARRgbPixelReader_RGB24 implements INyARRgbPixelReader\r
+public class NyARRgbPixelReader_BYTE1D_R8G8B8_24 implements INyARRgbPixelReader\r
{\r
protected byte[] _ref_buf;\r
\r
private NyARIntSize _size;\r
\r
- public NyARRgbPixelReader_RGB24(byte[] i_buf, NyARIntSize i_size)\r
+ public NyARRgbPixelReader_BYTE1D_R8G8B8_24(byte[] i_buf, NyARIntSize i_size)\r
{\r
this._ref_buf = i_buf;\r
this._size = i_size;\r
{\r
NyARException.notImplement(); \r
}\r
- \r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ assert(((byte[])i_ref_buffer).length>=this._size.w*this._size.h*3);\r
+ this._ref_buf=(byte[])i_ref_buffer;\r
+ } \r
}
\ No newline at end of file
{\r
NyARException.notImplement(); \r
}\r
- \r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ assert(((byte[])i_ref_buffer).length>=this._size.w*this._size.h*4);\r
+ this._ref_buf=(byte[])i_ref_buffer;\r
+ }\r
}
\ No newline at end of file
{\r
NyARException.notImplement(); \r
}\r
- \r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ assert(((int[])i_ref_buffer).length>=this._size.w*this._size.h);\r
+ this._ref_buf=(int[])i_ref_buffer;\r
+ } \r
}\r
{\r
NyARException.notImplement(); \r
}\r
- \r
+ public void switchBuffer(Object i_ref_buffer) throws NyARException\r
+ {\r
+ assert(((int[])i_ref_buffer).length>=this._size.w*this._size.h);\r
+ this._ref_buf=(int[])i_ref_buffer;\r
+ } \r
}\r
private NyARIntSize _ref_size;\r
public NyARVectorReader_INT1D_GRAY_8(INyARRaster i_ref_raster)\r
{\r
- assert(i_ref_raster.getBufferReader().getBufferType()==INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
- this._ref_buf=(int[])(i_ref_raster.getBufferReader().getBuffer());\r
+ assert(i_ref_raster.getBufferType()==INyARRaster.BUFFERFORMAT_INT1D_GRAY_8);\r
+ this._ref_buf=(int[])(i_ref_raster.getBuffer());\r
this._ref_size=i_ref_raster.getSize();\r
}\r
/**\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.INyARBufferReader;\r
import jp.nyatla.nyartoolkit.core.labeling.artoolkit.*;\r
\r
/**\r
protected final static int[] _getContour_ydir = {-1,-1, 0, 1, 1, 1, 0,-1 ,-1,-1, 0, 1, 1, 1, 0};\r
public int getContour(NyARBinRaster i_raster,int i_entry_x,int i_entry_y,int i_array_size,int[] o_coord_x,int[] o_coord_y) throws NyARException\r
{\r
- assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8));\r
+ assert(i_raster.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8));\r
return impl_getContour(i_raster,0,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y);\r
}\r
/**\r
*/\r
public int getContour(NyARGrayscaleRaster i_raster,int i_th,int i_entry_x,int i_entry_y,int i_array_size,int[] o_coord_x,int[] o_coord_y) throws NyARException\r
{\r
- assert(i_raster.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8));\r
+ assert(i_raster.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8));\r
return impl_getContour(i_raster,i_th,i_entry_x,i_entry_y,i_array_size,o_coord_x,o_coord_y);\r
}\r
\r
final int[] xdir = _getContour_xdir;// static int xdir[8] = { 0, 1, 1, 1, 0,-1,-1,-1};\r
final int[] ydir = _getContour_ydir;// static int ydir[8] = {-1,-1, 0, 1, 1, 1, 0,-1};\r
\r
- final int[] i_buf=(int[])i_raster.getBufferReader().getBuffer();\r
+ final int[] i_buf=(int[])i_raster.getBuffer();\r
final int width=i_raster.getWidth();\r
final int height=i_raster.getHeight();\r
//クリップ領域の上端に接しているポイントを得る。\r
final int[] xdir = _getContour_xdir;// static int xdir[8] = { 0, 1, 1, 1, 0,-1,-1,-1};\r
final int[] ydir = _getContour_ydir;// static int ydir[8] = {-1,-1, 0, 1, 1, 1, 0,-1};\r
\r
- final int[] i_buf=(int[])i_raster.getBufferReader().getBuffer();\r
+ final int[] i_buf=(int[])i_raster.getBuffer();\r
final int width=i_raster.getWidth();\r
final int height=i_raster.getHeight();\r
//クリップ領域の上端に接しているポイントを得る。\r
}\r
}\r
/**\r
- * 3乗根を求められないシステムで、3乗根を求めます。\r
- * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html\r
- * @param i_in\r
- * @return\r
- */\r
- private static double cuberoot(double i_in) {\r
- double res = Math.pow(Math.abs(i_in), 1.0 / 3.0);\r
- return (i_in >= 0) ? res : -res;\r
- }\r
- /**\r
* 3次方程式の実根を1個だけ求める。\r
* 4字方程式で使う。\r
* @param i_b\r
return tmp * Math.cos(t / 3) - b;\r
}\r
} \r
-\r
+/*\r
public static void main(String[] args)\r
{\r
NyAREquationSolver n = new NyAREquationSolver();\r
e.printStackTrace();\r
}\r
System.out.println(l);\r
- }\r
+ }*/\r
}\r
z=i_p2.z-i_p1.z;\r
return x*x+y*y+z*z;\r
}\r
-\r
+ /**\r
+ * 3乗根を求められないシステムで、3乗根を求めます。\r
+ * http://aoki2.si.gunma-u.ac.jp/JavaScript/src/3jisiki.html\r
+ * @param i_in\r
+ * @return\r
+ */\r
+ public static double cubeRoot(double i_in)\r
+ {\r
+ double res = Math.pow(Math.abs(i_in), 1.0 / 3.0);\r
+ return (i_in >= 0) ? res : -res;\r
+ }\r
\r
}\r
protected INyARTransMat _transmat;\r
//画処理用\r
private NyARBinRaster _bin_raster;\r
- protected INyARRasterFilter_RgbToBin _tobin_filter;\r
+ protected INyARRasterFilter_Rgb2Bin _tobin_filter;\r
private DetectSquareCB _detect_cb;\r
private NyARRectOffset _offset; \r
\r
INyARColorPatt i_patt_inst,\r
INyARSquareContourDetector i_sqdetect_inst,\r
INyARTransMat i_transmat_inst,\r
- INyARRasterFilter_RgbToBin i_filter,\r
+ INyARRasterFilter_Rgb2Bin i_filter,\r
NyARParam i_ref_param,\r
NyARCode i_ref_code,\r
double i_marker_width) throws NyARException\r
\r
private NyARBinRaster _bin_raster;\r
\r
- private INyARRasterFilter_RgbToBin _tobin_filter;\r
+ private INyARRasterFilter_Rgb2Bin _tobin_filter;\r
\r
/**\r
* i_imageにマーカー検出処理を実行し、結果を記録します。\r
byte[] buf = new byte[(int) f.length()];\r
fs.read(buf); \r
\r
- NyARRgbRaster_RGB ra = NyARRgbRaster_RGB.wrap(buf, 320, 240);\r
+ NyARRgbRaster_RGB ra = new NyARRgbRaster_RGB(320, 240,false);\r
+ ra.wrapBuffer(buf);\r
\r
- MarkerProcessor pr = new MarkerProcessor(ap, ra.getBufferReader().getBufferType());\r
+ MarkerProcessor pr = new MarkerProcessor(ap, ra.getBufferType());\r
pr.detectMarker(ra);\r
return;\r
}\r
FileInputStream fs = new FileInputStream(data_file);\r
byte[] buf = new byte[(int) f.length()];\r
fs.read(buf);\r
- INyARRgbRaster ra = NyARRgbRaster_BGRA.wrap(buf, 320, 240);\r
+ INyARRgbRaster ra = new NyARRgbRaster_BGRA(320, 240,false);\r
+ ra.wrapBuffer(buf);\r
// Blank_Raster ra=new Blank_Raster(320, 240);\r
\r
// 1パターンのみを追跡するクラスを作成\r
NyARSingleDetectMarker ar = new NyARSingleDetectMarker(\r
- ap, code, 80.0,ra.getBufferReader().getBufferType(),NyARSingleDetectMarker.PF_NYARTOOLKIT);\r
+ ap, code, 80.0,ra.getBufferType(),NyARSingleDetectMarker.PF_NYARTOOLKIT);\r
NyARTransMatResult result_mat = new NyARTransMatResult();\r
ar.setContinueMode(false);\r
ar.detectMarkerLite(ra, 100);\r
byte[] buf = new byte[(int) f.length()];\r
fs.read(buf); \r
\r
- NyARRgbRaster_BGRA ra = NyARRgbRaster_BGRA.wrap(buf, 320, 240);\r
+ NyARRgbRaster_BGRA ra = new NyARRgbRaster_BGRA(320, 240,false);\r
+ ra.wrapBuffer(buf);\r
\r
- MarkerProcessor pr = new MarkerProcessor(ap, ra.getBufferReader().getBufferType());\r
+ MarkerProcessor pr = new MarkerProcessor(ap, ra.getBufferType());\r
NyARCode[] codes=new NyARCode[1];\r
codes[0]=new NyARCode(16,16);\r
codes[0].loadARPattFromFile(CARCODE_FILE);\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
import jp.nyatla.nyartoolkit.core.types.stack.*;\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
\r
\r
public void drawImage(NyARGrayscaleRaster i_raster) throws NyARException\r
{\r
- assert (i_raster.getBufferReader().getBufferType() == INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8);\r
+ assert (i_raster.getBufferType() == INyARRaster.BUFFERFORMAT_INT1D_GRAY_8);\r
\r
int w = this.getWidth();\r
int h = this.getHeight();\r
\r
int[] limg;\r
// イメージの描画\r
- limg = (int[]) i_raster.getBufferReader().getBuffer();\r
+ limg = (int[]) i_raster.getBuffer();\r
for (int i = 0; i < h; i++) {\r
for (int i2 = 0; i2 < w; i2++) {\r
this.setRGB(i2, i,limg[i*w+i2]);\r
*/\r
public void drawImage(NyARBinRaster i_raster) throws NyARException\r
{\r
- assert (i_raster.getBufferReader().getBufferType() == INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8);\r
+ assert (i_raster.getBufferType() == INyARRaster.BUFFERFORMAT_INT1D_BIN_8);\r
\r
int w = this.getWidth();\r
int h = this.getHeight();\r
\r
int[] limg;\r
// イメージの描画\r
- limg = (int[]) i_raster.getBufferReader().getBuffer();\r
+ limg = (int[]) i_raster.getBuffer();\r
for (int i = 0; i < h; i++) {\r
for (int i2 = 0; i2 < w; i2++) {\r
this.setRGB(i2, i, limg[i*w+i2] > 0 ? 255 : 0);\r
\r
int[] limg;\r
// イメージの描画\r
- limg = (int[]) i_image.getBufferReader().getBuffer();\r
+ limg = (int[]) i_image.getBuffer();\r
for (int i = 0; i < h; i++) {\r
for (int i2 = 0; i2 < w; i2++) {\r
int t=limg[i*w+i2]-1;\r
public static void copy(NyARGrayscaleRaster i_in,BufferedImage o_out) throws NyARException\r
{\r
assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight());\r
- if(i_in.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GRAY_8))\r
+ if(i_in.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_GRAY_8))\r
{\r
- final int[] buf=(int[])i_in.getBufferReader().getBuffer();\r
+ final int[] buf=(int[])i_in.getBuffer();\r
final int w=o_out.getWidth();\r
final int h=o_out.getHeight();\r
for(int y=h-1;y>=0;y--){\r
public static void copy(INyARRaster i_in,BufferedImage o_out) throws NyARException\r
{\r
assert i_in.getSize().isEqualSize(o_out.getWidth(), o_out.getHeight());\r
- if(i_in.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8))\r
+ if(i_in.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8))\r
{\r
- final int[] buf=(int[])i_in.getBufferReader().getBuffer();\r
+ final int[] buf=(int[])i_in.getBuffer();\r
final int w=o_out.getWidth();\r
final int h=o_out.getHeight();\r
for(int y=h-1;y>=0;y--){\r
public static void copy(BufferedImage i_in,INyARRaster o_out) throws NyARException\r
{\r
assert o_out.getSize().isEqualSize(i_in.getWidth(), i_in.getHeight());\r
- if(o_out.getBufferReader().isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_BIN_8))\r
+ if(o_out.isEqualBufferType(INyARRaster.BUFFERFORMAT_INT1D_BIN_8))\r
{\r
- final int[] buf=(int[])o_out.getBufferReader().getBuffer();\r
+ final int[] buf=(int[])o_out.getBuffer();\r
final int w=i_in.getWidth();\r
final int h=i_in.getHeight();\r
for(int y=h-1;y>=0;y--){\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" path=""/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolKit"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.utils.jmf"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.utils.jogl"/>\r
+ <classpathentry combineaccessrules="false" kind="src" path="/NyARToolkit.sandbox"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/JMF2.1.1e/lib/jmf.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/jre6/lib/ext/gluegen-rt.jar"/>\r
+ <classpathentry kind="lib" path="C:/Program Files (x86)/Java/jre6/lib/ext/jogl.jar"/>\r
+ <classpathentry kind="output" path=""/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>Test</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
NyARRasterFilterBuilder_RgbToBin filter = new NyARRasterFilterBuilder_RgbToBin(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[] t = (int[]) bin.getBuffer();\r
int[] s = {\r
1,1,1,1,1,1,1,1,1,1,\r
\r
{\r
final int width = this._width;\r
final int height = this._height;\r
- int[] in_buf = (int[]) i_bin_raster.getBufferReader().getBuffer();\r
+ int[] in_buf = (int[]) i_bin_raster.getBuffer();\r
\r
short current = 0;\r
short r = -1;\r
Frame frame = new Frame("["+i_pf+"]");\r
\r
// NyARToolkitの準備\r
- this._nya = new NyARSingleDetectMarker(this._ar_param, i_program._ar_code, 80.0,i_program._cap_image.getBufferReader().getBufferType(),i_pf);\r
+ this._nya = new NyARSingleDetectMarker(this._ar_param, i_program._ar_code, 80.0,i_program._cap_image.getBufferType(),i_pf);\r
this._nya.setContinueMode(true);// ここをtrueにすると、transMatContinueモード(History計算)になります。\r
\r
// 3Dを描画するコンポーネント\r
NyARCode code = new NyARCode(16, 16);\r
code.loadARPattFromFile(CARCODE_FILE);\r
this._capraster = new JmfNyARRaster_RGB(W, H, this._capture.getCaptureFormat());\r
- this.detect = new NyARSingleDetectMarker(ar_param, code, 80, this._capraster.getBufferReader().getBufferType());\r
+ this.detect = new NyARSingleDetectMarker(ar_param, code, 80, this._capraster.getBufferType());\r
this._capture.setOnCapture(this);\r
this._bin_raster = new NyARBinRaster(W, H);\r
this._param = ar_param;\r
\r
{// ピックアップ画像の表示\r
// 矩形抽出\r
- INyARRasterFilter_Bin to_binfilter = new NyARRasterFilterBuilder_RgbToBin(110, i_raster.getBufferReader().getBufferType());\r
+ INyARRasterFilter_Bin to_binfilter = new NyARRasterFilterBuilder_RgbToBin(110, i_raster.getBufferType());\r
to_binfilter.doFilter(i_raster, this._bin_raster);\r
if (this.detect.detectMarkerLite(i_raster, 100)) {\r
\r
import jp.nyatla.nyartoolkit.core.pickup.INyARColorPatt;\r
import jp.nyatla.nyartoolkit.core.raster.NyARBinRaster;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
-import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.INyARRasterFilter_RgbToBin;\r
+import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.INyARRasterFilter_Rgb2Bin;\r
\r
\r
\r
protected INyARTransMat _transmat;\r
//画処理用\r
private NyARBinRaster _bin_raster;\r
- protected INyARRasterFilter_RgbToBin _tobin_filter;\r
+ protected INyARRasterFilter_Rgb2Bin _tobin_filter;\r
private DetectSquareCB _detect_cb;\r
\r
public IntRectStack _next_marker;\r
INyARColorPatt i_patt_inst,\r
INyARSquareContourDetector i_sqdetect_inst,\r
INyARTransMat i_transmat_inst,\r
- INyARRasterFilter_RgbToBin i_filter,\r
+ INyARRasterFilter_Rgb2Bin i_filter,\r
NyARParam i_ref_param,\r
NyARCode i_ref_code,\r
double i_marker_width) throws NyARException\r
this._capture.setOnCapture(this);\r
\r
addMouseMotionListener(this);\r
- this._tr=new Tracking(ar_param,code,80,this._capraster.getBufferReader().getBufferType());\r
+ this._tr=new Tracking(ar_param,code,80,this._capraster.getBufferType());\r
this._trm=new TransMat2MarkerRect(ar_param);\r
return;\r
}\r