gpt4 book ai didi

ios - CoreImage 坐标系

转载 作者:可可西里 更新时间:2023-11-01 05:43:54 30 4
gpt4 key购买 nike

我有来自 AVAssetCVPixelBufferRef。我正在尝试对其应用 CIFilter。我使用这些行:

CVPixelBufferRef pixelBuffer = ...
CVPixelBufferRef newPixelBuffer = // empty pixel buffer to fill
CIContex *context = // CIContext created from EAGLContext
CGAffineTransform preferredTransform = // AVAsset track preferred transform
CIImage *phase1 = [CIImage imageWithCVPixelBuffer:pixelBuffer];
CIImage *phase2 = [phase1 imageByApplyingTransform:preferredTransform];
CIImage *phase3 = [self applyFiltersToImage:phase2];

[context render:phase3 toCVPixelBuffer:newPixelBuffer bounds:phase3.extent colorSpace:CGColorSpaceCreateDeviceRGB()];

不幸的是,我得到的结果方向不正确。例如,在纵向模式下拍摄的视频是颠倒的。我猜问题出在从 AVAssetCoreImage 坐标系(在 XCode 中显示 phase2 的预览也显示不正确的结果)。如何解决?

最佳答案

我通过这样做解决了它,它应该将所有内容正确定位到坐标空间

var preferredTransform = inst.preferredTransform
preferredTransform.b *= -1
preferredTransform.c *= -1

var outputImage = CIImage(cvPixelBuffer: videoFrameBuffer)
.applying(preferredTransform)
outputImage = outputImage.applying(CGAffineTransform(translationX: -outputImage.extent.origin.x, y: -outputImage.extent.origin.y))

关于ios - CoreImage 坐标系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29967700/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com