WIL説明書(.NET)  3.1.0
FGA ライブラリを使用した例

この例では、FGA ライブラリを使用しています。
fnFGA プレフィックスの関数が FGA ライブラリの関数です。 これらの関数は fvalgcli.fga 配下に集約されています。

FGA インストーラは、WIL 本体のインストーラとは分離していますので、別途インストールする必要があります。
また、FGA ライブラリを使用するには "fvalgcli for FGA" を参照設定に追加する必要があります。


コード例:

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.Drawing;
5 using System.Windows.Forms;
6 using System.Reflection;
7 using fvalgcli;
8 
9 namespace User.SampleCode
10 {
11  partial class MyClass
12  {
16  public void Test3()
17  {
18  int status = 0;
19  FVIL.Data.CFviImage src = null;
20  FVIL.Data.CFviImage dst = null;
21  FHANDLE hfga_src = IntPtr.Zero;
22  FHANDLE hfga_dst1 = IntPtr.Zero;
23  FHANDLE hfga_dst2 = IntPtr.Zero;
24 
25  if (fga.fnFGA_is_setuped() == false) return;
26 
27  try
28  {
29  // 入力.
30  {
31  src = new FVIL.Data.CFviImage("Data/key_UC8_M.png");
32 
33  int type = api.fnFIE_img_get_type( src.GetFIE() );
34  int channels = api.fnFIE_img_get_channels( src.GetFIE() );
35  int width = api.fnFIE_img_get_width( src.GetFIE() );
36  int height = api.fnFIE_img_get_height( src.GetFIE() );
37 
38  // 生成.
39  hfga_src = fga.fnFGA_img_root_alloc( type, channels, width, height );
40 
41  // コピー.(FIE → FGA)
42  fga.fnFGA_img_copy( src.GetFIE(), hfga_src );
43  }
44 
45  // 処理.
46  {
47  int type = fga.fnFGA_img_get_type( hfga_src );
48  int channels = fga.fnFGA_img_get_channels( hfga_src );
49  int width = fga.fnFGA_img_get_width( hfga_src );
50  int height = fga.fnFGA_img_get_height( hfga_src );
51 
52  // 生成.
53  hfga_dst1 = fga.fnFGA_img_root_alloc( type, channels, width, height );
54  hfga_dst2 = fga.fnFGA_img_root_alloc( type, channels, width, height );
55 
56  // 平均化.
57  status = fga.fnFGA_average(hfga_src, hfga_dst1, f_border_mode.F_BORDER_CONTINUOUS, 0.0);
58  if (status != (int)f_err.F_ERR_NONE)
59  {
60  Console.WriteLine("fnFGA_average failed.({0})", (f_err)status);
61  throw new FvException((f_err)status);
62  }
63 
64  // ソーベル.
65  status = fga.fnFGA_sobel(hfga_dst1, hfga_dst2, f_sobel_mode.F_SOBEL_XY_MODE, f_border_mode.F_BORDER_CONTINUOUS, 0.0);
66  if (status != (int)f_err.F_ERR_NONE)
67  {
68  Console.WriteLine("fnFGA_sobel failed.({0})", (f_err)status);
69  throw new FvException((f_err)status);
70  }
71  }
72 
73  // 出力.
74  {
75  int type = fga.fnFGA_img_get_type(hfga_dst2);
76  int channels = fga.fnFGA_img_get_channels(hfga_dst2);
77  int width = fga.fnFGA_img_get_width(hfga_dst2);
78  int height = fga.fnFGA_img_get_height(hfga_dst2);
79 
80  // 生成.
81  FHANDLE hfie_dst = api.fnFIE_img_root_alloc( type, channels, width, height );
82 
83  // コピー.(FGA → FIE)
84  fga.fnFGA_img_copy( hfga_dst2, hfie_dst );
85 
86  // ファイル保存.
87  dst = new FVIL.Data.CFviImage(hfie_dst, false);
88  dst.Save("Result/Result3.png");
89  }
90  }
91  finally
92  {
93  // 解放.
94  if (src != null)
95  src.Dispose();
96  if (dst != null)
97  dst.Dispose();
98  hfga_src.Dispose();
99  hfga_dst1.Dispose();
100  hfga_dst2.Dispose();
101  }
102  }
103 
107  void main()
108  {
109  // 初期化.
110  int status = fga.fnFGA_setup();
111 
112  if (status == (int)f_err.F_ERR_NONE)
113  {
114  Test3();
115  }
116 
117  // 解放.
118  fga.fnFGA_teardown();
119  }
120  }
121 }

※注)
FGA ライブラリの初期化は暗黙的には行われませんので、 上記のようにアプリケーションのエントリポイント等で初期化関数を呼び出す必要があります。


Documentation copyright © 2008 FAST Corporation. [B-001864]
Generated on 2024年10月10日(木) 10時07分53秒 for WIL説明書(.NET) by doxygen 1.8.11