如何捕获图像GPUIMAGE 2

时间:2017-04-08 17:17:44

标签: ios swift gpuimage

我无法捕捉图像。 相机处于活动状态但未在单击按钮上保存图像

var rendeView = RenderView()
var filter = RGBAdjustment()

override func viewDidLoad() {
    rendeView = RenderView(frame: CGRect(x: 0, y: 179, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height - 179))

    do {
        var camera = try Camera(sessionPreset:AVCaptureSessionPreset640x480)
        filter.red = 0.0
        camera --> filter --> rendeView
        camera.startCapture()
        view.addSubview(rendeView)
    } catch {
        fatalError("Could not initialize rendering pipeline: \(error)")
    }
    view.bringSubview(toFront: takePhotobutton)
    view.bringSubview(toFront: testimview)
}


@IBAction func takeApicture(_ sender: UIButton)
{
  code?
}

如何捕获图像并显示ViewController?

1 个答案:

答案 0 :(得分:0)

@IBAction func takeApicture(_ sender: UIButton)
{
    let pictureOutput = PictureOutput()
    pictureOutput.encodedImageFormat = .JPEG
    pictureOutput.encodedImageAvailableCallback = {imageData in

        // Do something with the NSData
        //Convert this NSData to UIImage and place this image to your imageView to the next screen.

    }
    filter --> pictureOutput
}