我在Swift中有此代码,并得到一个错误:CVImageBuffer不能转换为非托管
func getTextureFromSampleBuffer(sampleBuffer: CMSampleBuffer!) -> GLuint {
cleanupVideoTextures()
var unmanagedImageBuffer: Unmanaged<CVImageBuffer> = CMSampleBufferGetImageBuffer(sampleBuffer) // Here get the error
var imageBuffer = unmanagedImageBuffer.takeUnretainedValue()
var opaqueImageBuffer = unmanagedImageBuffer.toOpaque()
我怎么能投这个?
谢谢!
最佳答案
CMSampleBufferGetImageBuffer()
不接受非托管对象(不再?–也许这改变了
在测试版之间)。你可以替换
var unmanagedImageBuffer: Unmanaged<CVImageBuffer> = CMSampleBufferGetImageBuffer(sampleBuffer) // Here get the error
var imageBuffer = unmanagedImageBuffer.takeUnretainedValue()
简单地
var imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
关于swift - 如何将CVImageBuffer转换为Unmanaged <CVImageBuffer>?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25633669/