グレイサーチの実行
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_gs2_search( 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, f_gs2_mode search_mode, int search_type, F_GS_RESULT_PTR result, int max_result_num, ref int result_num ) |
Visual Basic |
---|
Public Shared Function fnFIE_gs2_search ( 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, search_mode As f_gs2_mode, search_type 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を入力した場合、パターンサイズの半分になります。
- search_mode
- Type: fvalgcli..::..f_gs2_mode
サーチ精度を指定します。- F_GS2_NORMAL_MODE 通常精度
- F_GS2_HIGH_MODE 高精度
- F_GS2_SUPER_MODE 超高精度
- F_GS2_ULTRA_SUPER_MODE ウルトラ超高精度
- search_type
- Type: System..::..Int32
サーチ複雑度を指定します。( 1 〜 9 )
- 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 | 引数オブジェクトの種別が異常,引数オブジェクトが IntPtr.Zero |
F_ERR_NOMEMORY | メモリ不足 |
F_ERR_INVALID_IMAGE | 対応していない画像が渡された |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Remarks
Examples
C# | Copy |
---|---|
// $Revision: 1.1 $ using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace TC { public partial class FIE { [FvPluginExecute] public void fnFIE_gs2_search() { int status = (int)f_err.F_ERR_NONE; FHANDLE hgs = FHANDLE.Zero; FHANDLE hSrc = FHANDLE.Zero; FHANDLE hPtn = FHANDLE.Zero; FHANDLE hMask = FHANDLE.Zero; FHANDLE hPattern = FHANDLE.Zero; F_GS_RESULT_PTR result = IntPtr.Zero; try { // サーチ対象画像の読み込み. status = api.fnFIE_load_img_file(TestImageDir + "/TC/SampleCode/key_UC8_M.png", ref hSrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8); if (status != (int)f_err.F_ERR_NONE) Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "画像を開くときにエラーが発生しました。({0})", (f_err)status); // グレイサーチオブジェクトの生成. uint first_buff_size = 0; uint last_buff_size = 0; uint cache_pow_num = 0; hgs = api.fnFIE_gs2_alloc(first_buff_size, last_buff_size, cache_pow_num); Assert.IsTrue(hgs != FHANDLE.Zero, "fnFIE_gs2_alloc: エラーが発生しました。({0})", hgs); // グレイサーチパターンオブジェクト作成. hPtn = api.fnFIE_img_child_alloc(hSrc, 50, 0, 80, 80); int mark_offsetx = 10; int mark_offsety = 10; hPattern = api.fnFIE_gs2_pattern_alloc(hPtn, hMask, mark_offsetx, mark_offsety, f_comp_filter.F_COMP_MODE_SMOOTH, ref status); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_gs2_pattern_alloc: エラーが発生しました。({0})", (f_err)status); // グレイサーチ実行. BOX_T search_window = new BOX_T(); search_window.st.x = 0; search_window.st.y = 0; search_window.ed.x = api.fnFIE_img_get_width(hSrc) - 1; search_window.ed.y = api.fnFIE_img_get_height(hSrc) - 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; f_gs2_mode search_mode = f_gs2_mode.F_GS2_HIGH_MODE; int search_type = 1; int max_result_num = 10; result = F_GS_RESULT_PTR.alloc(max_result_num); int result_num = 0; status = api.fnFIE_gs2_search( hgs, hPattern, hSrc, search_window, threshold_mid, threshold_final, edge_detect, reverse_mode, pitch_x, pitch_y, search_mode, search_type, result, max_result_num, ref result_num ); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_gs2_search: エラーが発生しました。({0})", (f_err)status); Console.WriteLine("fnFIE_gs2_search"); 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 { hgs.Dispose(); hSrc.Dispose(); hPtn.Dispose(); hMask.Dispose(); hPattern.Dispose(); result.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE <FvPluginExecute> _ Public Sub fnFIE_gs2_search() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim hgs As FHANDLE = FHANDLE.Zero Dim hSrc As FHANDLE = FHANDLE.Zero Dim hPtn As FHANDLE = FHANDLE.Zero Dim hMask As FHANDLE = FHANDLE.Zero Dim hPattern As FHANDLE = FHANDLE.Zero Dim result As F_GS_RESULT_PTR = IntPtr.Zero Try ' サーチ対象画像の読み込み. status = api.fnFIE_load_img_file(TestImageDir & "/TC/SampleCode/key_UC8_M.png", hSrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8) If status <> CInt(f_err.F_ERR_NONE) Then Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "画像を開くときにエラーが発生しました。({0})", CType(status, f_err)) End If ' グレイサーチオブジェクトの生成. Dim first_buff_size As UInteger = 0 Dim last_buff_size As UInteger = 0 Dim cache_pow_num As UInteger = 0 hgs = api.fnFIE_gs2_alloc(first_buff_size, last_buff_size, cache_pow_num) Assert.IsTrue(hgs <> FHANDLE.Zero, "fnFIE_gs2_alloc: エラーが発生しました。({0})", hgs) ' グレイサーチパターンオブジェクト作成. hPtn = api.fnFIE_img_child_alloc(hSrc, 50, 0, 80, 80) Dim mark_offsetx As Integer = 10 Dim mark_offsety As Integer = 10 hPattern = api.fnFIE_gs2_pattern_alloc(hPtn, hMask, mark_offsetx, mark_offsety, f_comp_filter.F_COMP_MODE_SMOOTH, status) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_gs2_pattern_alloc: エラーが発生しました。({0})", CType(status, f_err)) ' グレイサーチ実行. Dim search_window As New BOX_T() search_window.st.x = 0 search_window.st.y = 0 search_window.ed.x = api.fnFIE_img_get_width(hSrc) - 1 search_window.ed.y = api.fnFIE_img_get_height(hSrc) - 1 Dim threshold_mid As Integer = 5000 Dim threshold_final As Integer = 6000 Dim edge_detect As Boolean = True Dim reverse_mode As Boolean = True Dim pitch_x As Integer = 0 Dim pitch_y As Integer = 0 Dim search_mode As f_gs2_mode = f_gs2_mode.F_GS2_HIGH_MODE Dim search_type As Integer = 1 Dim max_result_num As Integer = 10 result = F_GS_RESULT_PTR.alloc(max_result_num) Dim result_num As Integer = 0 status = api.fnFIE_gs2_search(hgs, hPattern, hSrc, search_window, threshold_mid, threshold_final, _ edge_detect, reverse_mode, pitch_x, pitch_y, search_mode, search_type, _ result, max_result_num, result_num) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_gs2_search: エラーが発生しました。({0})", CType(status, f_err)) Console.WriteLine("fnFIE_gs2_search") For i As Integer = 0 To result_num - 1 Console.WriteLine("result[{0}]=({1}, {2}, {3})", i, result(i).x, result(i).y, result(i).score) Next Finally hgs.Dispose() hSrc.Dispose() hPtn.Dispose() hMask.Dispose() hPattern.Dispose() result.Dispose() End Try End Sub End Class |