/** * * @param i_ref_raster * 基本画像 * @param i_ref_raster_distortion * 歪み解除オブジェクト(nullの場合歪み解除を省略) * @param i_ref_rob_raster * エッジ探索用のROB画像 * @param */ public NyARVectorReader_INT1D_GRAY_8(NyARGrayscaleRaster i_ref_raster,NyARCameraDistortionFactor i_ref_raster_distortion,NyARGrayscaleRaster i_ref_rob_raster) : base() { Debug.Assert (i_ref_raster.getBufferType() == NyARBufferType.INT1D_GRAY_8); Debug.Assert (i_ref_rob_raster.getBufferType() == NyARBufferType.INT1D_GRAY_8); this.initInstance(i_ref_raster, i_ref_raster_distortion, i_ref_rob_raster,new NyARContourPickup()); }
/** * ラスタの指定点を基点に、輪郭線を抽出します。開始点は、輪郭の一部、かつ左上のエッジで有る必要があります。 * @param i_raster * 輪郭線を抽出するラスタを指定します。 * @param i_th * 輪郭とみなす暗点の敷居値を指定します。 * @param i_entry_x * 輪郭抽出の開始点です。 * @param i_entry_y * 輪郭抽出の開始点です。 * @param o_coord * 輪郭点を格納する配列を指定します。i_array_sizeよりも大きなサイズの配列が必要です。 * @return * 輪郭の抽出に成功するとtrueを返します。輪郭抽出に十分なバッファが無いと、falseになります。 * @throws NyARException */ public bool getContour(NyARGrayscaleRaster i_raster, int i_th, int i_entry_x, int i_entry_y, NyARIntCoordinates o_coord) { Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); NyARIntSize s = i_raster.getSize(); return(impl_getContour(i_raster, 0, 0, s.w - 1, s.h - 1, i_th, i_entry_x, i_entry_y, o_coord)); }
/** * GSラスタの2値ラべリングを実行します。 * @param i_gs_raster * @param i_th * 二値化の敷居値を指定します。 * @param o_stack * 結果を蓄積するスタックオブジェクトを指定します。 * 関数は、このオブジェクトに結果を追記します。 * @return * @throws NyARException */ public virtual void labeling(NyARGrayscaleRaster i_gs_raster, int i_th) { Debug.Assert(i_gs_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); NyARIntSize size = i_gs_raster.getSize(); this.imple_labeling(i_gs_raster, i_th, 0, 0, size.w, size.h); }
/** * ラスタの異解像度間コピーをします。 * @param i_input * 入力ラスタ * @param i_top * 入力ラスタの左上点を指定します。 * @param i_left * 入力ラスタの左上点を指定します。 * @param i_skip * skip値。1なら等倍、2なら1/2倍、3なら1/3倍の偏重の画像を出力します。 * @param o_output * 出力先ラスタ。このラスタの解像度は、w=(i_input.w-i_left)/i_skip,h=(i_input.h-i_height)/i_skipを満たす必要があります。 * 出力先ラスタと入力ラスタのバッファタイプは、同じである必要があります。 */ public void copyTo(int i_left, int i_top, int i_skip, NyARGrayscaleRaster o_output) { Debug.Assert(this.getSize().isInnerSize(i_left + o_output.getWidth() * i_skip, i_top + o_output.getHeight() * i_skip)); Debug.Assert(this.isEqualBufferType(o_output.getBufferType())); this._impl.copyTo(this, i_left, i_top, i_skip, o_output); return; }
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) { Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true); NyARIntSize s = i_input.getSize(); this._do_filter_impl.doFilter(i_input, (int[])i_output.getBuffer(), 0, 0, s.w, s.h); return; }
public void fill(NyARGrayscaleRaster i_raster, int i_value) { Debug.Assert(i_raster._buffer_type == NyARBufferType.INT1D_GRAY_8); int[] buf = (int[])i_raster._buf; for (int i = i_raster._size.h * i_raster._size.w - 1; i >= 0; i--) { buf[i] = i_value; } }
public override void labeling(NyARGrayscaleRaster i_raster, NyARIntRect i_area, int i_th) { //配列初期化 this.label_stack.clear(); //ラベルの検出 base.labeling(i_raster, i_area, i_th); //ソート this.label_stack.sortByArea(); }
public void detectMarker(NyARGrayscaleRaster i_raster, NyARIntRect i_area, int i_th) { Debug.Assert(i_area.w * i_area.h > 0); NyARRleLabelFragmentInfoPtrStack flagment = this._labeling.label_stack; NyARLabelOverlapChecker <NyARRleLabelFragmentInfo> overlap = this._overlap_checker; // ラベル数が0ならここまで this._labeling.labeling(i_raster, i_area, i_th); int label_num = flagment.getLength(); if (label_num < 1) { return; } //ラベルリストを取得 NyARRleLabelFragmentInfo[] labels = flagment.getArray(); NyARIntCoordinates coord = this._coord; int[] mkvertex = this.__detectMarker_mkvertex; //重なりチェッカの最大数を設定 overlap.setMaxLabels(label_num); for (int i = 0; i < label_num; i++) { NyARRleLabelFragmentInfo label_pt = labels[i]; // 既に検出された矩形との重なりを確認 if (!overlap.check(label_pt)) { // 重なっているようだ。 continue; } //輪郭を取得 if (!this._cpickup.getContour(i_raster, i_area, i_th, label_pt.entry_x, label_pt.clip_t, coord)) { continue; } int label_area = label_pt.area; //輪郭線をチェックして、矩形かどうかを判定。矩形ならばmkvertexに取得 if (!this._coord2vertex.getVertexIndexes(coord, label_area, mkvertex)) { // 頂点の取得が出来なかった continue; } //矩形を発見したことをコールバック関数で通知 this.onSquareDetect(coord, mkvertex); // 検出済の矩形の属したラベルを重なりチェックに追加する。 overlap.push(label_pt); } return; }
/** * 継承クラスのコンストラクタから呼び出す。 * @param i_ref_raster * 基本画像 * @param i_ref_raster_distortion * 歪み解除オブジェクト(nullの場合歪み解除を省略) * @param i_ref_rob_raster * エッジ探索用のROB画像 * @param i_contour_pickup * 輪郭線取得クラス * @param */ public void initInstance(NyARGrayscaleRaster i_ref_raster,INyARCameraDistortionFactor i_ref_raster_distortion,NyARGrayscaleRaster i_ref_rob_raster,NyARContourPickup i_contour_pickup) { this._rob_resolution=i_ref_raster.getWidth()/i_ref_rob_raster.getWidth(); this._ref_rob_raster=i_ref_rob_raster; this._ref_base_raster=i_ref_raster; this._coord_buf = new NyARIntCoordinates((i_ref_raster.getWidth() + i_ref_raster.getHeight()) * 4); this._factor=i_ref_raster_distortion; this._tmp_coord_pos = VecLinearCoordinates.VecLinearCoordinatePoint.createArray(this._coord_buf.items.Length); this._cpickup = i_contour_pickup; return; }
public void doCutFilter(INyARRaster i_input, int l, int t, int i_st, NyARGrayscaleRaster o_output) { Debug.Assert(i_input.isEqualBufferType(NyARBufferType.BYTE1D_B8G8R8_24) || i_input.isEqualBufferType(NyARBufferType.BYTE1D_R8G8B8_24)); Debug.Assert(i_input.getSize().isInnerSize(l + o_output.getWidth() * i_st, t + o_output.getHeight() * i_st)); byte[] input = (byte[])i_input.getBuffer(); int[] output = (int[])o_output.getBuffer(); int pt_src, pt_dst; NyARIntSize dest_size = o_output.getSize(); NyARIntSize src_size = i_input.getSize(); int skip_src_y = (src_size.w - dest_size.w * i_st) * 3 + src_size.w * (i_st - 1) * 3; int skip_src_x = 3 * i_st; int pix_count = dest_size.w; int pix_mod_part = pix_count - (pix_count % 8); //左上から1行づつ走査していく pt_dst = 0; pt_src = (t * src_size.w + l) * 3; for (int y = dest_size.h - 1; y >= 0; y -= 1) { int x; for (x = pix_count - 1; x >= pix_mod_part; x--) { output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; } for (; x >= 0; x -= 8) { output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; output[pt_dst++] = ((input[pt_src + 0] & 0xff) + (input[pt_src + 1] & 0xff) + (input[pt_src + 2] & 0xff)) >> 2; pt_src += skip_src_x; } //スキップ pt_src += skip_src_y; } return; }
public void copyTo(NyARGrayscaleRaster i_input, int i_left, int i_top, int i_skip, NyARGrayscaleRaster o_output) { Debug.Assert(i_input.getSize().isInnerSize(i_left + o_output.getWidth() * i_skip, i_top + o_output.getHeight() * i_skip)); int[] input = (int[])i_input.getBuffer(); int[] output = (int[])o_output.getBuffer(); int pt_src, pt_dst; NyARIntSize dest_size = o_output.getSize(); NyARIntSize src_size = i_input.getSize(); int skip_src_y = (src_size.w - dest_size.w * i_skip) + src_size.w * (i_skip - 1); int pix_count = dest_size.w; int pix_mod_part = pix_count - (pix_count % 8); // 左上から1行づつ走査していく pt_dst = 0; pt_src = (i_top * src_size.w + i_left); for (int y = dest_size.h - 1; y >= 0; y -= 1) { int x; for (x = pix_count - 1; x >= pix_mod_part; x--) { output[pt_dst++] = input[pt_src]; pt_src += i_skip; } for (; x >= 0; x -= 8) { output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; output[pt_dst++] = input[pt_src]; pt_src += i_skip; } // スキップ pt_src += skip_src_y; } return; }
public static NyARNftFreakFsetFile genFeatureSet3(NyARNftIsetFile i_iset_file) { int max_features = 500; DogFeaturePointStack _dog_feature_points = new DogFeaturePointStack(max_features); FreakFeaturePointStack query_keypoint = new FreakFeaturePointStack(max_features); // List <NyARNftFreakFsetFile.RefDataSet> refdataset = new List <NyARNftFreakFsetFile.RefDataSet>(); List <NyARNftFreakFsetFile.ImageInfo> imageinfo = new List <NyARNftFreakFsetFile.ImageInfo>(); for (int ii = 0; ii < i_iset_file.items.Length; ii++) { NyARNftIsetFile.ReferenceImage rimg = i_iset_file.items[ii]; FREAKExtractor mFeatureExtractor = new FREAKExtractor(); int octerves = BinomialPyramid32f.octavesFromMinimumCoarsestSize(rimg.width, rimg.height, 8); BinomialPyramid32f _pyramid = new BinomialPyramid32f(rimg.width, rimg.height, octerves, 3); DoGScaleInvariantDetector _dog_detector = new DoGScaleInvariantDetector(rimg.width, rimg.height, octerves, 3, 3, 4, max_features); //RefDatasetの作成 _pyramid.build(NyARGrayscaleRaster.createInstance(rimg.width, rimg.height, NyARBufferType.INT1D_GRAY_8, rimg.img)); // Detect feature points _dog_feature_points.clear(); _dog_detector.detect(_pyramid, _dog_feature_points); // Extract features query_keypoint.clear(); mFeatureExtractor.extract(_pyramid, _dog_feature_points, query_keypoint); for (int i = 0; i < query_keypoint.getLength(); i++) { FreakFeaturePoint ffp = query_keypoint.getItem(i); NyARNftFreakFsetFile.RefDataSet rds = new NyARNftFreakFsetFile.RefDataSet(); rds.pageNo = 1; rds.refImageNo = ii; rds.coord2D.setValue(ffp.x, ffp.y); rds.coord3D.setValue((ffp.x + 0.5f) / rimg.dpi * 25.4f, ((rimg.height - 0.5f) - ffp.y) / rimg.dpi * 25.4f); rds.featureVec.angle = ffp.angle; rds.featureVec.maxima = ffp.maxima ? 1 : 0; rds.featureVec.scale = ffp.scale; ffp.descripter.getValueLe(rds.featureVec.v); refdataset.Add(rds); } imageinfo.Add(new NyARNftFreakFsetFile.ImageInfo(rimg.width, rimg.height, ii)); } NyARNftFreakFsetFile.PageInfo[] pi = new NyARNftFreakFsetFile.PageInfo[1]; pi[0] = new NyARNftFreakFsetFile.PageInfo(1, imageinfo.ToArray()); return(new NyARNftFreakFsetFile(refdataset.ToArray(), pi)); }
/** * @param i_number_of_sample * サンプラが検出する最大数。 * 通常100~200以上を指定します。(QVGA画像あたり、100個を基準にします。) * 数が少なすぎると、検出率が低下します。最低でも、NyARTrackerに設定するターゲット数の合計*2以上を指定してください。 * @param i_ref_raster_distortion * 歪み矯正の為のオブジェクトを指定します。歪み矯正が必要ない時は、NULLを指定します。 * @param i_width * ソース画像のサイズ * @param i_height * ソース画像のサイズ * @param i_depth * 解像度の深さ(1/(2^n))倍の画像として処理する。 * @param i_is_alloc * ベースラスタのバッファを内部確保外部参照にするかのフラグです。 * trueの場合、バッファは内部に確保され、{@link #wrapBuffer}関数が使用できなくなります。 * @throws NyARException */ public NyARTrackerSource_Reference(int i_number_of_sample, INyARCameraDistortionFactor i_ref_raster_distortion, int i_width, int i_height, int i_depth, bool i_is_alloc) : base((int)Math.Pow(2, i_depth)) { Debug.Assert(i_depth>0); int div=this._rob_resolution; //主GSラスタ this._base_raster=new NyARGrayscaleRaster(i_width,i_height,NyARBufferType.INT1D_GRAY_8,i_is_alloc); this._gs_graphics = NyARGsRasterGraphicsFactory.createDriver(this._base_raster); //Roberts変換ラスタ this._rb_source=new NyARGrayscaleRaster(i_width/div,i_height/div,NyARBufferType.INT1D_GRAY_8, true); //Robertsラスタは最も解像度の低いラスタと同じ this._rbraster=new NyARGrayscaleRaster(i_width/div,i_height/div,NyARBufferType.INT1D_GRAY_8, true); this._vec_reader=new NyARVectorReader_INT1D_GRAY_8(this._base_raster,i_ref_raster_distortion,this._rbraster); //samplerとsampleout this._sampler=new LowResolutionLabelingSampler(i_width, i_height,(int)Math.Pow(2,i_depth)); this._sample_out=new LowResolutionLabelingSamplerOut(i_number_of_sample); }
public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output) { Debug.Assert(i_input.getBufferType() == NyARBufferType.INT1D_GRAY_8); Debug.Assert(i_output.getBufferType() == NyARBufferType.INT1D_BIN_8); int[] out_buf = (int[])i_output.getBuffer(); int[] in_buf = (int[])i_input.getBuffer(); NyARIntSize s = i_input.getSize(); int th = this._threshold; int bp = s.w * s.h - 1; int pix_count = s.h * s.w; int pix_mod_part = pix_count - (pix_count % 8); for (bp = pix_count - 1; bp >= pix_mod_part; bp--) { out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; } //タイリング for (; bp >= 0;) { out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; out_buf[bp] = (in_buf[bp] & 0xff) <= th?0:1; bp--; } return; }
public void doFilter(NyARGrayscaleRaster i_input, NyARBinRaster i_output) { Debug.Assert(i_input.getBufferType()==NyARBufferType.INT1D_GRAY_8); Debug.Assert(i_output.getBufferType()==NyARBufferType.INT1D_BIN_8); int[] out_buf = (int[]) i_output.getBuffer(); int[] in_buf = (int[]) i_input.getBuffer(); NyARIntSize s=i_input.getSize(); int th=this._threshold; int bp =s.w*s.h-1; int pix_count =s.h*s.w; int pix_mod_part=pix_count-(pix_count%8); for(bp=pix_count-1;bp>=pix_mod_part;bp--){ out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; } //タイリング for (;bp>=0;) { out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; out_buf[bp]=(in_buf[bp] & 0xff)<=th?0:1; bp--; } return; }
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) { Debug.Assert (i_input.getSize().isEqualSize(i_output.getSize()) == true); this._dofilterimpl.doFilter(i_input,i_output,i_input.getSize()); }
public static INyARGrayscaleRaster createInstance(NyARIntSize i_size) { return(NyARGrayscaleRaster.createInstance(i_size.w, i_size.h, true)); }
/** * 内部参照のバッファ({@link NyARBufferType#INT1D_GRAY_8}形式)を持つインスタンスを生成します。 * @param i_width * ラスタのサイズ * @param i_height * ラスタのサイズ * @throws NyARRuntimeException */ public static INyARGrayscaleRaster createInstance(int i_width, int i_height) { return(NyARGrayscaleRaster.createInstance(i_width, i_height, true)); }
/** * 画像のサイズパラメータとバッファ参照方式を指定して、インスタンスを生成します。 * バッファの形式は、{@link NyARBufferType#INT1D_GRAY_8}です。 * @param i_width * ラスタのサイズ * @param i_height * ラスタのサイズ * @param i_is_alloc * バッファを外部参照にするかのフラグ値。 * trueなら内部バッファ、falseなら外部バッファを使用します。 * falseの場合、初期のバッファはnullになります。インスタンスを生成したのちに、{@link #wrapBuffer}を使って割り当ててください。 * @throws NyARRuntimeException */ public static INyARGrayscaleRaster createInstance(int i_width, int i_height, bool i_is_alloc) { return(NyARGrayscaleRaster.createInstance(i_width, i_height, NyARBufferType.INT1D_GRAY_8, i_is_alloc)); }
/** * 範囲付きでGSラスタの2値ラべリングを実行します。 * @param i_gs_raster * @param i_area * @param i_th * @param o_stack * 結果を蓄積するスタックオブジェクトを指定します。 * 関数は、このオブジェクトに結果を追記します。 * @return * @throws NyARException */ public virtual void labeling(NyARGrayscaleRaster i_gs_raster, NyARIntRect i_area, int i_th) { Debug.Assert(i_gs_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); this.imple_labeling(i_gs_raster, i_th, i_area.x, i_area.y, i_area.w, i_area.h); }
/** * この関数は、インスタンスを初期化します。 * 継承先のクラスから呼び出してください。 * @param i_param * カメラパラメータオブジェクト。このサイズは、{@link #detectMarker}に入力する画像と同じサイズである必要があります。 * @param i_encoder * IDマーカの値エンコーダを指定します。 * @param i_marker_width * マーカの物理縦横サイズをmm単位で指定します。 * @ */ protected void initInstance(NyARParam i_param, INyIdMarkerDataEncoder i_encoder, double i_marker_width) { //初期化済? Debug.Assert(this._initialized == false); NyARIntSize scr_size = i_param.getScreenSize(); // 解析オブジェクトを作る this._square_detect = new RleDetector( i_param, i_encoder, new NyIdMarkerPickup()); this._transmat = new NyARTransMat(i_param); // 2値画像バッファを作る this._gs_raster = new NyARGrayscaleRaster(scr_size.w, scr_size.h); this._histmaker = (INyARHistogramFromRaster)this._gs_raster.createInterface(typeof(INyARHistogramFromRaster)); //ワーク用のデータオブジェクトを2個作る this._data_current = i_encoder.createDataInstance(); this._threshold_detect = new NyARHistogramAnalyzer_SlidePTile(15); this._initialized = true; this._is_active = false; this._offset = new NyARRectOffset(); this._offset.setSquare(i_marker_width); return; }
public void doCutFilter(INyARRaster i_input, int l, int t, int i_st, NyARGrayscaleRaster o_output) { NyARException.notImplement(); }
/** * レイヤ2以降のイメージを生成する。 * idxは{@link #dpi }のlength-1まで。 * @param i_idx * @return */ public ReferenceImage(int i_w, int i_h, int[] i_src, double i_src_dpi, double i_dest_dpi) : this(NyARGrayscaleRaster.createInstance(i_w, i_h, NyARBufferType.INT1D_GRAY_8, i_src), i_src_dpi, i_dest_dpi) { //int1Dラスタのラッパーを通して実行する。 ; return; }
/** * * @param i_raster * @param i_th * 画像を2値化するための閾値。暗点<=i_th<明点となります。 * @param i_entry_x * 輪郭の追跡開始点を指定します。 * @param i_entry_y * @param i_array_size * @param o_coord_x * @param o_coord_y * @return * @throws NyARException */ 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) { Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); return impl_getContour(i_raster, i_th, i_entry_x, i_entry_y, i_array_size, o_coord_x, o_coord_y); }
public bool InitializeApplication(Form1 topLevelForm, CaptureDevice i_cap_device) { this._top_form = topLevelForm; topLevelForm.ClientSize=new Size(SCREEN_WIDTH,SCREEN_HEIGHT); //キャプチャを作る(QVGAでフレームレートは30) i_cap_device.SetCaptureListener(this); i_cap_device.PrepareCapture(SCREEN_WIDTH, SCREEN_HEIGHT, 30); this._cap = i_cap_device; //ARの設定 //ARラスタを作る(DirectShowキャプチャ仕様)。 this._raster = new DsRgbRaster(i_cap_device.video_width, i_cap_device.video_height,NyARBufferType.OBJECT_CS_Bitmap); this.gs = new NyARGrayscaleRaster(i_cap_device.video_width, i_cap_device.video_height); this.filter = NyARRgb2GsFilterFactory.createRgbAveDriver(this._raster); this.tracker = new NyARTracker(100, 1, 10); this.tracksource = new NyARTrackerSource_Reference(100, null, i_cap_device.video_width, i_cap_device.video_height,2, false); return true; }
/** * 同一サイズのラスタi_inputとi_outputの間で、一部の領域だけにラスタ処理を実行します。 * @param i_input * @param i_rect * @param i_output * @throws NyARException */ public void doFilter(INyARRgbRaster i_input, NyARIntRect i_rect, NyARGrayscaleRaster i_output) { Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true); this._do_filter_impl.doFilter(i_input, (int[])i_output.getBuffer(), i_rect.x, i_rect.y, i_rect.w, i_rect.h); }
/** * i_inのデータをサンプリングして、o_outにサンプル値を作成します。 * この関数は、o_outにi_inのサンプリング結果を出力します。既にo_outにあるデータは初期化されます。 * @param i_in * 入力元のデータです。 * @param i_th * ラべリングの敷居値です。 * @param o_out * 出力先のデータです。 * @throws NyARException */ public void sampling(NyARGrayscaleRaster i_in,int i_th,LowResolutionLabelingSamplerOut o_out) { //クラスのパラメータ初期化 Main_Labeling lb=this._main_labeling; lb.current_output=o_out; lb.current_th=i_th; //パラメータの設定 o_out.initializeParams(); //ラべリング lb.setAreaRange(10000,3); lb.labeling(i_in,i_th); }
public bool getContour(NyARGrayscaleRaster i_raster, NyARIntRect i_area, int i_th, int i_entry_x, int i_entry_y, NyARIntCoordinates o_coord) { Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); return(impl_getContour(i_raster, i_area.x, i_area.y, i_area.x + i_area.w - 1, i_area.h + i_area.y - 1, i_th, i_entry_x, i_entry_y, o_coord)); }
/** * GS画像をセットします。 * この関数を使ってセットした画像は、インスタンスから参照されます。 * @param i_ref_source * @throws NyARException */ public void wrapBuffer(NyARGrayscaleRaster i_ref_source) { //バッファのスイッチ this._base_raster.wrapBuffer(i_ref_source.getBuffer()); }
/** * BINラスタをラベリングします。 * @param i_gs_raster * @param i_th * 画像を2値化するための閾値。暗点<=th<明点となります。 * @param i_top * @param i_bottom * @param o_stack * @return * @throws NyARException */ public int labeling(NyARGrayscaleRaster i_gs_raster, int i_th, int i_top, int i_bottom, RleLabelFragmentInfoStack o_stack) { Debug.Assert(i_gs_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); return(this.imple_labeling(i_gs_raster, i_th, i_top, i_bottom, o_stack)); }
/** * この関数は、インスタンスを初期化します。 * 継承先のクラスから呼び出してください。 * @param i_param * カメラパラメータオブジェクト。このサイズは、{@link #detectMarker}に入力する画像と同じサイズである必要があります。 * @ */ protected void initInstance(NyARParam i_param) { //初期化済? Debug.Assert(this._initialized == false); NyARIntSize scr_size = i_param.getScreenSize(); // 解析オブジェクトを作る this._transmat = new NyARTransMat(i_param); this._thdetect = new NyARHistogramAnalyzer_SlidePTile(15); // 2値画像バッファを作る this._gs_raster = new NyARGrayscaleRaster(scr_size.w, scr_size.h); this._initialized = true; //コールバックハンドラ this._detectmarker = new DetectSquare(i_param); this._offset = new NyARRectOffset(); return; }
/** * 異サイズのラスタi_inputとi_outputの間で、一部の領域をi_outputへ転送します。 * 関数は、i_outputのサイズをi_skip倍した領域を、i_inputのi_left,i_topの位置から切り出し、フィルタ処理をしてi_outputへ格納します。 * @param i_input * @param i_left * @param i_top * @param i_skip * @param i_output */ public void doCutFilter(INyARRgbRaster i_input, int i_left, int i_top, int i_skip, NyARGrayscaleRaster i_output) { this._do_filter_impl.doCutFilter(i_input, i_left, i_top, i_skip, i_output); }
/** * * @param i_raster * @param i_th * 画像を2値化するための閾値。暗点<=i_th<明点となります。 * @param i_entry_x * 輪郭の追跡開始点を指定します。 * @param i_entry_y * @param i_array_size * @param o_coord_x * @param o_coord_y * @return * @throws NyARException */ 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) { Debug.Assert(i_raster.isEqualBufferType(NyARBufferType.INT1D_GRAY_8)); return(impl_getContour(i_raster, i_th, i_entry_x, i_entry_y, i_array_size, o_coord_x, o_coord_y)); }
public void doFilter(INyARRgbRaster i_input, NyARGrayscaleRaster i_output) { Debug.Assert(i_input.getSize().isEqualSize(i_output.getSize()) == true); this._do_filter_impl.doFilter(i_input, i_output, i_input.getSize()); return; }