public NyARTransMatResult transmat=null;\r
public int current_id=-1;\r
\r
- public MarkerProcessor(NyARParam i_cparam,int i_raster_format) throws NyARException\r
+ public MarkerProcessor(NyARParam i_cparam,int i_width,int i_raster_format) throws NyARException\r
{\r
//アプリケーションフレームワークの初期化\r
super();\r
- initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),i_raster_format);\r
+ initInstance(i_cparam,new NyIdMarkerDataEncoder_RawBit(),100,i_raster_format);\r
return;\r
}\r
/**\r
this._cap_image = new GLNyARRaster_RGB(i_cparam,this._capture.getCaptureFormat()); \r
\r
//プロセッサの準備\r
- this._processor=new MarkerProcessor(i_cparam,this._cap_image.getBufferReader().getBufferType());\r
- this._processor.setMarkerWidth(100);\r
+ this._processor=new MarkerProcessor(i_cparam,100,this._cap_image.getBufferReader().getBufferType());\r
\r
//OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)\r
Frame frame = new Frame("Java simpleLite with NyARToolkit");\r
{\r
int width=o_code.getWidth();\r
int height=o_code.getHeight();\r
- NyARRaster tmp_raster=new NyARRaster(new NyARIntSize(width,height),new int[width*height],INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+ NyARRaster tmp_raster=new NyARRaster(new NyARIntSize(width,height),INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
//4個の要素をラスタにセットする。\r
try {\r
StreamTokenizer st = new StreamTokenizer(new InputStreamReader(i_stream));\r
case INyARBufferReader.BUFFERFORMAT_WORD1D_R5G6B5_16LE:\r
this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_WORD1D_R5G6B5_16LE();\r
break;\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ this._histImpl = new NyARRasterThresholdAnalyzer_Histgram_INT1D_X8R8G8B8_32();\r
+ break;\r
default:\r
throw new NyARException();\r
}\r
return i_size.w*i_size.h;\r
} \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
+ {\r
+ assert (i_reader.isEqualBufferType(INyARBufferReader.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
+ for (int x = i_size.w-1; x >=0; x--) {\r
+ int p=input[pt];\r
+ o_histgram[((p& 0xff)+(p& 0xff)+(p& 0xff))/3]++;\r
+ pt++;\r
+ }\r
+ }\r
+ return i_size.w*i_size.h;\r
+ } \r
+ }\r
\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
this._resolution=i_point_per_pix; \r
this._size=new NyARIntSize(i_width,i_height);\r
this._patdata = new int[i_height*i_width];\r
- this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);\r
+ this._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
* @param i_edge_percentage\r
* エッジ幅の割合(ARToolKit標準と同じなら、25)\r
*/\r
- public NyARColorPatt_Perspective(int i_width, int i_height,int i_resolution,int i_edge_percentage)\r
+ public NyARColorPatt_Perspective(int i_width, int i_height,int i_point_per_pix,int i_edge_percentage)\r
{\r
//入力制限\r
- initializeInstance(i_width,i_height,i_resolution);\r
- setEdgeSizeByPercent(i_edge_percentage,i_edge_percentage,i_resolution);\r
+ initializeInstance(i_width,i_height,i_point_per_pix);\r
+ setEdgeSizeByPercent(i_edge_percentage,i_edge_percentage,i_point_per_pix);\r
return;\r
} \r
/**\r
*/\r
package jp.nyatla.nyartoolkit.core.raster;\r
\r
+import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
public INyARBufferReader getBufferReader()\r
{\r
return this._reader;\r
- }\r
- public NyARRaster(NyARIntSize i_size,Object i_ref_buf,int i_buf_type)\r
+ } \r
+ public NyARRaster(NyARIntSize i_size,int i_buf_type) throws NyARException\r
{\r
super(i_size);\r
- this._reader=new NyARBufferReader(i_ref_buf,i_buf_type);\r
+ init(i_size,i_buf_type);\r
return;\r
}\r
+ private void init(NyARIntSize i_size,int i_buf_type) throws NyARException\r
+ {\r
+ Object buf;\r
+ switch(i_buf_type)\r
+ {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ buf=new int[i_size.w*i_size.h];\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ this._reader=new NyARBufferReader(buf,i_buf_type);\r
+ } \r
}
\ No newline at end of file
--- /dev/null
+package jp.nyatla.nyartoolkit.core.raster.rgb;\r
+\r
+import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
+import jp.nyatla.nyartoolkit.*;\r
+\r
+public class NyARRgbRaster extends NyARRgbRaster_BasicClass\r
+{\r
+ protected Object _ref_buf;\r
+\r
+ private INyARRgbPixelReader _reader;\r
+ private INyARBufferReader _buffer_reader;\r
+ private void init(NyARIntSize i_size,int i_raster_type) throws NyARException\r
+ {\r
+ switch(i_raster_type)\r
+ {\r
+ case INyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32:\r
+ this._ref_buf=new int[i_size.w*i_size.h];\r
+ this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32((int[])this._ref_buf,i_size);\r
+ break;\r
+ default:\r
+ throw new NyARException();\r
+ }\r
+ this._buffer_reader=new NyARBufferReader(this._ref_buf,i_raster_type);\r
+ }\r
+ public NyARRgbRaster(NyARIntSize i_size,int i_raster_type) throws NyARException\r
+ {\r
+ super(i_size);\r
+ init(i_size,i_raster_type);\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
public NyARRgbRaster_BGRA(int i_width, int i_height)\r
{\r
super(new NyARIntSize(i_width,i_height));\r
- this._ref_buf = new byte[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
return;\r
public static final int INT2D =0x00020000;\r
public static final int SHORT1D=0x00030000;\r
public static final int INT1D =0x00040000;\r
- // ID規約\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
*/\r
public static final int BUFFERFORMAT_INT1D_X7H9S8V8_32=INT1D|0x0103;\r
\r
+ public static final int BUFFERFORMAT_OBJECT_Javat= 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
+ * 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
{\r
private Object _buffer;\r
private int _buffer_type;\r
- private NyARBufferReader()\r
- {\r
- return;\r
- }\r
public NyARBufferReader(Object i_buffer,int i_buffer_type)\r
{\r
this._buffer=i_buffer;\r
*/\r
public double dist(NyARDoublePoint3d i_point)\r
{\r
- double x,y;\r
+ double x,y,z;\r
x=this.x-i_point.x;\r
y=this.y-i_point.y;\r
z=this.z-i_point.z;\r
* @param i_in\r
* @return\r
*/\r
- private double cuberoot(double i_in) {\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
public NyARPerspectiveParamGenerator_O1(int i_local_x,int i_local_y,int i_width, int i_height)\r
{\r
super(i_local_x,i_local_y,i_width,i_height);\r
- this._height=i_height;\r
- this._width=i_width;\r
- this._local_x=i_local_x;\r
- this._local_y=i_local_y;\r
return;\r
}\r
final public boolean getParam(final NyARIntPoint2d[] i_vertex,double[] o_param)throws NyARException\r
public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type,int i_profile_id) throws NyARException\r
{\r
super();\r
- initInstance(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);\r
+ initialize(i_param,i_code,i_marker_width,i_input_raster_type,i_profile_id);\r
return;\r
}\r
public NyARSingleDetectMarker(NyARParam i_param, NyARCode i_code, double i_marker_width,int i_input_raster_type) throws NyARException\r
{\r
super();\r
- initInstance(i_param,i_code,i_marker_width,i_input_raster_type,PF_NYARTOOLKIT);\r
+ initialize(i_param,i_code,i_marker_width,i_input_raster_type,PF_NYARTOOLKIT);\r
return;\r
}\r
/**\r
* @param i_profile_id\r
* @throws NyARException\r
*/\r
- protected void initInstance(\r
+ private void initialize(\r
NyARParam i_ref_param,\r
NyARCode i_ref_code,\r
double i_marker_width,\r
* RECT(2):[2]=(9-16),[3]=(17-24)\r
* RECT(3):[4]=(25-32),[5]=(33-40),[6]=(41-48)\r
*/\r
- int[] _bit_table;\r
- int[] _bits=new int[16];\r
- int[] _work=new int[16];\r
- int _model;\r
+ private int[] _bit_table;\r
+ private int[] _bits=new int[16];\r
+ private int[] _work=new int[16];\r
+ private int _model;\r
public void setBitByBitIndex(int i_index_no,int i_value)\r
{\r
assert i_value==0 || i_value==1;\r
return;\r
}\r
private boolean _initialized=false;\r
- protected void initInstance(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_raster_format) throws NyARException\r
+ protected void initInstance(NyARParam i_param,INyIdMarkerDataEncoder i_encoder,int i_marker_width,int i_raster_format) throws NyARException\r
{\r
//初期化済?\r
assert this._initialized==false;\r
this._initialized=true;\r
this._is_active=false;\r
this._offset=new NyARRectOffset();\r
+ this._offset.setSquare(i_marker_width);\r
return;\r
\r
}\r
public MarkerProcessor(NyARParam i_cparam, int i_raster_format) throws Exception\r
{\r
super();//\r
- initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(), i_raster_format);\r
+ initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(),100, i_raster_format);\r
//アプリケーションフレームワークの初期化\r
return;\r
}\r
* @param i_resolution\r
* resolution of reading pixel per point. ---- 取得時の解像度。高解像度のときは1を指定してください。低解像度のときは2以上を指定します。\r
*/\r
- TransformedBitmapPickup(NyARPerspectiveProjectionMatrix i_ref_cparam, int i_width, int i_height, int i_resolution)\r
+ public TransformedBitmapPickup(NyARPerspectiveProjectionMatrix i_ref_cparam, int i_width, int i_height, int i_resolution)\r
{\r
super(i_width, i_height, i_resolution, 0);\r
this._ref_perspective = i_ref_cparam;\r