public NyARCode createNyARCode() { NyARCode result = new NyARCode(this._code_size, this._code_size); result.loadARPattFromFile(this._root_path + "\\" + this._code_file); return(result); }
public SimpleLiteD3d(NyARToolkitCS topLevelForm, ResourceBuilder i_resource) { NyMath.initialize(); this._capture = i_resource.createWmCapture(); this._capture.setOnSample(this); this._d3dmgr = i_resource.createD3dManager(topLevelForm); this._back_ground = i_resource.createBackGround(this._d3dmgr); this._d3dcube = new ColorCube(this._d3dmgr.d3d_device, 40); //AR用のパターンコードを読み出 NyARCode code = i_resource.createNyARCode(); //ARラスタを作る(DirectShowキャプチャ仕様)。 this.m_raster = i_resource.createARRaster(); //1パターンのみを追跡するクラスを作成 this.m_ar = new NyARSingleDetectMarker(i_resource.ar_param, code, 80.0, this.m_raster.getBufferType()); //計算モードの設定 this.m_ar.setContinueMode(false); ////立方体(頂点数8)の準備 return; }
protected void initInstance( INyARColorPatt i_patt_inst, NyARSquareContourDetector i_sqdetect_inst, INyARTransMat i_transmat_inst, INyARRasterFilter_Rgb2Bin i_filter, NyARParam i_ref_param, NyARCode i_ref_code, double i_marker_width) { NyARIntSize scr_size = i_ref_param.getScreenSize(); // 解析オブジェクトを作る this._square_detect = i_sqdetect_inst; this._transmat = i_transmat_inst; this._tobin_filter = i_filter; //2値画像バッファを作る this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h); //パターンの一致検索処理用 this._inst_patt = i_patt_inst; this._deviation_data = new NyARMatchPattDeviationColorData(i_ref_code.getWidth(), i_ref_code.getHeight()); this._coordline = new NyARCoord2Linear(i_ref_param.getScreenSize(), i_ref_param.getDistortionFactor()); this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code); //オフセットを作成 this._offset = new NyARRectOffset(); this._offset.setSquare(i_marker_width); return; }
public MainWindow() { InitializeComponent(); CaptureDeviceList cl = new CaptureDeviceList(); m_cap = cl[0]; m_cap.SetCaptureListener(this); m_cap.PrepareCapture(cameraResX, cameraResY, 30); // 800x600 resolution, 30 fps NyARParam ap = new NyARParam(); ap.loadARParamFromFile(AR_CAMERA_FILE); ap.changeScreenSize(cameraResX, cameraResY); this.m_raster = new NyARRgbRaster(m_cap.video_width, m_cap.video_height, NyARBufferType.BYTE1D_R8G8B8_24, false); NyARCode code = new NyARCode(16, 16); // 16 pixels to detect within black box code.loadARPattFromFile(AR_CODE_FILE); this.m_ar = new NyARDetectMarker(ap, new NyARCode[] { code }, new double[] { 80.0 }, 1, NyARBufferType.BYTE1D_B8G8R8_24); this.m_ar.setContinueMode(false); this.Loaded += MainWindow_Loaded; }
/** * この関数は、ARToolKitスタイルのマーカーをストリームから読みだして、登録します。 * @param i_stream * マーカデータを読み出すストリーム * @param i_patt_edge_percentage * エッジ割合。ARToolkitと同じ場合は25を指定します。 * @param i_marker_size * マーカの平方サイズ[mm] * @return * マーカID(ハンドル)値。 * @throws NyARException */ public int addARMarker(StreamReader i_stream, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); c.loadARPatt(i_stream); return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }
public Form1() { InitializeComponent(); //ARの設定 //AR用カメラパラメタファイルをロード NyARParam ap = NyARParam.loadFromARParamFile(File.OpenRead(AR_CAMERA_FILE), 320, 240); //AR用のパターンコードを読み出し NyARCode code = NyARCode.loadFromARPattFile(File.OpenRead(AR_CODE_FILE), 16, 16); NyARDoubleMatrix44 result_mat = new NyARDoubleMatrix44(); //計算モードの設定 //キャプチャを作る /************************************************** * このコードは、0番目(一番初めに見つかったキャプチャデバイス) * を使用するようにされています。 * 複数のキャプチャデバイスを持つシステムの場合、うまく動作しないかもしれません。 * n番目のデバイスを使いたいときには、CaptureDevice cap=cl[0];←ここの0を変えてください。 * 手動で選択させる方法は、SimpleLiteDirect3Dを参考にしてください。 **************************************************/ CaptureDeviceList cl = new CaptureDeviceList(); CaptureDevice cap = cl[0]; cap.SetCaptureListener(this); cap.PrepareCapture(320, 240, 30); this.m_cap = cap; //ラスタを作る。 this.m_raster = new DsRgbRaster(cap.video_width, cap.video_height); //1パターンのみを追跡するクラスを作成 this.m_ar = NyARSingleDetectMarker.createInstance(ap, code, 80.0); this.m_ar.setContinueMode(false); }
public MainWindow() { InitializeComponent(); this.GdMainZm.Height = 600; this.CameraZm.Height = 600; this.CameraZm.DesiredPixelHeight = 600; this.GdMainZm.Width = 800; this.CameraZm.Width = 800; this.CameraZm.DesiredPixelWidth = 800; this.CameraZm.EnableSampleGrabbing = true; this.CameraZm.NewVideoSample += CameraZm_NewVideoSample; NyARParam ap = NyARParam.loadFromARParamFile(File.OpenRead(AR_CAMERA_FILE), 800, 600); this.ARRgbRaster = new NyARRgbRaster_BYTE1D_B8G8R8_24(800, 600, false); NyARCode code = NyARCode.loadFromARPattFile(File.OpenRead(AR_CODE_FILE), 16, 16); this.ARDetectMarker = new NyARDetectMarker(ap, new NyARCode[] { code }, new double[] { 80.0 }, 1); this.ARDetectMarker.setContinueMode(false); this.Loaded += MainWindow_Loaded; }
public NyARSingleDetectMarker_NyARTK_FITTING_ARTKv2(NyARParam i_ref_param, NyARCode i_ref_code, double i_marker_width) : base(i_ref_param, i_ref_code, i_marker_width) { this._inst_patt = new NyARColorPatt_Perspective(i_ref_code.getWidth(), i_ref_code.getHeight(), 4, 25); this._transmat = new NyARTransMat_ARToolKit(i_ref_param); this._square_detect = new NyARSingleDetectMarker_ARTKv2.ARTKDetector(this, i_ref_param.getScreenSize()); }
public DetectSquareCB(INyARColorPatt i_inst_patt, NyARCode i_ref_code, NyARParam i_param) { this._inst_patt = i_inst_patt; this._deviation_data = new NyARMatchPattDeviationColorData(i_ref_code.getWidth(), i_ref_code.getHeight()); this._coordline = new Coord2Linear(i_param.getScreenSize(), i_param.getDistortionFactor()); this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code); return; }
public int addARMarker(NyARCode i_code, int i_patt_edge_percentage, double i_marker_size) { ARMarkerList.Item target = new ARMarkerList.Item(i_code, i_patt_edge_percentage, i_marker_size); this._armk_list.add(target); this._tracking_list.add(target); this._on_sq_handler.setMaxDetectMarkerCapacity(this._tracking_list.Count); return((this._armk_list.Count - 1) | IDTYPE_ARTK); }
public void setValue(NyARCode i_code, int i_idtag, String i_name, double i_width, double i_height) { this.code = i_code; this.marker_height = i_height; this.marker_width = i_width; this.name = i_name; this.idtag = i_idtag; }
/** * この関数は、ARToolKitスタイルのマーカーを登録します。 * @param i_code * 登録するマーカパターンオブジェクト * @param i_patt_edge_percentage * エッジ割合。ARToolkitと同じ場合は25を指定します。 * @param i_marker_size * マーカの平方サイズ[mm] * @return * マーカID(ハンドル)値。 * @throws NyARException */ public int addARMarker(NyARCode i_code, int i_patt_edge_percentage, double i_marker_size) { MarkerInfoARMarker target = new MarkerInfoARMarker(i_code, i_patt_edge_percentage, i_marker_size); this._armk_list.add(target); this._tracking_list.add(target); return((this._armk_list.Count - 1) | IDTYPE_ARTK); }
private void InitARConfigs() { NyARParam ap = NyARParam.loadFromARParamFile(File.OpenRead(AR_CAMERA_FILE), 800, 600); NyARCode code = NyARCode.loadFromARPattFile(File.OpenRead(AR_CODE_FILE2), 16, 16); this.MyArRaster = new DsRgbRaster(800, 600); this.MySingleDetectMarker = NyARSingleDetectMarker.createInstance(ap, code, 80.0); this.MySingleDetectMarker.setContinueMode(false); }
public bool InitializeApplication(Form1 topLevelForm, CaptureDevice i_cap_device) { 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ラスタを作る(DirectShowキャプチャ仕様)。 this._raster = new DsRgbRaster(i_cap_device.video_width, i_cap_device.video_height); //AR用カメラパラメタファイルをロードして設定 NyARParam ap = NyARParam.loadFromARParamFile(File.OpenRead(AR_CAMERA_FILE), SCREEN_WIDTH, SCREEN_HEIGHT); //Direct3d用のユーティリティ準備 //プロセッサの準備 this._processor = new MarkerProcessor(ap, this._raster.getBufferType()); NyARCode[] codes = new NyARCode[2]; codes[0] = NyARCode.loadFromARPattFile(File.OpenRead(AR_CODE_FILE1), 16, 16); codes[1] = NyARCode.loadFromARPattFile(File.OpenRead(AR_CODE_FILE2), 16, 16); this._processor.setARCodeTable(codes, 16, 80.0); //3dデバイスを準備する this._device = PrepareD3dDevice(topLevelForm); this._device.RenderState.ZBufferEnable = true; this._device.RenderState.Lighting = false; this._device.RenderState.CullMode = Cull.CounterClockwise; Viewport vp = new Viewport(); vp.X = 0; vp.Y = 0; vp.Height = ap.getScreenSize().h; vp.Width = ap.getScreenSize().w; vp.MaxZ = 1.0f; //ビューポート設定 this._device.Viewport = vp; this._text = new TextPanel(this._device, 1); //カメラProjectionの設定 Matrix tmp = new Matrix(); NyARD3dUtil.toCameraFrustumRH(ap.getPerspectiveProjectionMatrix(), ap.getScreenSize(), 1, 10, 10000, ref tmp); this._device.Transform.Projection = tmp; // ビュー変換の設定(左手座標系ビュー行列で設定する) // 0,0,0から、Z+方向を向いて、上方向がY軸 this._device.Transform.View = Matrix.LookAtLH( new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, 1.0f, 0.0f)); //背景サーフェイスを作成 this._surface = new NyARD3dSurface(this._device, SCREEN_WIDTH, SCREEN_HEIGHT); return(true); }
/** * この関数は、ARToolKitスタイルのマーカーをファイルから読みだして、登録します。 * @param i_stream * マーカデータを読み出すストリーム * @param i_patt_edge_percentage * エッジ割合。ARToolkitと同じ場合は25を指定します。 * @param i_marker_size * マーカの平方サイズ[mm] * @return * マーカID(ハンドル)値。 * @throws NyARException */ public int addARMarker(String i_file_name, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { try{ NyARCode c = NyARCode.createFromARPattFile(new StreamReader(i_file_name), i_patt_resolution, i_patt_resolution); return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }catch (Exception e) { throw new NyARException(e); } }
/** */ public Item(NyARCode i_patt, int i_patt_edge_percentage, double i_patt_size) { //base(); this.matchpatt = new NyARMatchPatt_Color_WITHOUT_PCA(i_patt); this.patt_edge_percentage = i_patt_edge_percentage; this.marker_offset.setSquare(i_patt_size); this.patt_w = i_patt.getWidth(); this.patt_h = i_patt.getHeight(); return; }
/** * この関数は、ARToolKitスタイルのマーカーをファイルから読みだして、登録します。 * @param i_stream * マーカデータを読み出すストリーム * @param i_patt_edge_percentage * エッジ割合。ARToolkitと同じ場合は25を指定します。 * @param i_marker_size * マーカの平方サイズ[mm] * @return * マーカID(ハンドル)値。 * @throws NyARException */ public int addARMarker(String i_file_name, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); try{ c.loadARPatt(new StreamReader(i_file_name)); }catch (Exception e) { throw new NyARException(e); } return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }
/** * ARTKパターンコードを、テーブルに追加します。このパターンコードのメタデータとして、IDと名前を指定できます。 * @param i_code * ARToolKit形式のパターンコードを格納したオブジェクト。このオブジェクトは、関数成功後はインスタンスに所有されます。 * パターンコードの解像度は、コンストラクタに指定した高さと幅である必要があります。 * @param i_id * このマーカを識別するユーザ定義のID値です。任意の値を指定できます。不要な場合は0を指定してください。 * @param i_name * ユーザ定義の名前です。任意の値を指定できます。不要な場合はnullを指定して下さい。 * @param i_width * マーカの高さ[通常mm単位] * @param i_height * マーカの幅[通常mm単位] * @return */ public bool addMarker(NyARCode i_code, int i_id, String i_name, double i_width, double i_height) { Debug.Assert(i_code.getHeight() == this._resolution_height && i_code.getHeight() == this._resolution_width); MarkerTable.SerialTableRow d = this._table.prePush(); if (d == null) { return(false); } d.setValue(i_code, i_id, i_name, i_width, i_height); return(true); }
protected NyARSingleDetectMarker(NyARParam i_ref_param, NyARCode i_ref_code, double i_marker_width) { this._deviation_data = new NyARMatchPattDeviationColorData(i_ref_code.getWidth(), i_ref_code.getHeight()); this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code); this._offset = new NyARRectOffset(); this._offset.setSquare(i_marker_width); this._coordline = new NyARCoord2Linear(i_ref_param.getScreenSize(), i_ref_param.getDistortionFactor()); //2値画像バッファを作る NyARIntSize s = i_ref_param.getScreenSize(); this._bin_raster = new NyARBinRaster(s.w, s.h); }
/** * ARToolkit準拠のパターンファイルからパターンコードを生成して、テーブルへ追加します。 * @param i_filename * @param i_id * このマーカを識別するユーザ定義のID値です。任意の値を指定できます。不要な場合は0を指定してください。 * @param i_name * ユーザ定義の名前です。任意の値を指定できます。不要な場合はnullを指定して下さい。 * @param i_width * マーカの高さ[通常mm単位] * @param i_height * マーカの幅[通常mm単位] * @return * @throws NyARException */ public bool addMarkerFromARPatt(StreamReader i_stream, int i_id, String i_name, double i_width, double i_height) { MarkerTable.SerialTableRow d = this._table.prePush(); if (d == null) { return(false); } NyARCode c = NyARCode.createFromARPattFile(i_stream, this._resolution_width, this._resolution_height); d.setValue(c, i_id, i_name, i_width, i_height); return(true); }
public int addARMarker(INyARRgbRaster i_raster, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); NyARIntSize s = i_raster.getSize(); INyARPerspectiveCopy pc = (INyARPerspectiveCopy)i_raster.createInterface(typeof(INyARPerspectiveCopy)); INyARRgbRaster tr = NyARRgbRaster.createInstance(i_patt_resolution, i_patt_resolution); pc.copyPatt(0, 0, s.w, 0, s.w, s.h, 0, s.h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr); c.setRaster(tr); return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }
public int addARMarker(String i_file_name, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { try { NyARCode c = NyARCode.loadFromARPattFile(File.OpenRead(i_file_name), i_patt_resolution, i_patt_resolution); return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size)); } catch (Exception e) { throw new NyARRuntimeException(e); } }
/** * ARToolkit準拠のパターンファイルからパターンコードを生成して、テーブルへ追加します。 * @param i_filename * @param i_id * このマーカを識別するユーザ定義のID値です。任意の値を指定できます。不要な場合は0を指定してください。 * @param i_name * ユーザ定義の名前です。任意の値を指定できます。不要な場合はnullを指定して下さい。 * @param i_width * マーカの高さ[通常mm単位] * @param i_height * マーカの幅[通常mm単位] * @return * @throws NyARException */ public bool addMarkerFromARPattFile(String i_filename, int i_id, String i_name, double i_width, double i_height) { MarkerTable.SerialTableRow d = this._table.prePush(); if (d == null) { return(false); } NyARCode c = new NyARCode(this._resolution_width, this._resolution_height); c.loadARPattFromFile(i_filename); d.setValue(c, i_id, i_name, i_width, i_height); return(true); }
/** * i_rasterからパターンコードを生成して、テーブルへ追加します。 * @param i_raster * @param i_id * このマーカを識別するユーザ定義のID値です。任意の値を指定できます。不要な場合は0を指定してください。 * @param i_name * ユーザ定義の名前です。任意の値を指定できます。不要な場合はnullを指定して下さい。 * @param i_width * マーカの高さ[通常mm単位] * @param i_height * マーカの幅[通常mm単位] * @return * @throws NyARException */ public bool addMarker(NyARRgbRaster i_raster, int i_id, String i_name, double i_width, double i_height) { MarkerTable.SerialTableRow d = this._table.prePush(); if (d == null) { return(false); } NyARCode c = new NyARCode(this._resolution_width, this._resolution_height); c.setRaster(i_raster); d.setValue(c, i_id, i_name, i_width, i_height); return(true); }
public void Test_arDetectMarkerLite() { Assembly assembly = Assembly.GetExecutingAssembly(); //AR用カメラパラメタファイルをロード NyARParam ap = new NyARParam(); ap.loadARParam(assembly.GetManifestResourceStream(RES_CAMERA)); ap.changeScreenSize(320, 240); //AR用のパターンコードを読み出し NyARCode code = new NyARCode(16, 16); Stream sr1 = assembly.GetManifestResourceStream(RES_PATT); code.loadARPatt(new StreamReader(sr1)); //試験イメージの読み出し(320x240 BGRAのRAWデータ) StreamReader sr = new StreamReader(assembly.GetManifestResourceStream(RES_DATA)); BinaryReader bs = new BinaryReader(sr.BaseStream); byte[] raw = bs.ReadBytes(320 * 240 * 4); NyARRgbRaster_BGRA ra = new NyARRgbRaster_BGRA(320, 240, false); ra.wrapBuffer(raw); // Blank_Raster ra=new Blank_Raster(320, 240); //1パターンのみを追跡するクラスを作成 // NyARSingleDetectMarker_Quad ar = new NyARSingleDetectMarker_Quad(ap, code, 80.0); NyARSingleDetectMarker ar = new NyARSingleDetectMarker(ap, code, 80.0, ra.getBufferType()); NyARTransMatResult result_mat = new NyARTransMatResult(); ar.setContinueMode(false); ar.detectMarkerLite(ra, 100); ar.getTransmationMatrix(result_mat); //マーカーを検出 for (int i3 = 0; i3 < 10; i3++) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 10; i++) { //変換行列を取得 ar.detectMarkerLite(ra, 100); ar.getTransmationMatrix(result_mat); } sw.Stop(); Debug.WriteLine(sw.ElapsedMilliseconds + "[ms]"); } return; }
public void Test() { //AR用カメラパラメタファイルをロード NyARParam ap = NyARParam.createFromARParamFile(new StreamReader(camera_file)); ap.changeScreenSize(320, 240); //AR用のパターンコードを読み出し NyARCode code = NyARCode.createFromARPattFile(new StreamReader(code_file), 16, 16); //試験イメージの読み出し(320x240 BGRAのRAWデータ) StreamReader sr = new StreamReader(data_file); BinaryReader bs = new BinaryReader(sr.BaseStream); byte[] raw = bs.ReadBytes(320 * 240 * 4); // NyARBitmapRaster ra = new NyARBitmapRaster(320, 240); // Graphics g = Graphics.FromImage(ra.getBitmap()); // g.DrawImage(new Bitmap("../../../../../data/320x240ABGR.png"), 0, 0); NyARRgbRaster ra = new NyARRgbRaster(320, 240, NyARBufferType.BYTE1D_B8G8R8X8_32, false); ra.wrapBuffer(raw); //1パターンのみを追跡するクラスを作成 NyARSingleDetectMarker ar = NyARSingleDetectMarker.createInstance(ap, code, 80.0, NyARSingleDetectMarker.PF_NYARTOOLKIT); NyARDoubleMatrix44 result_mat = new NyARDoubleMatrix44(); ar.setContinueMode(false); ar.detectMarkerLite(ra, 100); ar.getTransmationMatrix(result_mat); //マーカーを検出 Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000; i++) { //変換行列を取得 ar.detectMarkerLite(ra, 100); ar.getTransmationMatrix(result_mat); } Console.WriteLine(result_mat.m00 + "," + result_mat.m01 + "," + result_mat.m02 + "," + result_mat.m03); Console.WriteLine(result_mat.m10 + "," + result_mat.m11 + "," + result_mat.m12 + "," + result_mat.m13); Console.WriteLine(result_mat.m20 + "," + result_mat.m21 + "," + result_mat.m22 + "," + result_mat.m23); Console.WriteLine(result_mat.m30 + "," + result_mat.m31 + "," + result_mat.m32 + "," + result_mat.m33); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds + "[ms]"); return; }
/// <summary> /// {@link #addARMarker(INyARRgbRaster, int, int, double)}のラッパーです。Bitmapからマーカパターンを作ります。 /// 引数については、{@link #addARMarker(INyARRgbRaster, int, int, double)}を参照してください。 /// /// </summary> /// <param name="i_img"></param> /// <param name="i_patt_resolution">生成するマーカの解像度を指定します。</param> /// <param name="i_patt_edge_percentage">画像のエッジ領域を%で指定します。</param> /// <param name="i_marker_size">マーカの物理サイズを指定します。</param> /// <returns></returns> public int addARMarker(Texture2D i_img, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { int w = i_img.width; int h = i_img.height; NyARUnityRaster ur = new NyARUnityRaster(i_img); NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); //ラスタからマーカパターンを切り出す INyARPerspectiveCopy pc = (INyARPerspectiveCopy)ur.createInterface(typeof(INyARPerspectiveCopy)); NyARRgbRaster tr = new NyARRgbRaster(i_patt_resolution, i_patt_resolution); pc.copyPatt(0, 0, w, 0, w, h, 0, h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr); //切り出したパターンをセット c.setRaster(tr); return(base.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }
// // This reogion may be moved to NyARJ2seMarkerSystem. // /// <summary> /// {@link #addARMarker(INyARRgbRaster, int, int, double)}のラッパーです。Bitmapからマーカパターンを作ります。 /// 引数については、{@link #addARMarker(INyARRgbRaster, int, int, double)}を参照してください。 /// /// </summary> /// <param name="i_img"></param> /// <param name="i_patt_resolution">生成するマーカの解像度を指定します。</param> /// <param name="i_patt_edge_percentage">画像のエッジ領域を%で指定します。</param> /// <param name="i_marker_size">マーカの物理サイズを指定します。</param> /// <returns></returns> public int addARMarker(Bitmap i_img, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { int w = i_img.Width; int h = i_img.Height; using (NyARBitmapRaster bmr = new NyARBitmapRaster(i_img)) { NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); //ラスタからマーカパターンを切り出す。 INyARPerspectiveCopy pc = (INyARPerspectiveCopy)bmr.createInterface(typeof(INyARPerspectiveCopy)); NyARRgbRaster tr = new NyARRgbRaster(i_patt_resolution, i_patt_resolution); pc.copyPatt(0, 0, w, 0, w, h, 0, h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr); //切り出したパターンをセット c.setRaster(tr); return(base.addARMarker(c, i_patt_edge_percentage, i_marker_size)); } }
/** * 処理プロファイルを指定して、{@link NyARSingleDetectoMarker}オブジェクトを生成します。 * @param i_param * カメラパラメータを指定します。このサイズは、{@link #detectMarkerLite}に入力する画像と同じである必要があります。 * @param i_code * 検出するマーカパターンを指定します。 * @param i_marker_width * 正方形マーカの物理サイズをmm単位で指定します。 * @param i_input_raster_type * {@link #detectMarkerLite}に入力するラスタの画素形式を指定します。 * この値は、{@link INyARRgbRaster#getBufferType}関数の戻り値を利用します。 * @param i_profile_id * 計算アルゴリズムの選択値です。以下の定数のいずれかを指定します。 * <ul> * <li>{@link #PF_ARTOOLKIT_COMPATIBLE} * <li>{@link #PF_NYARTOOLKIT} * <li>{@link #PF_NYARTOOLKIT_ARTOOLKIT_FITTING} * </ul> * @ * @ */ public static NyARSingleDetectMarker createInstance(NyARParam i_param, NyARCode i_code, double i_marker_width, int i_profile_id) { switch (i_profile_id) { case PF_ARTOOLKIT_COMPATIBLE: return(new NyARSingleDetectMarker_ARTKv2(i_param, i_code, i_marker_width)); case PF_NYARTOOLKIT_ARTOOLKIT_FITTING: return(new NyARSingleDetectMarker_NyARTK_FITTING_ARTKv2(i_param, i_code, i_marker_width)); case PF_NYARTOOLKIT://default return(new NyARSingleDetectMarker_NyARTK(i_param, i_code, i_marker_width)); default: throw new NyARException(); } }
public MainWindow() { InitializeComponent(); CaptureDeviceList cl = new CaptureDeviceList(); m_cap = cl[0]; m_cap.SetCaptureListener(this); m_cap.PrepareCapture(800, 600, 30); NyARParam ap = NyARParam.loadFromARParamFile(File.OpenRead(AR_CAMERA_FILE), 800, 600); this.m_raster = new NyARRgbRaster_BYTE1D_B8G8R8_24(m_cap.video_width, m_cap.video_height, false); NyARCode code = NyARCode.loadFromARPattFile(File.OpenRead(AR_CODE_FILE), 16, 16); this.m_ar = new NyARDetectMarker(ap, new NyARCode[] { code }, new double[] { 80.0 }, 1); this.m_ar.setContinueMode(false); this.Loaded += MainWindow_Loaded; this.Closing += MainWindow_Closing; }