来自 CVImageBuffer 的原始数据无需渲染?

发布于 2024-10-31 19:03:55 字数 476 浏览 1 评论 0原文

我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夢归不見 2024-11-07 19:03:55

CVImageBuffer 本身是一个抽象类型。您的图像应该是 CVPixelBuffer、CVOpenGLBuffer 或 CVOpenGLTexture 的实例。这些类型的文档列出了可用于访问数据的函数。

要了解您的类型,请使用 GetTypeID 方法:

CVImageBufferRef image = …;
CFTypeID imageType = CFGetTypeID(image);

if (imageType == CVPixelBufferGetTypeID()) {
  // Pixel Data
}
else if (imageType == CVOpenGLBufferGetTypeID()) {
  // OpenGL pbuffer
}
else if (imageType == CVOpenGLTextureGetTypeID()) {
  // OpenGL Texture
}

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:

CVImageBufferRef image = …;
CFTypeID imageType = CFGetTypeID(image);

if (imageType == CVPixelBufferGetTypeID()) {
  // Pixel Data
}
else if (imageType == CVOpenGLBufferGetTypeID()) {
  // OpenGL pbuffer
}
else if (imageType == CVOpenGLTextureGetTypeID()) {
  // OpenGL Texture
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文