Objective c 如何从CVImageBufferRef进行缩放——或者——为什么不';设置像素是否有效?

Objective c 如何从CVImageBufferRef进行缩放——或者——为什么不';设置像素是否有效?,objective-c,cocoa,core-graphics,nsimage,quartz-core,Objective C,Cocoa,Core Graphics,Nsimage,Quartz Core,我正在通过QTCaptureDecompressedDVideOutput从相机(MacBookAir,OSX 10.9.5)捕获视频并对其进行处理,但我需要缩放传入的图像。无论出于何种原因,在设置像素缓冲区属性时,传回给我的图像不是我要求的大小: [mVideoOutput setPixelBufferAttributes: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWit

我正在通过
QTCaptureDecompressedDVideOutput
从相机(MacBookAir,OSX 10.9.5)捕获视频并对其进行处理,但我需要缩放传入的图像。无论出于何种原因,在设置像素缓冲区属性时,传回给我的图像不是我要求的大小:

   [mVideoOutput setPixelBufferAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
            [NSNumber numberWithDouble:width], (id)kCVPixelBufferWidthKey,
            [NSNumber numberWithDouble:height], (id)kCVPixelBufferHeightKey,
            [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32ARGB], (id)kCVPixelBufferPixelFormatTypeKey,
            nil]];
我得到的图像是我要求的两倍大

将图像缩放到一半的最有效方法是什么?

或者更好


为什么setPixelBufferAttributes不能正常工作?

第一次请求时似乎忽略了
setPixelBufferAttributes
,因此在从相机接收图像的回调中,我检查大小,如果不正确,再次发出请求。这似乎解决了这个问题