double confidence = 0;\r
for(int i=0;i<number_of_square;i++){\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster,l_square_list.getItem(i))){\r
+ if (!this._patt.pickFromRaster(i_raster,l_square_list.getItem(i).imvertex)){\r
continue;\r
}\r
//取得パターンをカラー差分データに変換して評価する。\r
double confidence = 0;\r
for(int i=0;i<number_of_square;i++){\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i))){\r
+ if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i).imvertex)){\r
continue;\r
}\r
//取得パターンをカラー差分データに変換して評価する。\r
return false;\r
}\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, i_square)) {\r
+ if (!this._patt.pickFromRaster(i_raster, i_square.imvertex)) {\r
return false;\r
}\r
//評価データを作成して、評価器にセット\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
-import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
\r
public interface INyARColorPatt extends INyARRgbRaster\r
{\r
* ラスタイメージからi_square部分のカラーパターンを抽出して、thisメンバに格納します。\r
* \r
* @param image\r
- * @param i_square\r
- * @return ラスターの取得に成功するとTRUE/失敗するとFALSE\r
+ * Source raster object.\r
+ * ----\r
+ * 抽出元のラスタオブジェクト\r
+ * @param i_vertexs\r
+ * Vertexes of the square. Number of element must be 4.\r
+ * ----\r
+ * 射影変換元の4角形を構成する頂点群頂群。要素数は4であること。\r
+ * @return\r
+ * True if sucessfull; otherwise false.\r
+ * ----\r
+ * ラスターの取得に成功するとTRUE/失敗するとFALSE\r
* @throws NyARException\r
*/\r
- public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square) throws NyARException;\r
+// public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square) throws NyARException;\r
+ public boolean pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertexs) throws NyARException;\r
}
\ No newline at end of file
import jp.nyatla.nyartoolkit.core.NyARMat;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
-import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
/**\r
* 24ビットカラーのマーカーを保持するために使うクラスです。 このクラスは、ARToolkitのパターンと、ラスタから取得したパターンを保持します。\r
private final NyARMat __pickFromRaster_cpara_c = new NyARMat(8, 1);\r
\r
/**\r
- * imageから、i_markerの位置にあるパターンを切り出して、保持します。 Optimize:STEP[769->]\r
- * \r
- * @param image\r
- * @param i_marker\r
- * @return 切り出しに失敗した\r
- * @throws Exception\r
+ * @see INyARColorPatt#pickFromRaster\r
*/\r
- public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square)throws NyARException\r
+ public boolean pickFromRaster(INyARRgbRaster image,NyARIntPoint2d[] i_vertexs)throws NyARException\r
{\r
- final NyARIntPoint2d[] local = i_square.imvertex;\r
-\r
// パターンの切り出しに失敗することもある。\r
NyARMat cpara = this.__pickFromRaster_cpara_c;\r
- if (!get_cpara(i_square.imvertex, cpara)) {\r
+ if (!get_cpara(i_vertexs, cpara)) {\r
return false;\r
}\r
final double[][] para=cpara.getArray();\r
final double para21=para[2*3+1][0];\r
final double para22=1.0;\r
\r
- int lx1 = (int) ((local[0].x - local[1].x) * (local[0].x - local[1].x) + (local[0].y - local[1].y)* (local[0].y - local[1].y));\r
- int lx2 = (int) ((local[2].x - local[3].x) * (local[2].x - local[3].x) + (local[2].y - local[3].y)* (local[2].y - local[3].y));\r
- int ly1 = (int) ((local[1].x - local[2].x) * (local[1].x - local[2].x) + (local[1].y - local[2].y)* (local[1].y - local[2].y));\r
- int ly2 = (int) ((local[3].x - local[0].x) * (local[3].x - local[0].x) + (local[3].y - local[0].y)* (local[3].y - local[0].y));\r
+ int lx1 = (int) ((i_vertexs[0].x - i_vertexs[1].x) * (i_vertexs[0].x - i_vertexs[1].x) + (i_vertexs[0].y - i_vertexs[1].y)* (i_vertexs[0].y - i_vertexs[1].y));\r
+ int lx2 = (int) ((i_vertexs[2].x - i_vertexs[3].x) * (i_vertexs[2].x - i_vertexs[3].x) + (i_vertexs[2].y - i_vertexs[3].y)* (i_vertexs[2].y - i_vertexs[3].y));\r
+ int ly1 = (int) ((i_vertexs[1].x - i_vertexs[2].x) * (i_vertexs[1].x - i_vertexs[2].x) + (i_vertexs[1].y - i_vertexs[2].y)* (i_vertexs[1].y - i_vertexs[2].y));\r
+ int ly2 = (int) ((i_vertexs[3].x - i_vertexs[0].x) * (i_vertexs[3].x - i_vertexs[0].x) + (i_vertexs[3].y - i_vertexs[0].y)* (i_vertexs[3].y - i_vertexs[0].y));\r
if (lx2 > lx1) {\r
lx1 = lx2;\r
}\r
import jp.nyatla.nyartoolkit.core.NyARMat;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
-import jp.nyatla.nyartoolkit.core.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
/**\r
* 24ビットカラーのマーカーを保持するために使うクラスです。 このクラスは、ARToolkitのパターンと、ラスタから取得したパターンを保持します。\r
\r
\r
/**\r
- * imageから、i_markerの位置にあるパターンを切り出して、保持します。 Optimize:STEP[769->750]\r
- * \r
- * @param image\r
- * @param i_marker\r
- * @throws Exception\r
+ * @see INyARColorPatt#pickFromRaster\r
*/\r
- public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square)throws NyARException\r
+ public boolean pickFromRaster(INyARRgbRaster image,NyARIntPoint2d[] i_vertexs)throws NyARException\r
{\r
NyARMat cpara = this.wk_pickFromRaster_cpara;\r
- NyARIntPoint2d[] local = i_square.imvertex;\r
// xdiv2,ydiv2の計算\r
int xdiv2, ydiv2;\r
int l1, l2;\r
int w1, w2;\r
// x計算\r
- w1 = local[0].x - local[1].x;\r
- w2 = local[0].y - local[1].y;\r
+ w1 = i_vertexs[0].x - i_vertexs[1].x;\r
+ w2 = i_vertexs[0].y - i_vertexs[1].y;\r
l1 = (w1 * w1 + w2 * w2);\r
- w1 = local[2].x - local[3].x;\r
- w2 = local[2].y - local[3].y;\r
+ w1 = i_vertexs[2].x - i_vertexs[3].x;\r
+ w2 = i_vertexs[2].y - i_vertexs[3].y;\r
l2 = (w1 * w1 + w2 * w2);\r
if (l2 > l1) {\r
l1 = l2;\r
}\r
\r
// y計算\r
- w1 = local[1].x - local[2].x;\r
- w2 = local[1].y - local[2].y;\r
+ w1 = i_vertexs[1].x - i_vertexs[2].x;\r
+ w2 = i_vertexs[1].y - i_vertexs[2].y;\r
l1 = (w1 * w1 + w2 * w2);\r
- w1 = local[3].x - local[0].x;\r
- w2 = local[3].y - local[0].y;\r
+ w1 = i_vertexs[3].x - i_vertexs[0].x;\r
+ w2 = i_vertexs[3].y - i_vertexs[0].y;\r
l2 = (w1 * w1 + w2 * w2);\r
if (l2 > l1) {\r
l1 = l2;\r
}\r
\r
// cparaの計算\r
- if (!get_cpara(local, cpara)) {\r
+ if (!get_cpara(i_vertexs, cpara)) {\r
return false;\r
}\r
updateExtpat(image, cpara, xdiv2, ydiv2);\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.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.utils.NyARPerspectiveParamGenerator_O1;\r
\r
}\r
private final int[] __pickFromRaster_rgb_tmp = new int[3];\r
protected final double[] __pickFromRaster_cpara=new double[8];\r
+ \r
/**\r
- * \r
- * @param image\r
- * @param i_marker\r
- * @return 切り出しに失敗した\r
- * @throws Exception\r
+ * @see INyARColorPatt#pickFromRaster\r
*/\r
- public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square)throws NyARException\r
+ public boolean pickFromRaster(INyARRgbRaster image,NyARIntPoint2d[] i_vertexs)throws NyARException\r
{\r
//遠近法のパラメータを計算\r
final double[] cpara = this.__pickFromRaster_cpara;\r
- if (!this._perspective_gen.getParam(i_square.imvertex, cpara)) {\r
+ if (!this._perspective_gen.getParam(i_vertexs, cpara)) {\r
return false;\r
}\r
\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.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
\r
\r
} \r
return;\r
}\r
-\r
- public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square)throws NyARException\r
+ /**\r
+ * @see INyARColorPatt#pickFromRaster\r
+ */\r
+ public boolean pickFromRaster(INyARRgbRaster image,NyARIntPoint2d[] i_vertexs)throws NyARException\r
{\r
//遠近法のパラメータを計算\r
final double[] cpara = this.__pickFromRaster_cpara;\r
- if (!this._perspective_gen.getParam(i_square.imvertex, cpara)) {\r
+ if (!this._perspective_gen.getParam(i_vertexs, cpara)) {\r
return false;\r
} \r
this._pickup.pickFromRaster(cpara, image,this._patdata);\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.squaredetect.NyARSquare;\r
import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.types.matrix.*;\r
\r
*/\r
private double[] _convparam=new double[8];\r
\r
- public boolean pickFromRaster(INyARRgbRaster image, NyARSquare i_square)throws NyARException\r
+ /**\r
+ * @see INyARColorPatt#pickFromRaster\r
+ */\r
+ public boolean pickFromRaster(INyARRgbRaster image,NyARIntPoint2d[] i_vertexs)throws NyARException\r
{\r
final double[] conv_param=this._convparam;\r
int rx2,ry2;\r
// 変形先領域の頂点を取得\r
\r
//変換行列から現在の座標系への変換パラメタを作成\r
- calcPara(i_square.imvertex,conv_param);// 変換パラメータを求める\r
+ calcPara(i_vertexs,conv_param);// 変換パラメータを求める\r
for(int y=0;y<ry2;y++){\r
for(int x=0;x<rx2;x++){\r
final int ttx=(int)((conv_param[0]*x*y+conv_param[1]*x+conv_param[2]*y+conv_param[3])+0.5);\r
o_out.z = Math.atan2(-this.m01, this.m11);\r
o_out.y = Math.atan2(-this.m20, this.m22);\r
}\r
- } \r
+ }\r
+ public final void transformVertex(double i_x,double i_y,double i_z,NyARDoublePoint3d o_out)\r
+ {\r
+ o_out.x=this.m00*i_x+this.m01*i_y+this.m02*i_z+this.m03;\r
+ o_out.y=this.m10*i_x+this.m11*i_y+this.m12*i_z+this.m13;\r
+ o_out.z=this.m20*i_x+this.m21*i_y+this.m22*i_z+this.m23;\r
+ return;\r
+ }\r
}\r
{\r
NyARDoublePoint3d[] vertex_3d=this.__transMat_vertex_3d;\r
double err = -1;\r
+ //System.out.println("START");\r
// ループを抜けるタイミングをARToolKitと合わせるために変なことしてます。 \r
for (int i = 0;; i++) {\r
// <arGetTransMat3>\r
i_solver.solveTransportVector(vertex_3d, io_transvec);\r
\r
err = this._mat_optimize.modifyMatrix(io_rotmat, io_transvec, i_offset_3d, i_2d_vertex);\r
+ //System.out.println("E:"+err*4);\r
// //</arGetTransMat3>\r
if (err < AR_GET_TRANS_MAT_MAX_FIT_ERROR || i == AR_GET_TRANS_MAT_MAX_LOOP_COUNT - 1) {\r
break;\r
io_rotmat.getPoint3dBatch(i_offset_3d,vertex_3d,4);\r
i_solver.solveTransportVector(vertex_3d, io_transvec);\r
}\r
+ //System.out.println("END");\r
return err;\r
} \r
/**\r
double confidence = 0;\r
for(int i=0;i<number_of_square;i++){\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i))){\r
+ if (!this._patt.pickFromRaster(i_raster, l_square_list.getItem(i).imvertex)){\r
continue;\r
}\r
//取得パターンをカラー差分データに変換して評価する。\r
NyARSquare square = (l_square_list.getItem(i));\r
\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, square)) {\r
+ if (!this._patt.pickFromRaster(i_raster, square.imvertex)) {\r
// イメージの切り出しは失敗することもある。\r
continue;\r
}\r
return false;\r
}\r
// 評価基準になるパターンをイメージから切り出す\r
- if (!this._patt.pickFromRaster(i_raster, i_square)) {\r
+ if (!this._patt.pickFromRaster(i_raster, i_square.imvertex)) {\r
return false;\r
}\r
//評価データを作成して、評価器にセット\r
--- /dev/null
+package jp.nyatla.nyartoolkit.utils;\r
+\r
+import jp.nyatla.nyartoolkit.NyARException;\r
+import jp.nyatla.nyartoolkit.core.param.NyARPerspectiveProjectionMatrix;\r
+import jp.nyatla.nyartoolkit.core.pickup.NyARColorPatt_Perspective_O2;\r
+import jp.nyatla.nyartoolkit.core.raster.rgb.INyARRgbRaster;\r
+import jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult;\r
+import jp.nyatla.nyartoolkit.core.types.NyARIntPoint2d;\r
+\r
+/**\r
+ * マーカの周辺領域からビットマップを取得する方法を提供します。\r
+ * 比較的負荷が大きいので、連続してパターンを取得し続ける用途には向いていません。\r
+ *\r
+ */\r
+class TransformedBitmapPickup extends NyARColorPatt_Perspective_O2\r
+{\r
+ private NyARIntPoint2d[] _work_points = NyARIntPoint2d.createArray(4);\r
+\r
+ private NyARPerspectiveProjectionMatrix _ref_perspective;\r
+\r
+ /**\r
+ * \r
+ * @param i_width\r
+ * 取得するビットマップの幅\r
+ * @param i_height\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
+ {\r
+ super(i_width, i_height, i_resolution, 0);\r
+ this._ref_perspective = i_ref_cparam;\r
+ }\r
+\r
+ /**\r
+ * This function retrieves bitmap from the area defined by RECT(i_l,i_t,i_r,i_b) above transform matrix i_base_mat. \r
+ * ----\r
+ * この関数は、basementで示される平面のAで定義される領域から、ビットマップを読み出します。\r
+ * 例えば、8cmマーカでRECT(i_l,i_t,i_r,i_b)に-40,0,0,-40.0を指定すると、マーカの左下部分の画像を抽出します。\r
+ * \r
+ * マーカから離れた場所になるほど、また、マーカの鉛直方向から外れるほど誤差が大きくなります。\r
+ * @param i_src_imege\r
+ * 詠み出し元の画像を指定します。\r
+ * @param i_l\r
+ * 基準点からの左上の相対座標(x)を指定します。\r
+ * @param i_t\r
+ * 基準点からの左上の相対座標(y)を指定します。\r
+ * @param i_r\r
+ * 基準点からの右下の相対座標(x)を指定します。\r
+ * @param i_b\r
+ * 基準点からの右下の相対座標(y)を指定します。\r
+ * @param i_base_mat\r
+ * @return 画像の取得の成否を返す。\r
+ */\r
+ boolean pickupImage2d(INyARRgbRaster i_src_imege, double i_l, double i_t, double i_r, double i_b, NyARTransMatResult i_base_mat) throws NyARException\r
+ {\r
+ double cp00, cp01, cp02, cp11, cp12;\r
+ cp00 = this._ref_perspective.m00;\r
+ cp01 = this._ref_perspective.m01;\r
+ cp02 = this._ref_perspective.m02;\r
+ cp11 = this._ref_perspective.m11;\r
+ cp12 = this._ref_perspective.m12;\r
+ //マーカと同一平面上にある矩形の4個の頂点を座標変換して、射影変換して画面上の\r
+ //頂点を計算する。\r
+ //[hX,hY,h]=[P][RT][x,y,z]\r
+\r
+ //出力先\r
+ NyARIntPoint2d[] poinsts = this._work_points; \r
+ \r
+ double yt0,yt1,yt2;\r
+ double x3, y3, z3;\r
+ \r
+ double m00=i_base_mat.m00;\r
+ double m10=i_base_mat.m10;\r
+ double m20=i_base_mat.m20;\r
+ \r
+ //yとtの要素を先に計算\r
+ yt0=i_base_mat.m01 * i_t+i_base_mat.m03;\r
+ yt1=i_base_mat.m11 * i_t+i_base_mat.m13;\r
+ yt2=i_base_mat.m21 * i_t+i_base_mat.m23;\r
+ // l,t\r
+ x3 = m00 * i_l + yt0;\r
+ y3 = m10 * i_l + yt1;\r
+ z3 = m20 * i_l + yt2;\r
+ poinsts[0].x = (int) ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3);\r
+ poinsts[0].y = (int) ((y3 * cp11 + z3 * cp12) / z3);\r
+ // r,t\r
+ x3 = m00 * i_r + yt0;\r
+ y3 = m10 * i_r + yt1;\r
+ z3 = m20 * i_r + yt2;\r
+ poinsts[1].x = (int) ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3);\r
+ poinsts[1].y = (int) ((y3 * cp11 + z3 * cp12) / z3);\r
+\r
+ //yとtの要素を先に計算\r
+ yt0=i_base_mat.m01 * i_b+i_base_mat.m03;\r
+ yt1=i_base_mat.m11 * i_b+i_base_mat.m13;\r
+ yt2=i_base_mat.m21 * i_b+i_base_mat.m23;\r
+\r
+ // r,b\r
+ x3 = m00 * i_r + yt0;\r
+ y3 = m10 * i_r + yt1;\r
+ z3 = m20 * i_r + yt2;\r
+ poinsts[2].x = (int) ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3);\r
+ poinsts[2].y = (int) ((y3 * cp11 + z3 * cp12) / z3);\r
+ // l,b\r
+ x3 = m00 * i_l + yt0;\r
+ y3 = m10 * i_l + yt1;\r
+ z3 = m20 * i_l + yt2;\r
+ poinsts[3].x = (int) ((x3 * cp00 + y3 * cp01 + z3 * cp02) / z3);\r
+ poinsts[3].y = (int) ((y3 * cp11 + z3 * cp12) / z3);\r
+ return this.pickFromRaster(i_src_imege, poinsts);\r
+ }\r
+}
\ No newline at end of file
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.jmf.utils.*;\r
+import jp.nyatla.nyartoolkit.detector.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.NyIdMarkerPickup;\r
+import jp.nyatla.nyartoolkit.core.transmat.*;\r
import jp.nyatla.nyartoolkit.core.*;\r
import jp.nyatla.nyartoolkit.core.param.*;\r
import jp.nyatla.nyartoolkit.core.pickup.*;\r
import jp.nyatla.nyartoolkit.core.raster.*;\r
+import jp.nyatla.nyartoolkit.core.types.*;\r
import jp.nyatla.nyartoolkit.core.raster.rgb.*;\r
import jp.nyatla.nyartoolkit.core.rasterfilter.rgb2bin.*;\r
import jp.nyatla.utils.j2se.*;\r
import jp.nyatla.nyartoolkit.nyidmarker.*;\r
import jp.nyatla.nyartoolkit.core.squaredetect.*;\r
\r
+\r
+\r
public class PattPickupTest extends Frame implements JmfCaptureListener\r
{\r
private final String PARAM_FILE = "../Data/camera_para.dat";\r
\r
+ private final static String CARCODE_FILE = "../Data/patt.hiro";\r
+\r
private static final long serialVersionUID = -2110888320986446576L;\r
\r
private JmfCaptureDevice _capture;\r
\r
private JmfNyARRaster_RGB _capraster;\r
- private int W=320;\r
- private int H=240;\r
\r
+ private int W = 320;\r
\r
+ private int H = 240;\r
+\r
+ private NyARParam _param;\r
\r
private NyARBinRaster _bin_raster;\r
\r
private NyARSquareStack _stack = new NyARSquareStack(100);\r
- private NyARSquareDetector_Rle detect;\r
+\r
+ private NyARSingleDetectMarker detect;\r
+\r
public PattPickupTest() throws NyARException\r
{\r
setTitle("JmfCaptureTest");\r
NyARParam ar_param = new NyARParam();\r
ar_param.loadARParamFromFile(PARAM_FILE);\r
ar_param.changeScreenSize(W, H);\r
- this.detect=new NyARSquareDetector_Rle(ar_param.getDistortionFactor(),ar_param.getScreenSize());\r
+\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._capture.setOnCapture(this);\r
this._bin_raster = new NyARBinRaster(W, H);\r
+ this._param = ar_param;\r
return;\r
}\r
\r
\r
private INyARColorPatt _patt1 = new NyARColorPatt_O3(16, 16);\r
\r
- private INyARColorPatt _patt2 = new NyARColorPatt_Perspective_O2(16,16,4,25);\r
-\r
- private INyARColorPatt _patt3 = new NyARColorPatt_Perspective(16,16,4,25);\r
-\r
public void draw(INyARRgbRaster i_raster)\r
{\r
try {\r
\r
{// ピックアップ画像の表示\r
// 矩形抽出\r
- INyARRasterFilter_RgbToBin to_binfilter= new NyARRasterFilter_ARToolkitThreshold(110,i_raster.getBufferReader().getBufferType()); \r
+ INyARRasterFilter_RgbToBin to_binfilter = new NyARRasterFilter_ARToolkitThreshold(110, i_raster.getBufferReader().getBufferType());\r
to_binfilter.doFilter(i_raster, this._bin_raster);\r
- this.detect.detectMarker(this._bin_raster, this._stack);\r
-\r
- int max_point = 0;\r
- NyARSquare t = null;\r
- // ど れ に し よ う か なー\r
- for (int i = this._stack.getLength() - 1; i >= 0; i--) {\r
- NyARSquare sq = this._stack.getItem(i);\r
- int wp = getSQPoint(sq);\r
- if (wp < max_point) {\r
- continue;\r
- }\r
- t = sq;\r
- }\r
-// NyARSquare t=new NyARSquare();\r
- if (t != null) {\r
- BufferedImage sink=new BufferedImage(this._patt1.getWidth(),this._patt1.getHeight(),ColorSpace.TYPE_RGB);\r
- BufferedImage sink2=new BufferedImage(this._patt2.getWidth(),this._patt2.getHeight(),ColorSpace.TYPE_RGB);\r
-/* t.imvertex[0].x=(int)483.0639377595418;\r
- t.imvertex[0].y=(int)303.17616747966747;\r
-\r
- t.imvertex[1].x=(int)506.1019505415998;\r
- t.imvertex[1].y=(int)310.5313224526344;\r
-\r
- t.imvertex[2].x=(int)589.3605435960492;\r
- t.imvertex[2].y=(int)258.46261716798523;\r
-\r
- t.imvertex[3].x=(int)518.1385869954609;\r
- t.imvertex[3].y=(int)325.1434618295405;\r
-*/ \r
- Graphics g1,g2,g3;\r
- {// ARToolkit\r
- // 一番それっぽいパターンを取得\r
- this._patt1.pickFromRaster(i_raster, t);\r
- Date d2 = new Date();\r
- for (int i = 0; i < 10000; i++) {\r
- this._patt1.pickFromRaster(i_raster, t);\r
- }\r
- Date d = new Date();\r
- System.out.println(d.getTime() - d2.getTime()); \r
-\r
- \r
- // パターンを書く\r
- NyARRasterImageIO.copy(this._patt1,sink);\r
- g1=sink.getGraphics();\r
- g1.setColor(Color.red);\r
- }\r
- {// 疑似アフィン変換\r
- // 一番それっぽいパターンを取得\r
- for(int i2=0;i2<5;i2++){\r
- Date d2 = new Date();\r
- for (int i = 0; i < 10000; i++) {\r
- this._patt2.pickFromRaster(i_raster, t);\r
- }\r
- Date d = new Date();\r
- System.out.println(d.getTime() - d2.getTime()); \r
- // パターンを書く\r
- }\r
- NyARRasterImageIO.copy(this._patt2,sink2); \r
- g2=sink2.getGraphics();\r
- g2.setColor(Color.red);\r
- this._patt3.pickFromRaster(i_raster, t);\r
- {//比較\r
- int[] p2=(int[])this._patt2.getBufferReader().getBuffer();\r
- int[] p3=(int[])this._patt3.getBufferReader().getBuffer();\r
- for(int i=0;i<this._patt2.getHeight()*this._patt2.getWidth();i++){\r
- if(p2[i]!=p3[i]){\r
- System.out.print(i+",");\r
- }\r
+ if (this.detect.detectMarkerLite(i_raster, 100)) {\r
+\r
+ NyARTransMatResult res = new NyARTransMatResult();\r
+ this.detect.getTransmationMatrix(res);\r
+ int max_point = 0;\r
+\r
+ // NyARSquare t=new NyARSquare();\r
+\r
+ TransformedBitmapPickup patt2 = new TransformedBitmapPickup(this._param.getPerspectiveProjectionMatrix(), 100, 100, 1);\r
+\r
+ BufferedImage sink = new BufferedImage(this._patt1.getWidth(), this._patt1.getHeight(), ColorSpace.TYPE_RGB);\r
+ BufferedImage sink2 = new BufferedImage(patt2.getWidth(), patt2.getHeight(), ColorSpace.TYPE_RGB);\r
+ patt2.pickupImage2d(i_raster,-20,-40,20,-80,res);\r
+ /*\r
+ * t.imvertex[0].x=(int)483.0639377595418; t.imvertex[0].y=(int)303.17616747966747;\r
+ * \r
+ * t.imvertex[1].x=(int)506.1019505415998; t.imvertex[1].y=(int)310.5313224526344;\r
+ * \r
+ * t.imvertex[2].x=(int)589.3605435960492; t.imvertex[2].y=(int)258.46261716798523;\r
+ * \r
+ * t.imvertex[3].x=(int)518.1385869954609; t.imvertex[3].y=(int)325.1434618295405;\r
+ */\r
+ Graphics g1, g2, g3;\r
+ /* {// ARToolkit\r
+ // 一番それっぽいパターンを取得\r
+ this._patt1.pickFromRaster(i_raster, t.imvertex);\r
+ Date d2 = new Date();\r
+ for (int i = 0; i < 10000; i++) {\r
+ this._patt1.pickFromRaster(i_raster, t.imvertex);\r
}\r
- }\r
+ Date d = new Date();\r
+ System.out.println(d.getTime() - d2.getTime());\r
+\r
+ // パターンを書く\r
+ NyARRasterImageIO.copy(this._patt1, sink);\r
+ g1 = sink.getGraphics();\r
+ g1.setColor(Color.red);\r
+ }*/\r
+ {// 疑似アフィン変換\r
+ NyARRasterImageIO.copy(patt2, sink2);\r
+ g2 = sink2.getGraphics();\r
+ g2.setColor(Color.red);\r
\r
- }\r
- g.drawImage(sink, ins.left + 320, ins.top, 128, 128, null);\r
- g.drawImage(sink2, ins.left + 320, ins.top + 128, 128, 128, null);\r
-// g.drawImage(sink3, ins.left + 100, ins.top + 240, this._patt3.getWidth() * 10, this._patt3.getHeight() * 10, null);\r
+ }\r
+ g.drawImage(sink, ins.left + 320, ins.top, 128, 128, null);\r
+ g.drawImage(sink2, ins.left + 320, ins.top + 128, 128, 128, null);\r
+ // g.drawImage(sink3, ins.left + 100, ins.top + 240, this._patt3.getWidth() * 10, this._patt3.getHeight() * 10, null);\r
+ \r
}\r
-\r
{// 撮影画像\r
- BufferedImage sink=new BufferedImage(i_raster.getWidth(),i_raster.getHeight(),ColorSpace.TYPE_RGB);\r
+ BufferedImage sink = new BufferedImage(i_raster.getWidth(), i_raster.getHeight(), ColorSpace.TYPE_RGB);\r
NyARRasterImageIO.copy(i_raster, sink);\r
- g.drawImage(sink, ins.left, ins.top, this); \r
+ g.drawImage(sink, ins.left, ins.top, this);\r
}\r
\r
{// 信号取得テスト\r
e.printStackTrace();\r
}\r
}\r
+\r
public void onUpdateBuffer(Buffer i_buffer)\r
{\r
try {\r
e.printStackTrace();\r
}\r
}\r
+\r
public void startImage()\r
{\r
try {\r
// 試験イメージの読み出し(320x240 BGRAのRAWデータ)\r
File f = new File(data_file);\r
FileInputStream fs = new FileInputStream(data_file);\r
- byte[] buf = new byte[(int) f.length()*4];\r
+ byte[] buf = new byte[(int) f.length() * 4];\r
fs.read(buf);\r
INyARRgbRaster ra = NyARRgbRaster_BGRA.wrap(buf, W, H);\r
draw(ra);\r
} catch (Exception e) {\r
e.printStackTrace();\r
}\r
- \r
+\r
}\r
\r
public static void main(String[] args)\r
try {\r
PattPickupTest mainwin = new PattPickupTest();\r
mainwin.setVisible(true);\r
- //mainwin.startCapture();\r
- mainwin.startImage();\r
+ mainwin.startCapture();\r
+ // mainwin.startImage();\r
} catch (Exception e) {\r
e.printStackTrace();\r
}\r