原始数据从CVImageBuffer无渲染? [英] raw data from CVImageBuffer without rendering?

查看:290
本文介绍了原始数据从CVImageBuffer无渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从我的AVCaptureSession得到一个CVImageBufferRef,我想采取该图像缓冲区,并通过网络上传。为了节省空间和时间,我想这样做而不渲染图像到CIImage和NSBitmapImage,这是我见过的解决方案(如这里:
$ b如何获取原始数据? $ b

这是因为我的印象是CVImageBuffer可能是压缩的,这对我来说是真棒,如果我渲染它,我必须解压缩成一个完整的位图,然后上传整个位图。我想采取压缩数据(意识到一个单一的压缩帧可能是后来本身不可解释),就像它在CVImageBuffer。我认为这意味着我想要CVImageBuffer的基本数据指针及其长度,但它没有出现有一种方法来获得在API。任何人都有任何想法?

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



要告诉你使用 GetTypeID 方法:

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

if(imageType == CVPixelBufferGetTypeID()){
//像素数据
}
else if(imageType == CVOpenGLBufferGetTypeID()){
// OpenGL pbuffer
}
else if(imageType == CVOpenGLTextureGetTypeID()){
// OpenGL Texture
}
pre>

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?

解决方案

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
}

这篇关于原始数据从CVImageBuffer无渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆