我目前正在尝试获取CVVideoPixelBuffer的baseAddress,但即使我能够看到CVVideoPixelBuffer本身不是nil,它仍然保持返回nil。
let baseAddress = CVPixelBufferGetBaseAddressOfPlane(cvPixelBuffer, 0) // -> nil =(
答案 0 :(得分:0)
我发现原因是因为我试图从CPU访问pixelBuffer,因此需要将CVPixelBuffer的地址锁定到内存中的特定地址。
CVPixelBufferLockBaseAddress(cvPixelBuffer, CVPixelBufferLockFlags.readOnly)
let baseAddress = CVPixelBufferGetBaseAddressOfPlane(cvPixelBuffer, 0)
CVPixelBufferUnlockBaseAddress(cvPixelBuffer, CVPixelBufferLockFlags.readOnly)
这有效!