Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
initWithCVPixelBuffer失败,因为CVPixelBufferRef不是非IOSurface支持的_Ios_Core Image - Fatal编程技术网

initWithCVPixelBuffer失败,因为CVPixelBufferRef不是非IOSurface支持的

initWithCVPixelBuffer失败,因为CVPixelBufferRef不是非IOSurface支持的,ios,core-image,Ios,Core Image,我收到YUV帧(kCVPixelFormatTypeƤYPCBCRC8BIPLANARVIDEORAGE),从CVPixelBufferRef创建CIImage时,我得到: initWithCVPixelBuffer失败,因为CVPixelBufferRef不是非IOSurface支持的 我假设问题是:“为什么我会出现这个错误?” 要使CVPixelBuffer IOSurface成为backed,需要在创建CVPixelBuffer时设置其属性。现在您正在传入“0”,作为CVPixelBuff

我收到YUV帧(kCVPixelFormatTypeƤYPCBCRC8BIPLANARVIDEORAGE),从CVPixelBufferRef创建CIImage时,我得到:

initWithCVPixelBuffer失败,因为CVPixelBufferRef不是非IOSurface支持的


我假设问题是:“为什么我会出现这个错误?”

要使CVPixelBuffer IOSurface成为backed,需要在创建CVPixelBuffer时设置其属性。现在您正在传入“0”,作为CVPixelBufferCreateWithBytes中倒数第二个参数

在CvPixelBufferioSurfacePropertiesKey和CvPixelBufferioSurfacePropertiesKey中传递一个字典,该字典的键是CvPixelBufferioSurfacePropertiesKey,值是CvPixelBufferioSurfacePropertiesKey中的空字典(要使用默认的IOSurface选项,其他选项没有文档记录),将正确的字节复制到已创建的CVPixelBuffer中(不要忘记字节对齐)。这就是如何使其成为IOSurface backed

虽然我不确定它是否会因为像素格式而为您消除所有错误。但我的理解是,GPU必须能够以该像素格式保存纹理,才能用作iSurface,尽管我不是100%确定


注意:可以在中找到KCVPIXELFORMATTYPE420YPCBCRC8BIPLANARVIDEORAGE的正确复制像素字节。

我假设问题是:“为什么会出现此错误?”

要使CVPixelBuffer IOSurface成为backed,您需要在创建CVPixelBuffer时设置CVPixelBuffer的属性。现在,您正在传递“0”作为CVPixelBufferCreateWithBytes中倒数第二个参数

在CvPixelBufferioSurfacePropertiesKey和CvPixelBufferioSurfacePropertiesKey中传递一个字典,该字典的键是CvPixelBufferioSurfacePropertiesKey,值是CvPixelBufferioSurfacePropertiesKey中的空字典(要使用默认的IOSurface选项,其他选项没有文档记录),将正确的字节复制到已创建的CVPixelBuffer中(不要忘记字节对齐)。这就是如何使其成为IOSurface backed

虽然我不确定它是否会因为像素格式而为您消除所有错误。但我的理解是,GPU必须能够以该像素格式保存纹理,才能用作iSurface,尽管我不是100%确定


注意:可以在中找到KCVPIXELFORMATTYPE420YPCBCRC8BIPLANARVIDEORAGE的正确复制像素字节。

您能找到这个问题吗?您能找到这个问题吗?
CVPixelBufferRef pixelBuffer;

size_t planeWidth[] = { width, width / 2 };
size_t planeHeight[] = { height, height / 2};
size_t planeBytesPerRow[] = { width, width / 2 };

CVReturn ret = CVPixelBufferCreateWithBytes(
kCFAllocatorDefault, width, height, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
data, bytesPerRow, 0, 0, 0, &pixelBuffer
);

if (ret != kCVReturnSuccess)
{
    NSLog(@"FAILED");

    CVPixelBufferRelease(pixelBuffer);

    return;
}

CVPixelBufferLockBaseAddress(pixelBuffer, 0);

// fails
CIImage * image = [[CIImage alloc] initWithCVPixelBuffer:pixelBuffer];

CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);

CVPixelBufferRelease(pixelBuffer);

[image release];