NyARToolKit has been moved to github.
Bug fix version of NyARToolkit/2.3.0
-NyARIdMarker problem -- NyARToolkit selects a different target marker when a few marker in a captured image.
-"new" keyword in main loop -- "new" keyword in main loop was deleted .
-The remainder of debug code. -- In NyARPickUp_O3, unnecessary debug code was deleted.
-Ticket:#17015,#16937
NyARToolkit/2.3.0のバグフィクス版です。
・NyARIdMarker認識で、複数のマーカ存在時に表示マーカの選択ミスが起こる問題の修正。
・認識ループ内に残っていたnewの削除
・ARマーカ認識のコードにデバック用のコードが混入していた問題への対処
・対象チケット:#17015,#16937
Index: test/jp/nyatla/nyartoolkit/dev/PattPickupTest.java
===================================================================
--- test/jp/nyatla/nyartoolkit/dev/PattPickupTest.java (revision 241)
+++ test/jp/nyatla/nyartoolkit/dev/PattPickupTest.java (revision 248)
@@ -77,7 +77,7 @@
return (int) Math.sqrt((lx1 * lx1) + (ly1 * ly1)) * (int) Math.sqrt(((lx2 * lx2) + (ly2 * ly2)));
}
- private INyARColorPatt _patt1 = new NyARColorPatt_O3(64, 64);
+ private INyARColorPatt _patt1 = new NyARColorPatt_O3(16, 16);
private INyARColorPatt _patt2 = new NyARColorPatt_Perspective(100,100);
@@ -164,9 +164,6 @@
g2.drawRect(this._patt3.vertex_x[i]-1,this._patt3.vertex_y[i]-1, 2, 2);
}
*/ g2.setColor(Color.red);
- for (int i = 0; i <4; i++) {
- g2.drawRect(this._patt3.vertex2_x[i]-1,this._patt3.vertex2_y[i]-1, 2, 2);
- }
}
g.drawImage(sink, ins.left + 320, ins.top, 128, 128, null);
g.drawImage(sink2, ins.left + 320, ins.top + 128, 400, 400, null);
@@ -178,9 +175,7 @@
Image img = b2i.createImage(i_buffer);
g.drawImage(img, ins.left, ins.top, this);
g.setColor(Color.blue);
- for (int i = 0; i < 225*4; i++) {
- g.drawRect(ins.left+this._patt3.vertex_x[i]-1,ins.top+this._patt3.vertex_y[i]-1, 2, 2);
- }
+
}
/*
Index: readme.ja.txt
===================================================================
--- readme.ja.txt (revision 241)
+++ readme.ja.txt (revision 248)
@@ -1,7 +1,7 @@
ARToolKit Java class library NyARToolkit.
Copyright (C)2008 R.Iizuka
-version 2.3.0
+version 2.3.1
http://nyatla.jp/nyartoolkit/
airmail(at)ebony.plala.or.jp
Index: src/jp/nyatla/nyartoolkit/processor/SingleNyIdMarkerProcesser.java
===================================================================
--- src/jp/nyatla/nyartoolkit/processor/SingleNyIdMarkerProcesser.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/processor/SingleNyIdMarkerProcesser.java (revision 248)
@@ -59,7 +59,7 @@
private INyIdMarkerData _data_temp;
private INyIdMarkerData _data_current;
- private int _current_threshold;
+ private int _current_threshold=110;
// [AR]検出結果の保存用
private NyARBinRaster _bin_raster;
@@ -139,11 +139,12 @@
NyIdMarkerParam param=this._marker_param;
NyIdMarkerPattern patt_data =this._marker_data;
int number_of_square = i_stack.getLength();
- int square_index = 0;
+ NyARSquare current_square=null;
INyIdMarkerData marker_id=null;
for (int i = 0; i < number_of_square; i++) {
// 評価基準になるパターンをイメージから切り出す
- if (!this._id_pickup.pickFromRaster(i_raster, (NyARSquare) i_stack.getItem(i), patt_data, param)) {
+ current_square=(NyARSquare) i_stack.getItem(i);
+ if (!this._id_pickup.pickFromRaster(i_raster,current_square, patt_data, param)) {
continue;
}
//エンコード
@@ -157,7 +158,7 @@
}
// 認識状態を更新
- final boolean is_id_found=updateStatus((NyARSquare) this._square_list.getItem(square_index),marker_id, param);
+ final boolean is_id_found=updateStatus(current_square,marker_id, param);
//閾値フィードバック(detectExistMarkerにもあるよ)
if(is_id_found){
@@ -179,11 +180,12 @@
NyIdMarkerParam param=this._marker_param;
NyIdMarkerPattern patt_data =this._marker_data;
int number_of_square = i_stack.getLength();
- int square_index = 0;
+ NyARSquare current_square=null;
INyIdMarkerData marker_id=null;
for (int i = 0; i < number_of_square; i++){
//idマーカを認識
- if (!this._id_pickup.pickFromRaster(i_raster, (NyARSquare) i_stack.getItem(i), patt_data, param)) {
+ current_square=(NyARSquare) i_stack.getItem(i);
+ if (!this._id_pickup.pickFromRaster(i_raster, current_square, patt_data, param)) {
continue;
}
if(!this._encoder.encode(patt_data,this._data_temp)){
@@ -198,7 +200,7 @@
break;
}
// 認識状態を更新
- final boolean is_id_found=updateStatus((NyARSquare) this._square_list.getItem(square_index),marker_id,param);
+ final boolean is_id_found=updateStatus(current_square,marker_id,param);
//閾値フィードバック(detectExistMarkerにもあるよ)
if(is_id_found){
Index: src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPickup.java
===================================================================
--- src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPickup.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPickup.java (revision 248)
@@ -303,7 +303,7 @@
for(int i=0;i<10;i++){
freq_count_table[i]=0;
}
- final int freq_table[]=this._freq_table;
+ final int[] freq_table=this._freq_table;
for(int i=0;i<110;i++){
freq_table[i]=0;
}
@@ -425,8 +425,8 @@
}
class THighAndLow{
- int h;
- int l;
+ public int h;
+ public int l;
}
/**
* ピクセル配列の上位、下位の4ピクセルのピクセル値平均を求めます。
@@ -604,8 +604,8 @@
private int detectDataBitsIndex(PerspectivePixelReader.TThreshold i_th,double[] o_index_row,double[] o_index_col) throws NyARException
{
//周波数を測定
- final int freq_index1[]=this.__detectDataBitsIndex_freq_index1;
- final int freq_index2[]=this.__detectDataBitsIndex_freq_index2;
+ final int[] freq_index1=this.__detectDataBitsIndex_freq_index1;
+ final int[] freq_index2=this.__detectDataBitsIndex_freq_index2;
int frq_t=getRowFrequency(i_th.lt_y,i_th.th_h,i_th.th_l,freq_index1);
@@ -871,7 +871,9 @@
case 4:
case 5:
case 6:
- case 7:
+ case 7:
+ default:
+ break;
}
return -1;
}
@@ -888,7 +890,9 @@
case 4:
case 5:
case 6:
- case 7:
+ case 7:
+ default:
+ break;
}
return -1;
}
Index: src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPattern.java
===================================================================
--- src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPattern.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerPattern.java (revision 248)
@@ -31,6 +31,7 @@
*/
package jp.nyatla.nyartoolkit.nyidmarker;
/**
+ * [[Strage class]]
* IDマーカパターン値を格納するクラスです。
* クラスは、未整形のマーカデータを格納しています。
*
Index: src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerParam.java
===================================================================
--- src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerParam.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/nyidmarker/NyIdMarkerParam.java (revision 248)
@@ -32,6 +32,7 @@
package jp.nyatla.nyartoolkit.nyidmarker;
/**
+ * [[Strage class]]
* マーカを抽出した時のパラメータを格納するクラスです。
*
*/
Index: src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.java
===================================================================
--- src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerDataEncoder_RawBit.java (revision 248)
@@ -37,7 +37,7 @@
public class NyIdMarkerDataEncoder_RawBit implements INyIdMarkerDataEncoder
{
private final static int _DOMAIN_ID=0;
- private final static int _mod_data[]={7,31,127,511,2047,4095};
+ private final static int[] _mod_data={7,31,127,511,2047,4095};
public boolean encode(NyIdMarkerPattern i_data,INyIdMarkerData o_dest)
{
final NyIdMarkerData_RawBit dest=(NyIdMarkerData_RawBit)o_dest;
Index: src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerData_RawBit.java
===================================================================
--- src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerData_RawBit.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/nyidmarker/data/NyIdMarkerData_RawBit.java (revision 248)
@@ -31,6 +31,10 @@
*/
package jp.nyatla.nyartoolkit.nyidmarker.data;
+/**
+ * [[Strage class]]
+ *
+ */
public class NyIdMarkerData_RawBit implements INyIdMarkerData
{
public int[] packet=new int[22];
Index: src/jp/nyatla/nyartoolkit/nyidmarker/data/INyIdMarkerData.java
===================================================================
--- src/jp/nyatla/nyartoolkit/nyidmarker/data/INyIdMarkerData.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/nyidmarker/data/INyIdMarkerData.java (revision 248)
@@ -31,7 +31,11 @@
*/
package jp.nyatla.nyartoolkit.nyidmarker.data;
-
+/**
+ *
+ * [[Strage class]]
+ *
+ */
public interface INyIdMarkerData
{
/**
Index: src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O1.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O1.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O1.java (revision 248)
@@ -88,11 +88,11 @@
private final NyARMat __get_cpara_a = new NyARMat(8, 8);
private final NyARMat __get_cpara_b = new NyARMat(8, 1);
- private final 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 } };
+ 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 } };
final protected boolean get_cpara(final NyARIntPoint2d[] i_vertex, NyARMat o_para)throws NyARException
{
- double[][] world = this.__get__cpara_world;
+ double[][] world = __get__cpara_world;
NyARMat a = __get_cpara_a;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 8 );
double[][] a_array = a.getArray();
NyARMat b = __get_cpara_b;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 1 );
Index: src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O3.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O3.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/pickup/NyARColorPatt_O3.java (revision 248)
@@ -50,7 +50,6 @@
private NyARBufferReader _buf_reader;
private NyARIntSize _size;
private NyARRgbPixelReader_INT1D_X8R8G8B8_32 _pixelreader;
- private double _edge_percent;
public NyARColorPatt_O3(int i_width, int i_height)
{
@@ -58,7 +57,6 @@
this._patdata = new int[i_height*i_width];
this._buf_reader=new NyARBufferReader(this._patdata,NyARBufferReader.BUFFERFORMAT_INT1D_X8R8G8B8_32);
this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);
- this._edge_percent=50.0/100;
}
public int getWidth()
{
@@ -92,7 +90,7 @@
*/
private boolean get_cpara(final NyARIntPoint2d[] i_vertex, NyARMat o_para)throws NyARException
{
- int[][] world = this.wk_pickFromRaster_world;
+ int[][] world = wk_pickFromRaster_world;
NyARMat a = wk_get_cpara_a;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 8 );
double[][] a_array = a.getArray();
NyARMat b = wk_get_cpara_b;// 次処理で値を設定するので、初期化不要// new NyARMat( 8, 1 );
@@ -133,7 +131,7 @@
}
// private final double[] wk_pickFromRaster_para=new double[9];//[3][3];
- private final int[][] wk_pickFromRaster_world = {// double world[4][2];
+ private final static int[][] wk_pickFromRaster_world = {// double world[4][2];
{ 100, 100 }, { 100 + 10, 100 }, { 100 + 10, 100 + 10 }, { 100, 100 + 10 } };
@@ -216,7 +214,9 @@
this.__updateExtpat_rgbset=new int[i_xdiv*i_ydiv*3];
}
return;
- }
+ }
+ private static double LT_POS=102.5;
+ private static double SQ_SIZE=5.0;
//分割数16未満になると少し遅くなるかも。
private void updateExtpat(INyARRgbRaster image, NyARMat i_cpara, int i_xdiv2,int i_ydiv2) throws NyARException
@@ -246,8 +246,8 @@
//ワークバッファの準備
reservWorkBuffers(xdiv,ydiv);
- final double xw[]=this.__updateExtpat_xw;
- final double yw[]=this.__updateExtpat_yw;
+ final double[] xw=this.__updateExtpat_xw;
+ final double[] yw=this.__updateExtpat_yw;
final int[] xc=this.__updateExtpat_xc;
final int[] yc=this.__updateExtpat_yc;
int[] rgb_set = this.__updateExtpat_rgbset;
@@ -258,11 +258,11 @@
//xw,ywマップを作成
reciprocal= 1.0 / i_xdiv2;
for(i=xdiv-1;i>=0;i--){
- xw[i]=100 + 10.0 * (ix*xdiv+i + 0.5) * reciprocal;
+ xw[i]=LT_POS + SQ_SIZE * (ix*xdiv+i + 0.5) * reciprocal;
}
reciprocal= 1.0 / i_ydiv2;
for(i=ydiv-1;i>=0;i--){
- yw[i]=100 + 10.0 * (iy*ydiv+i + 0.5) * reciprocal;
+ yw[i]=LT_POS + SQ_SIZE * (iy*ydiv+i + 0.5) * reciprocal;
}
//1ピクセルを構成するピクセル座標の集合をxc,yc配列に取得
int number_of_pix=0;
Index: src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattDeviationColorData.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattDeviationColorData.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattDeviationColorData.java (revision 248)
@@ -41,7 +41,7 @@
*/
public class NyARMatchPattDeviationColorData
{
- private int _data[];
+ private int[] _data;
private double _pow;
//
private int _number_of_pixels;
Index: src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattResult.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattResult.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/match/NyARMatchPattResult.java (revision 248)
@@ -30,7 +30,10 @@
*
*/
package jp.nyatla.nyartoolkit.core.match;
-
+/**
+ * [[Strage class]]
+ *
+ */
public class NyARMatchPattResult
{
public double confidence;
Index: src/jp/nyatla/nyartoolkit/core/utils/NyARSystemOfLinearEquationsProcessor.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/utils/NyARSystemOfLinearEquationsProcessor.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/utils/NyARSystemOfLinearEquationsProcessor.java (revision 248)
@@ -118,8 +118,8 @@
final double p=i_left[i][i2]*s;
dest_l_n[i2]=dest_l_n[i2]-p;
}
- final double p=i_right[i]*s;
- i_right[solve_row]=i_right[solve_row]-p;
+ final double k=i_right[i]*s;
+ i_right[solve_row]=i_right[solve_row]-k;
}
//消去法の実行(割り算)
Index: src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster_BasicClass.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster_BasicClass.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/raster/rgb/NyARRgbRaster_BasicClass.java (revision 248)
@@ -61,7 +61,7 @@
{
this._size= i_size;
}
- public INyARRgbPixelReader getRgbPixcelReader() throws NyARException
+ public INyARRgbPixelReader getRgbPixelReader() throws NyARException
{
NyARException.notImplement();
return null;
Index: src/jp/nyatla/nyartoolkit/core/types/NyARLinear.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/types/NyARLinear.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/types/NyARLinear.java (revision 248)
@@ -36,6 +36,15 @@
public double rise;//y軸の増加量
public double run;//x軸の増加量
public double intercept;//切片
+ public static NyARLinear[] createArray(int i_number)
+ {
+ NyARLinear[] ret=new NyARLinear[i_number];
+ for(int i=0;i<i_number;i++)
+ {
+ ret[i]=new NyARLinear();
+ }
+ return ret;
+ }
public final void copyFrom(NyARLinear i_source)
{
this.rise=i_source.rise;
Index: src/jp/nyatla/nyartoolkit/core/types/matrix/NyARDoubleMatrix44.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/types/matrix/NyARDoubleMatrix44.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/types/matrix/NyARDoubleMatrix44.java (revision 248)
@@ -1,3 +1,34 @@
+/*
+ * PROJECT: NyARToolkit
+ * --------------------------------------------------------------------------------
+ * This work is based on the original ARToolKit developed by
+ * Hirokazu Kato
+ * Mark Billinghurst
+ * HITLab, University of Washington, Seattle
+ * http://www.hitl.washington.edu/artoolkit/
+ *
+ * The NyARToolkit is Java version ARToolkit class library.
+ * Copyright (C)2008 R.Iizuka
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this framework; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information please contact.
+ * http://nyatla.jp/nyatoolkit/
+ * <airmail(at)ebony.plala.or.jp>
+ *
+ */
package jp.nyatla.nyartoolkit.core.types.matrix;
Index: src/jp/nyatla/nyartoolkit/core/NyARSquare.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core/NyARSquare.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core/NyARSquare.java (revision 248)
@@ -43,16 +43,15 @@
{
public final static int DIRECTION_UNKNOWN=-1;
public int direction;
- public NyARLinear[] line = new NyARLinear[4];
- public NyARDoublePoint2d[] sqvertex = new NyARDoublePoint2d[4];
- public NyARIntPoint2d[] imvertex = new NyARIntPoint2d[4];
- public NyARSquare()
- {
- this.direction=DIRECTION_UNKNOWN;
- for(int i=0;i<4;i++){
- this.sqvertex[i]=new NyARDoublePoint2d();
- this.imvertex[i]=new NyARIntPoint2d();
- this.line[i]=new NyARLinear();
- }
- }
+ public NyARLinear[] line = NyARLinear.createArray(4);
+ public NyARDoublePoint2d[] sqvertex = NyARDoublePoint2d.createArray(4);
+ public NyARIntPoint2d[] imvertex = NyARIntPoint2d.createArray(4);
+ public NyARSquare()
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ this.line[i] = new NyARLinear();
+ }
+ }
+
}
\ No newline at end of file
Index: src/jp/nyatla/nyartoolkit/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java
===================================================================
--- src/jp/nyatla/nyartoolkit/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java (revision 241)
+++ src/jp/nyatla/nyartoolkit/core2/rasteranalyzer/threshold/NyARRasterThresholdAnalyzer_SlidePTile.java (revision 248)
@@ -60,6 +60,8 @@
}
public int createHistgramImpl(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram)
{
+ assert (i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));
+
int sum=0;
final int[] input=(int[]) i_reader.getBuffer();
for (int y = i_size.h-1; y >=0 ; y-=this._v_interval){
@@ -73,6 +75,10 @@
return sum;
}
}
+ /**
+ * RGB24bitのヒストグラム計算クラス
+ *
+ */
final class CreateHistgramImpl_BYTE1D_RGB_24 implements ICreateHistgramImpl
{
private int _v_interval;
@@ -83,6 +89,10 @@
}
public int createHistgramImpl(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram)
{
+ assert (
+ i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24)||
+ i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24));
+
final byte[] input=(byte[]) i_reader.getBuffer();
final int pix_count=i_size.w;
final int pix_mod_part=pix_count-(pix_count%8);
@@ -120,6 +130,61 @@
return sum;
}
}
+ /**
+ * RGBX32bitのヒストグラム計算クラス
+ *
+ */
+ final class CreateHistgramImpl_BYTE1D_B8G8R8X8_32 implements ICreateHistgramImpl
+ {
+ private int _v_interval;
+ public CreateHistgramImpl_BYTE1D_B8G8R8X8_32(int i_v_interval)
+ {
+ this._v_interval = i_v_interval;
+ return;
+ }
+ public int createHistgramImpl(INyARBufferReader i_reader, NyARIntSize i_size, int[] o_histgram)
+ {
+ assert(i_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32));
+ byte[] input = (byte[])i_reader.getBuffer();
+ int pix_count = i_size.w;
+ int pix_mod_part = pix_count - (pix_count % 8);
+ int sum = 0;
+ for (int y = i_size.h - 1; y >= 0; y -= this._v_interval)
+ {
+ sum += i_size.w;
+ int pt = y * i_size.w * 3;
+ int x, v;
+ for (x = pix_count - 1; x >= pix_mod_part; x--)
+ {
+ v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;
+ o_histgram[v]++;
+ pt += 4;
+ }
+ //タイリング
+ for (; x >= 0; x -= 8)
+ {
+ v = ((input[pt + 0] & 0xff) + (input[pt + 1] & 0xff) + (input[pt + 2] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 4] & 0xff) + (input[pt + 5] & 0xff) + (input[pt + 6] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 8] & 0xff) + (input[pt + 9] & 0xff) + (input[pt + 10] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 12] & 0xff) + (input[pt + 13] & 0xff) + (input[pt + 14] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 16] & 0xff) + (input[pt + 17] & 0xff) + (input[pt + 18] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 20] & 0xff) + (input[pt + 21] & 0xff) + (input[pt + 22] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 24] & 0xff) + (input[pt + 25] & 0xff) + (input[pt + 26] & 0xff)) / 3;
+ o_histgram[v]++;
+ v = ((input[pt + 28] & 0xff) + (input[pt + 29] & 0xff) + (input[pt + 30] & 0xff)) / 3;
+ o_histgram[v]++;
+ pt += 4 * 8;
+ }
+ }
+ return sum;
+ }
+ }
private int _persentage;
private int _threshold;
private ICreateHistgramImpl _histgram;
@@ -133,36 +198,41 @@
{
assert (0 <= i_persentage && i_persentage <= 50);
this._persentage = i_persentage;
- switch(i_raster_format){
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
- this._histgram=new CreateHistgramImpl_BYTE1D_RGB_24(i_vertical_interval);
- break;
- case INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8:
- this._histgram=new CreateHistgramImpl_INT1D_GLAY_8(i_vertical_interval);
- break;
- default:
- throw new NyARException();
- }
+ switch (i_raster_format)
+ {
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
+ this._histgram = new CreateHistgramImpl_BYTE1D_RGB_24(i_vertical_interval);
+ break;
+ case INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8:
+ this._histgram = new CreateHistgramImpl_INT1D_GLAY_8(i_vertical_interval);
+ break;
+ case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8X8_32:
+ this._histgram = new CreateHistgramImpl_BYTE1D_B8G8R8X8_32(i_vertical_interval);
+ break;
+ default:
+ throw new NyARException();
+ }
}
public void setVerticalInterval(int i_step)
{
return;//未実装一号
}
-
- private int createHistgram(INyARBufferReader i_reader,NyARIntSize i_size, int[] o_histgram) throws NyARException
+ private int[] _histgram_buf=new int[256];
+ public void analyzeRaster(INyARRaster i_input) throws NyARException
{
+ final int[] histgram = this._histgram_buf;
+ final NyARIntSize size=i_input.getSize();
+
//最大画像サイズの制限
- assert i_size.w*i_size.h<0x40000000;
+ assert size.w*size.h<0x40000000;
- int[] histgram = o_histgram;
-
- //ヒストグラム作成
+ //ヒストグラム初期化
for (int i = 0; i < 256; i++) {
- o_histgram[i] = 0;
+ histgram[i] = 0;
}
- int sum_of_pixel=this._histgram.createHistgramImpl(i_reader, i_size, o_histgram);
+ int sum_of_pixel=this._histgram.createHistgramImpl(i_input.getBufferReader(), size, histgram);
// 閾値ピクセル数確定
final int th_pixcels = sum_of_pixel * this._persentage / 100;
@@ -186,72 +256,9 @@
}
}
// 閾値の保存
- return (th_w + th_b) / 2;
- }
-
- public void analyzeRaster(INyARRaster i_input) throws NyARException
- {
- final INyARBufferReader buffer_reader=i_input.getBufferReader();
- assert (buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));
-
- int[] histgram = new int[256];
- // 閾値の基準値を出す。
- this._threshold = createHistgram(buffer_reader,i_input.getSize(), histgram);
+ this._threshold = (th_w + th_b) / 2;
return;
}
-
- /**
- * ヒストグラムをラスタに書き出す。
- *
- * @param i_output
- */
- public void debugDrawHistgramMap(INyARRaster i_input, INyARRaster i_output) throws NyARException
- {
- INyARBufferReader in_buffer_reader=i_input.getBufferReader();
- INyARBufferReader out_buffer_reader=i_output.getBufferReader();
- assert (in_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));
- assert (out_buffer_reader.isEqualBufferType(INyARBufferReader.BUFFERFORMAT_INT1D_GLAY_8));
-
- NyARIntSize size = i_output.getSize();
-
- int[] out_buf = (int[]) out_buffer_reader.getBuffer();
- // 0で塗りつぶし
- for (int y = 0; y < size.h; y++) {
- for (int x = 0; x < size.w; x++) {
- out_buf[y* size.w+x] = 0;
- }
- }
- // ヒストグラムを計算
- int[] histgram = new int[256];
- int threshold = createHistgram(in_buffer_reader,i_input.getSize(), histgram);
- for (int i = 255; i > 0; i--) {
- histgram[i] = Math.abs(histgram[i]);
- }
-
- // ヒストグラムの最大値を出す
- int max_v = 0;
- for (int i = 0; i < 255; i++) {
- if (max_v < histgram[i]) {
- max_v = histgram[i];
- }
- }
- // 目盛り
- for (int i = 0; i < size.h; i++) {
- out_buf[i* size.w+0] = 128;
- out_buf[i* size.w+128] = 128;
- out_buf[i* size.w+255] = 128;
- }
- // スケーリングしながら描画
- for (int i = 0; i < 255; i++) {
- out_buf[(histgram[i] * (size.h - 1) / max_v)* size.w+i] = 255;
- }
- // 値
- for (int i = 0; i < size.h; i++) {
- out_buf[i* size.w+threshold] = 255;
- }
- return;
- }
-
public int getThreshold()
{
return this._threshold;
Index: Data/NyIdMarker_template.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: Data\NyIdMarker_template.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream