更新:我最后更新了我的代码。
好像我和this site有同样的问题,但在不同的情况下。所以我尝试在viewController.swift中使用来自GPUImage2框架的shiTomasiFeatureDetector过滤器,我在行camera --> blendFilter --> renderView
中得到了代码= 1 / code = 2的EXC_BAD_ACCESS。这是我的代码:
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中链接的错误
答案 0 :(得分:0)
我得到了答案! 您所要做的就是检查左侧的身份检查员(公用事业栏),检查班级和模块是否使用了“RenderView”。是否有类和GPUImage模块。