imageAvailableCallback never called in basic GPUImage2 camera setup

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 23:35:00

问题


I have followed the basic setup instructions on GPUImage2's github for filtering live video and capturing an image from video just so I can setup a basic camera. When the user taps a button, I try to capture the image from the filter using this code specifically:

    let pictureOutput = PictureOutput()
    pictureOutput.encodedImageFormat = .JPEG
    pictureOutput.imageAvailableCallback = {image in
        // Do something with the image
        self.previewImageView.image = image
    }
    self.filter! --> pictureOutput

For whatever reason, the imageAvailableCallback is never called and I am unable to get the image from the camera.


回答1:


The --> calls addTarget and addTarget appends to targets (TargetContainer) which appends a weak reference. So you should make sure the target will be available on callback. For example just place the pictureOutput variable at the top of your class.



来源:https://stackoverflow.com/questions/37687753/imageavailablecallback-never-called-in-basic-gpuimage2-camera-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!