[非推奨]グレイサーチの実行(圧縮度を強制する版)
Namespace: fvalgcliAssembly: fvalgcli_fga (in fvalgcli_fga.dll) Version: 3.1.0.0 (3.1.0.3)
Syntax
C# |
---|
public static int fnFGA_gs2_search_enforce( FHANDLE hgs, FHANDLE hpattern, FHANDLE himage, BOX_T search_window, int threshold_mid, int threshold_final, bool edge_detect, bool reverse_mode, int pitch_x, int pitch_y, int first_unit, int last_unit, F_GS_RESULT_PTR result, int max_result_num, ref int result_num ) |
Visual Basic |
---|
Public Shared Function fnFGA_gs2_search_enforce ( hgs As FHANDLE, hpattern As FHANDLE, himage As FHANDLE, search_window As BOX_T, threshold_mid As Integer, threshold_final As Integer, edge_detect As Boolean, reverse_mode As Boolean, pitch_x As Integer, pitch_y As Integer, first_unit As Integer, last_unit As Integer, result As F_GS_RESULT_PTR, max_result_num As Integer, ByRef result_num As Integer ) As Integer |
Parameters
- hgs
- Type: fvalgcli..::..FHANDLE
グレイサーチオブジェクト
- hpattern
- Type: fvalgcli..::..FHANDLE
グレイサーチパターンオブジェクト
- himage
- Type: fvalgcli..::..FHANDLE
サーチ対象となる画像オブジェクト ( type : uc8 )。 チャネル数は1でなければいけません。 また、パタンのサイズよりも縦横共に大きい必要があります。
- search_window
- Type: fvalgcli..::..BOX_T
サーチウインドウ。 画像オブジェクトの中でサーチを行う処理範囲を himage 上の座標で指定します。 himage の内部に納まるように座標を指定する必要があります。 また、パタンのサイズよりも大きい必要があります。
- threshold_mid
- Type: System..::..Int32
途中相関値 ( 1000 〜 9999 )
- threshold_final
- Type: System..::..Int32
最終相関値 ( 1000 〜 9999 )
- edge_detect
- Type: System..::..Boolean
サーチウインドウ周囲接触フラグ- TRUE サーチウインドウに接したパターンも検出
- FALSE サーチウインドウに接したパターンを検出しない
- reverse_mode
- Type: System..::..Boolean
反転パターン検出モードフラグ。 濃度反転しているパターンも検出するかどうかを指定します。- TRUE 反転パターンも検出
- FALSE 反転パターンを検出しない
- pitch_x
- Type: System..::..Int32
最終的な回答の出力時に、同一の解であるとみなす範囲を指定します。 0を入力した場合、パターン幅の半分になります。
- pitch_y
- Type: System..::..Int32
最終的な回答の出力時に、同一の解であるとみなす範囲を指定します。 0を入力した場合、パターン高さの半分になります。
- first_unit
- Type: System..::..Int32
サーチ開始圧縮度を指定します。( 0 〜 9 ) 圧縮度がnのとき、2の-n乗倍の画像でサーチを開始します。
- last_unit
- Type: System..::..Int32
サーチ終了圧縮度を指定します。( 0 〜 9 ) 圧縮度がnのとき、2の-n乗倍の画像でサーチを完了します。
- result
- Type: fvalgcli..::..F_GS_RESULT_PTR
サーチ結果。 サーチスコア( 0 〜 10000 )と結果座標の100倍値を返します。
- max_result_num
- Type: System..::..Int32
サーチ結果取得個数。 相関値の上位からこの個数だけ回答します。 result はこの個数よりも大きい配列でなければいけません。
- result_num
- Type: System..::..Int32%
見つかったサーチ結果の個数 ( 0 〜 max_result_num )
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_PARAM | 引数異常 引数オブジェクトがない、範囲外の引数を与えた、継続サーチ時に圧縮フィルタ種別が同一でないなど |
F_ERR_INVALID_OBJECT | 引数オブジェクトの種別が異常 |
F_ERR_NOMEMORY | メモリ不足 |
F_ERR_INVALID_IMAGE | 対応していない画像が渡された |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Remarks
Examples
C# | Copy |
---|---|
// $Revision: 1.3 $ using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using fvalgcli; namespace TC { public partial class FIE { [FvPluginExecute] public void fnFGA_gs2_search_enforce() { int status = (int)f_err.F_ERR_NONE; FHANDLE hfie_src = FHANDLE.Zero; FHANDLE hfga_src = FHANDLE.Zero; FHANDLE hfga_gs2 = FHANDLE.Zero; FHANDLE hfga_roi = FHANDLE.Zero; FHANDLE hfga_msk = FHANDLE.Zero; FHANDLE hfga_ptn = FHANDLE.Zero; F_GS_RESULT_PTR result = IntPtr.Zero; try { // サーチ対象画像の読み込み. status = api.fnFIE_load_img_file(Defs.TestImageDir + "/TC/SampleCode/key_UC8_M.png", ref hfie_src, f_color_img_type.F_COLOR_IMG_TYPE_UC8); // 入力画像の情報取得. int width = api.fnFIE_img_get_width(hfie_src); int height = api.fnFIE_img_get_height(hfie_src); int channels = api.fnFIE_img_get_channels(hfie_src); int type = api.fnFIE_img_get_type(hfie_src); // 入出力画像の生成. hfga_src = fga.fnFGA_img_root_alloc(type, channels, width, height); // FGA 用. // FIE 画像オブジェクトから FGA 画像オブジェクトへコピー. fga.fnFGA_img_copy(hfie_src, hfga_src); // グレイサーチオブジェクトの生成. uint first_buff_size = 0; uint last_buff_size = 0; uint cache_pow_num = 0; hfga_gs2 = fga.fnFGA_gs2_alloc(first_buff_size, last_buff_size, cache_pow_num); if (hfga_gs2 == IntPtr.Zero) throw new FvException(f_err.F_ERR_NOMEMORY, "エラーが発生しました。"); // グレイサーチパターンオブジェクト作成. hfga_roi = fga.fnFGA_img_child_alloc(hfga_src, 50, 0, 80, 80); int mark_offsetx = 10; int mark_offsety = 10; hfga_ptn = fga.fnFGA_gs2_pattern_alloc(hfga_roi, hfga_msk, mark_offsetx, mark_offsety, f_comp_filter.F_COMP_MODE_SMOOTH, ref status); if (status != (int)f_err.F_ERR_NONE) throw new FvException(status, "エラーが発生しました。"); // グレイサーチ実行. BOX_T search_window = new BOX_T(); search_window.st.x = 0; search_window.st.y = 0; search_window.ed.x = width - 1; search_window.ed.y = height - 1; int threshold_mid = 5000; int threshold_final = 6000; bool edge_detect = true; bool reverse_mode = true; int pitch_x = 0; int pitch_y = 0; int first_unit = 0; int last_unit = 0; int max_result_num = 10; result = F_GS_RESULT_PTR.alloc(max_result_num); int result_num = 0; status = fga.fnFGA_gs2_search_enforce( hfga_gs2, hfga_ptn, hfga_src, search_window, threshold_mid, threshold_final, edge_detect, reverse_mode, pitch_x, pitch_y, first_unit, last_unit, result, max_result_num, ref result_num ); if (status != (int)f_err.F_ERR_NONE) throw new FvException(status, "エラーが発生しました。"); Console.WriteLine("fnFGA_gs2_search_enforce"); for (int i = 0; i < result_num; i++) Console.WriteLine("result[{0}]=({1}, {2}, {3})", i, result[i].x, result[i].y, result[i].score); } finally { hfie_src.Dispose(); hfga_src.Dispose(); hfga_gs2.Dispose(); hfga_roi.Dispose(); hfga_msk.Dispose(); hfga_ptn.Dispose(); result.Dispose(); } } } } |
Exceptions
Exception | Condition |
---|---|
System.IO..::..FileNotFoundException |
実行環境に NVIDIA CUDA Runtime が存在しない場合、FGA ライブラリのロードが失敗し、この例外が発行されます。 必要な環境については FGA ライブラリ説明書 をご参照ください。 例外メッセージの例 (32bit 日本語 O/S の場合): DLL 'fgamt.x86.3.0.0.dll' を読み込めません: 指定されたモジュールが見つかりません。 (HRESULT からの例外: 0x8007007E) |