来自 CVImageBuffer 的原始数据无需渲染?
我从 AVCaptureSession 获取 CVImageBufferRef,我想获取该图像缓冲区并通过网络上传。为了节省空间和时间,我想在不将图像渲染为 CIImage 和 NSBitmapImage 的情况下执行此操作,这是我随处可见的解决方案(如下所示: 如何从 CVImageBuffer 对象获取原始数据)。
这是因为我的印象是 CVImageBuffer 可能会被压缩,这对我来说很棒,如果我渲染它,我必须将其解压缩为完整的位图,然后上传整个位图。我想获取压缩数据(意识到单个压缩帧稍后可能无法单独渲染),就像它位于 CVImageBuffer 中一样。我认为这意味着我想要 CVImageBuffer 的基本数据指针及其长度,但似乎没有办法在 API 中获取它。有人有什么想法吗?
I'm getting a CVImageBufferRef from my AVCaptureSession, and I'd like to take that image buffer and upload it over the network. To save space and time, I would like to do this without rendering the image into a CIImage and NSBitmapImage, which is the solution I've seen everywhere (like here: How can I obtain raw data from a CVImageBuffer object).
This is because my impression is that the CVImageBuffer might be compressed, which is awesome for me, and if I render it, I have to uncompress it into a full bitmap and then upload the whole bitmap. I would like to take the compressed data (realizing that a single compressed frame might be unrenderable later by itself) just as it sits within the CVImageBuffer. I think this means I want the CVImageBuffer's base data pointer and its length, but it doesn't appear there's a way to get that within the API. Anybody have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CVImageBuffer 本身是一个抽象类型。您的图像应该是 CVPixelBuffer、CVOpenGLBuffer 或 CVOpenGLTexture 的实例。这些类型的文档列出了可用于访问数据的函数。
要了解您的类型,请使用
GetTypeID
方法:CVImageBuffer itself is an abstract type. Your image should be an instance of either CVPixelBuffer, CVOpenGLBuffer, or CVOpenGLTexture. The documentation for those types lists the functions you can use for accessing the data.
To tell which type you have use the
GetTypeID
methods: