【发布时间】:2017-12-04 02:15:21
【问题描述】:
不知道我做错了什么,我想创建一个简单的自定义相机,我正在创建 AVCapturePhotoOutput 并将其附加到 AVCaptureSession,然后使用最低设置创建 AVCapturePhotoSettings 以使拍照工作,请参见下面的代码。
我得到异常 kCVPixelBufferPixelFormatTypeKey 没有被定义,但它确实在我传递的 NSDictionary 中。
这里需要点灯,谢谢
public void TakePicture()
{
var output = new AVCapturePhotoOutput();
_captureSession.AddOutput(output);
var settings = AVCapturePhotoSettings.Create();
var previewPixelType = settings.AvailablePreviewPhotoPixelFormatTypes.First();
var keys = new[]
{
new NSString("kCVPixelBufferPixelFormatTypeKey"),
new NSString("kCVPixelBufferWidthKey"),
new NSString("kCVPixelBufferHeightKey"),
};
var objects = new NSObject[]
{
// don't have to be strings... can be any NSObject.
previewPixelType,
new NSString("160"),
new NSString("160")
};
var dicionary = new NSDictionary<NSString, NSObject>(keys, objects);
settings.PreviewPhotoFormat = dicionary;
output.CapturePhoto(settings,this);
}
【问题讨论】:
-
我通过传递解决了这个问题: settings.PreviewPhotoFormat = new NSDictionary
(CVPixelBuffer.PixelFormatTypeKey, settings.AvailablePreviewPhotoPixelFormatTypes[0]);但不确定为什么第一次尝试没有成功
标签: xamarin xamarin.ios ios-camera