2 * PROJECT: NyARToolkit
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java version ARToolkit class library.
\r
11 * Copyright (C)2008 R.Iizuka
\r
13 * This program is free software; you can redistribute it and/or
\r
14 * modify it under the terms of the GNU General Public License
\r
15 * as published by the Free Software Foundation; either version 2
\r
16 * of the License, or (at your option) any later version.
\r
18 * This program is distributed in the hope that it will be useful,
\r
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
21 * GNU General Public License for more details.
\r
23 * You should have received a copy of the GNU General Public License
\r
24 * along with this framework; if not, write to the Free Software
\r
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
27 * For further information please contact.
\r
28 * http://nyatla.jp/nyatoolkit/
\r
29 * <airmail(at)ebony.plala.or.jp>
\r
32 package jp.nyatla.nyartoolkit.sandbox.x2;
\r
34 import jp.nyatla.nyartoolkit.core.types.*;
\r
35 import jp.nyatla.nyartoolkit.core.param.*;
\r
37 * 歪み成分マップを使用するINyARCameraDistortionFactor
\r
38 * 内部マップをint(1:15:16)フォーマットの固定小数点で保持する。
\r
39 * 固定小数点で値を提供するインタフェイスを持ちます。
\r
41 final public class NyARFixedFloatObserv2IdealMap
\r
43 private double[] _factor=new double[4];
\r
44 private int _stride;
\r
45 private int[] _mapx;
\r
46 private int[] _mapy;
\r
47 public NyARFixedFloatObserv2IdealMap(NyARCameraDistortionFactor i_distfactor,NyARIntSize i_screen_size)
\r
49 NyARDoublePoint2d opoint=new NyARDoublePoint2d();
\r
50 this._mapx=new int[i_screen_size.w*i_screen_size.h];
\r
51 this._mapy=new int[i_screen_size.w*i_screen_size.h];
\r
52 this._stride=i_screen_size.w;
\r
53 int ptr=i_screen_size.h*i_screen_size.w-1;
\r
55 for(int i=i_screen_size.h-1;i>=0;i--)
\r
57 for(int i2=i_screen_size.w-1;i2>=0;i2--)
\r
59 i_distfactor.observ2Ideal(i2,i,opoint);
\r
60 this._mapx[ptr]=(int)(opoint.x*65536);
\r
61 this._mapy[ptr]=(int)(opoint.y*65536);
\r
65 i_distfactor.getValue(this._factor);
\r
69 * 点集合のi_start~i_numまでの間から、最大i_sample_count個の頂点を取得して返します。
\r
70 * i_sample_countは偶数である必要があります。
\r
77 * @param i_sample_count
\r
80 public int observ2IdealSampling(int[] i_x_coord, int[] i_y_coord,int i_start, int i_num, int[] o_x_coord,int[] o_y_coord,int i_sample_count)
\r
82 assert(i_sample_count%2==0);
\r
84 if (i_num < i_sample_count)
\r
86 for (int i = i_num - 1; i >= 0; i--)
\r
88 idx = i_x_coord[i_start + i] + i_y_coord[i_start + i] * this._stride;
\r
89 o_x_coord[i] = this._mapx[idx];
\r
90 o_y_coord[i] = this._mapy[idx];
\r
96 //サンプリング個数分の点を、両端から半分づつ取ってくる。
\r
98 int ed = i_start + i_num - 1;
\r
99 for (int i = i_sample_count - 1; i >= 0; i -= 2)
\r
101 idx = i_x_coord[st] + i_y_coord[st] * this._stride;
\r
102 o_x_coord[i] = this._mapx[idx];
\r
103 o_y_coord[i] = this._mapy[idx];
\r
104 idx = i_x_coord[ed] + i_y_coord[ed] * this._stride;
\r
105 o_x_coord[i - 1] = this._mapx[idx];
\r
106 o_y_coord[i - 1] = this._mapy[idx];
\r
110 return i_sample_count;
\r