gpt4 book ai didi

ios - 在 GPUImage2 中尝试 shiTomasiFeatureDetector 过滤器时 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-11-30 12:05:32 26 4
gpt4 key购买 nike

更新:我最后更新了我的代码。

似乎我对this site有同样的问题但在不同的情况下。因此,我尝试在 viewController.swift 中使用 GPUImage2 框架中的 shiTomasiFeatureDetector 过滤器,并在 camera --> BlendFilter --> renderView 行中得到了 EXC_BAD_ACCESS,代码=1/code=2。这是我的代码:

import UIKit
import CoreImage
import GPUImage
import AVFoundation
import QuartzCore

class ViewController: UIViewController {

@IBOutlet var filterView: RenderView?
var videoCamera: Camera?

required init(coder aDecoder: NSCoder) {
do {
videoCamera = try Camera(sessionPreset: AVCaptureSessionPreset640x480, location: .backFacing)
videoCamera!.runBenchmark = true
} catch {
videoCamera = nil
print("Couldn't initialize camera with error: \(error)")
}
super.init(coder: aDecoder)!
}

// declare filters and crosshairs
var shiTomasiFilter = ShiTomasiFeatureDetector()
lazy var crosshairGenerator: CrosshairGenerator = {
let generator = CrosshairGenerator(size:Size(width:480, height:640))
generator.crosshairWidth = 15.0
return generator
}()
let blendFilter = AlphaBlend()


override func viewDidLoad() {
super.viewDidLoad()

// re-declare camera using guard-statement
guard let videoCamera = videoCamera else {
let errorAlertController = UIAlertController(title: NSLocalizedString("Error", comment: "Error"), message: "Couldn't initialize camera", preferredStyle: .alert)
errorAlertController.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "OK"), style: .default, handler: nil))
self.present(errorAlertController, animated: true, completion: nil)
return
}

if let view = self.filterView {
// gettin' corners
shiTomasiFilter.cornersDetectedCallback = {
corners in self.crosshairGenerator.renderCrosshairs(corners)
}
shiTomasiFilter.threshold = 0.1

videoCamera --> shiTomasiFilter
crosshairGenerator --> blendFilter

videoCamera --> blendFilter --> view

videoCamera.startCapture()
}

}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}


}

我可以对这件事有什么建议吗?

错误链接: error link

Pipeline.swift 中链接的错误

最佳答案

我得到了答案!您所要做的就是检查左侧的身份检查器(实用程序栏),检查类和模块是否使用“RenderView”类和 GPUImage 模块。

关于ios - 在 GPUImage2 中尝试 shiTomasiFeatureDetector 过滤器时 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46719253/

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