【发布时间】:2014-03-21 23:44:51
【问题描述】:
我创建了一个简单的 Xamarin MonoMac Mac 应用程序(裸机 1 个窗口)。我正在尝试在应用程序的主窗口上预览我的网络摄像头。我使用 AVFoundation 类来访问网络摄像头。
我可以成功连接到 mac 的网络摄像头,并且网络摄像头灯亮,但我在主窗口中没有看到视频。
我的 C# 代码
session = new AVCaptureSession () { SessionPreset = AVCaptureSession.PresetMedium };
var captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video);
var input = AVCaptureDeviceInput.FromDevice (captureDevice);
if (input == null){
Console.WriteLine ("No input - this won't work on the simulator, try a physical device");
}
session.AddInput (input);
AVCaptureVideoPreviewLayer captureVideoPreviewLayer = new AVCaptureVideoPreviewLayer (session);
**//----> preview layer onto Window here ?!**
session.StartRunning ();
【问题讨论】:
-
您必须告诉相机设备在哪里流式传输图像。 captureVideoPreviewLayer .Frame = this.Frame;