WIL説明書(.NET)  3.1.0
デバイスコントローラを使用した例 (その1)

この例では、ビデオ入力クラスから画像を一枚取り込み、画像統計量を計測し、判定結果をデジタル入出力デバイスで外部に出力しています。

コード例:

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 Test4()
17  {
18  FVIL.Video.CFviVideoRICE001 video = null;
19  FVIL.Dio.CFviDioFIO01 dio = null;
20  FVIL.Data.CFviImage src = null;
21 
22  try
23  {
24  // 準備.
25  video = new FVIL.Video.CFviVideoRICE001();
26  video.Open(-1, 0);
27  video.LoadIniFile(@"C:\FAST\WIL\3.0.0\CameraFiles\RICE-001\rice_640.ini");
28 
29  dio = new FVIL.Dio.CFviDioFIO01();
30  dio.Open(-1);
31 
32  const uint DO_SUCCESS = 0x01;
33  const uint DO_FAILURE = 0x02;
34 
35  // 入力.
36  src = new FVIL.Data.CFviImage();
37  video.ChangeImageSize(src);
38  video.GrabImageSync(src);
39 
40  // 処理.
41  FVIL.Measure.CFviStatistics parser = new FVIL.Measure.CFviStatistics(src);
42  parser.Execute();
43 
44  // 出力.
45  if (32 <= parser.Average && parser.Average <= 200)
46  {
47  dio.DO = DO_SUCCESS;
48  }
49  else
50  {
51  dio.DO = DO_FAILURE;
52  }
53  }
54  finally
55  {
56  // 解放.
57  if (video != null)
58  video.Close();
59  if (dio != null)
60  dio.Close();
61  if (src != null)
62  src.Dispose();
63  }
64  }
65  }
66 }

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