相关疑难解决方法(0)

CVOpenGLESTextureCacheCreateTextureFromImage返回错误6683

我目前正在尝试使用YUV420格式(双平面)在openGL中绘制图像.我收到原始数据,并尝试将其解析为CVPixelBuffer,然后使用CVOpenGLESTextureCacheCreateTextureFromImage传递所述缓冲区.虽然在解析CVPixelBuffer时没有收到任何错误,但在尝试传递给CVOpenGLESTextureCacheCreateTextureFromImage时收到错误(-6683).我正在尽力遵循Apple的GLCameraRipple示例代码 - 除了我再次使用原始图像数据而不是相机中的数据.

希望有人可以解释我在这里失踪的是什么 - 我认为这是一个缺失的属性......

FYI,平面0是Y平面,平面1是UV平面 - 其中UV平面应该是Y平面的宽度和高度的一半.

size_t numPlanes = image->GetNumPlanes();
size_t planeWidth[numPlanes];
size_t planeHeight[numPlanes];
size_t scanWidth[numPlanes];
void *planeIndex[numPlanes];
for(int i = 0; i<numPlanes; i++){
    i<1 ? planeWidth[i] = image->GetWidth() : planeWidth[i] = image->GetWidth()/2;
    i<1 ? planeHeight[i] = image->GetHeight() : planeWidth[i] = image->GetHeight()/2;
    scanWidth[i] = image->GetScanWidth(i);
    planeIndex[i] = image->GetPlanePointer(i);
}

CVPixelBufferRef pixelBuffer;
CFDictionaryRef empty;
CFMutableDictionaryRef attrs;
empty = CFDictionaryCreate(kCFAllocatorDefault,
                           NULL,
                           NULL,
                           0,
                           &kCFTypeDictionaryKeyCallBacks,
                           &kCFTypeDictionaryValueCallBacks);

attrs = CFDictionaryCreateMutable(kCFAllocatorDefault,
                                  1,
                                  &kCFTypeDictionaryKeyCallBacks,
                                  &kCFTypeDictionaryValueCallBacks);

CFDictionarySetValue(attrs, kCVPixelBufferIOSurfacePropertiesKey, empty);



CVReturn cvError = CVPixelBufferCreateWithPlanarBytes(kCFAllocatorDefault,
                                                      image->GetWidth(), …
Run Code Online (Sandbox Code Playgroud)

yuv ios opengl-es-2.0

7
推荐指数
1
解决办法
6374
查看次数

如何从 YUV 转换为 iOS 的 CIImage

我正在尝试将 YUV 图像转换为 CIIMage 并最终转换为 UIImage。我在这些方面相当新手,并试图找出一种简单的方法来做到这一点。据我所知,从 iOS6 YUV 可以直接用于创建 CIImage 但当我试图创建它时,CIImage 只持有一个 nil 值。我的代码是这样的->

NSLog(@"Started DrawVideoFrame\n");

CVPixelBufferRef pixelBuffer = NULL;

CVReturn ret = CVPixelBufferCreateWithBytes(
                                            kCFAllocatorDefault, iWidth, iHeight, kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,
                                            lpData, bytesPerRow, 0, 0, 0, &pixelBuffer
                                            );

if(ret != kCVReturnSuccess)
{
    NSLog(@"CVPixelBufferRelease Failed");
    CVPixelBufferRelease(pixelBuffer);
}

NSDictionary *opt =  @{ (id)kCVPixelBufferPixelFormatTypeKey :
                      @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) };

CIImage *cimage = [CIImage imageWithCVPixelBuffer:pixelBuffer options:opt];
NSLog(@"CURRENT CIImage -> %p\n", cimage);

UIImage *image = [UIImage imageWithCIImage:cimage scale:1.0 orientation:UIImageOrientationUp];
NSLog(@"CURRENT UIImage -> %p\n", image);
Run Code Online (Sandbox Code Playgroud)

这里 lpData 是 YUV 数据,它是一个无符号字符数组。

这看起来也很有趣: …

image-processing yuv uiimage ios ciimage

4
推荐指数
1
解决办法
8711
查看次数

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

我收到YUV帧(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange),当从CVPixelBufferRef创建CIImage时,我得到:

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

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];
Run Code Online (Sandbox Code Playgroud)

core-image ios

0
推荐指数
1
解决办法
3481
查看次数