gpt4 book ai didi

ios - 来自 gpuimage lib 的 imageFromCurrentFramebuffer 保存黑帧

转载 作者:行者123 更新时间:2023-11-28 05:32:36 24 4
gpt4 key购买 nike

我正在应用过滤器列表来检测相机捕获过程中的形状。检测到形状后 - 想将其保存到照片中以供查看。 Google 搜索 imageFromCurrentFramebuffer,但总是保存黑色图片。

// camera init
var videoCamera = GPUImageVideoCamera(sessionPreset: AVCaptureSessionPreset1920x1080, cameraPosition: .Back)
videoCamera!.outputImageOrientation = .Portrait;
videoCamera?.startCameraCapture()

// filter init
var houghTransformFilter = GPUImageHoughTransformLineDetector()
houghTransformFilter!.lineDetectionThreshold = 0.3
houghTransformFilter!.useNextFrameForImageCapture() //without this crashes
houghTransformFilter!.linesDetectedBlock = {
// my custom shape detection logic
if (found) {
self.videoCamera?.pauseCameraCapture()
var capturedImage:UIImage? = self.houghTransformFilter!.imageFromCurrentFramebuffer()
UIImageWriteToSavedPhotosAlbum(capturedImage, nil, nil, nil);
}

}

最佳答案

我遇到了类似的问题。您可能需要在抓取框架的调用之前添加此行:

self.houghTransformFilter?.useNextFrameForImageCapture()

关于ios - 来自 gpuimage lib 的 imageFromCurrentFramebuffer 保存黑帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27151644/

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