質問編集履歴
2
具体的な質問の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,9 +40,9 @@
|
|
40
40
|
|
41
41
|
下記のコードだと、Windowsカメラが起動され、カメラのボタンをクリックすることでスクリーンショットをとる、という流れになります。
|
42
42
|
|
43
|
+
バックグラウンドでアプリを立ち上げておくことで、いちいちカメラが立ち上がってほかの作業を阻害しないようにしたいです。自分がそのアプリを意識せずに済むようにしたいです。
|
43
44
|
|
44
|
-
|
45
|
-
カメラを起動せずにWebカメラを使用して写真を撮る
|
45
|
+
カメラを起動せずにWebカメラを使用して写真を撮る方法はあるのでしょうか?
|
46
46
|
|
47
47
|
```
|
48
48
|
|
1
質問の具体化
test
CHANGED
File without changes
|
test
CHANGED
@@ -31,3 +31,69 @@
|
|
31
31
|
こちらはUWPで実現不可能でしょうか?
|
32
32
|
|
33
33
|
UWPで実現不可能ということはwin32を採用するべきでしょうか?
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
(追記)
|
38
|
+
|
39
|
+
質問を言語化できていませんでした。失礼いたしました。
|
40
|
+
|
41
|
+
下記のコードだと、Windowsカメラが起動され、カメラのボタンをクリックすることでスクリーンショットをとる、という流れになります。
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
カメラを起動せずにWebカメラを使用して写真を撮ることは不可能でしょうか?
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
private async void SimpleCapture(object sender, RoutedEventArgs e)
|
50
|
+
|
51
|
+
{
|
52
|
+
|
53
|
+
// キャプチャを初期化する
|
54
|
+
|
55
|
+
CameraCaptureUI capture = new CameraCaptureUI();
|
56
|
+
|
57
|
+
capture.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
|
58
|
+
|
59
|
+
capture.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
// 写真をキャプチャする
|
64
|
+
|
65
|
+
var file = await capture.CaptureFileAsync(CameraCaptureUIMode.Photo);
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
// ストリーム
|
70
|
+
|
71
|
+
IRandomAccessStream stream = await file.OpenReadAsync(); // IRandomAccessStreamとは?
|
72
|
+
|
73
|
+
byte[] buff = new byte[stream.Size];
|
74
|
+
|
75
|
+
DataReader reader = new DataReader(stream);
|
76
|
+
|
77
|
+
await reader.LoadAsync((uint)stream.Size);
|
78
|
+
|
79
|
+
reader.ReadBytes(buff);
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
// HTTPリクエスト処理
|
84
|
+
|
85
|
+
NetHttpClient client = new NetHttpClient();
|
86
|
+
|
87
|
+
Uri requestUri = new Uri("https://asia-northeast1-xxxxxxxxxx/xxxx");
|
88
|
+
|
89
|
+
var message = await client.PostAsync(requestUri, new ByteArrayContent(buff));
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
MessageDialog dialog = new MessageDialog(await message.Content.ReadAsStringAsync());
|
94
|
+
|
95
|
+
await dialog.ShowAsync();
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
```
|