回答編集履歴

1

追記

2018/10/25 03:07

投稿

YAmaGNZ
YAmaGNZ

スコア10251

test CHANGED
@@ -19,3 +19,67 @@
19
19
  IAMCameraControl cameraControl = capFilter as IAMCameraControl;
20
20
 
21
21
  ```
22
+
23
+
24
+
25
+ 追記
26
+
27
+ 内カメラがついたノートPCで試したところ
28
+
29
+ 質問者さんが提示されているコード
30
+
31
+ ```C#
32
+
33
+ IAMCameraControl cameraControl = devs[0] as IAMCameraControl;
34
+
35
+ ```
36
+
37
+ では、cameraControlがnullとなっていました。
38
+
39
+ 下記コードでは、「指定されたプロパティ ID は、指定されたプロパティ設定用にサポートされていません。」とエラーとなりましたのでFocusの調整をサポートしていないカメラだと思われます。
40
+
41
+ ```C#
42
+
43
+ DsDevice[] devs = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
44
+
45
+ IFilterGraph2 graphBuilder = (IFilterGraph2)(new FilterGraph());
46
+
47
+ IBaseFilter capFilter = null;
48
+
49
+ int hr = graphBuilder.AddSourceFilterForMoniker(devs[0].Mon, null, devs[0].Name, out capFilter);
50
+
51
+ IAMCameraControl CamControl = capFilter as IAMCameraControl;
52
+
53
+
54
+
55
+ try
56
+
57
+ {
58
+
59
+ int min = 0;
60
+
61
+ int max = 0;
62
+
63
+ int step = 0;
64
+
65
+ int def = 0;
66
+
67
+ CameraControlFlags flag = CameraControlFlags.None;
68
+
69
+
70
+
71
+ hr = CamControl.GetRange(CameraControlProperty.Focus, out min, out max, out step, out def, out flag);
72
+
73
+ DsError.ThrowExceptionForHR(hr);
74
+
75
+ }
76
+
77
+ catch (Exception ex)
78
+
79
+ {
80
+
81
+ Console.Write(ex.Message);
82
+
83
+ }
84
+
85
+ ```