raw data from CVImageBuffer without rendering?

后端 未结 1 986
生来不讨喜
生来不讨喜 2021-01-13 10:27

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

1条回答
  •  有刺的猬
    2021-01-13 11:13

    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
    }
    

    0 讨论(0)
提交回复
热议问题