ios - imageAvailableCallback 从未在基本 GPUImage2 相机设置中调用
<p><p>我已按照 GPUImage2 的 github 上的基本设置说明操作 <a href="https://github.com/BradLarson/GPUImage2#filtering-live-video" rel="noreferrer noopener nofollow">filtering live video</a>和 <a href="https://github.com/BradLarson/GPUImage2#capturing-an-image-from-video" rel="noreferrer noopener nofollow">capturing an image from video</a>就这样我可以设置一个基本的相机。当用户点击一个按钮时,我尝试使用以下代码从过滤器中捕获图像:</p>
<pre><code> let pictureOutput = PictureOutput()
pictureOutput.encodedImageFormat = .JPEG
pictureOutput.imageAvailableCallback = {image in
// Do something with the image
self.previewImageView.image = image
}
self.filter! --> pictureOutput
</code></pre>
<p>无论出于何种原因,永远不会调用 imageAvailableCallback,我无法从相机中获取图像。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><code>--></code> 调用 <code>addTarget</code> 和 <code>addTarget</code> 附加到附加弱引用的目标 (<code>TargetContainer</code>) .所以你应该确保目标在回调时可用。例如,只需将 pictureOutput 变量放在类的顶部。</p></p>
<p style="font-size: 20px;">关于ios - imageAvailableCallback 从未在基本 GPUImage2 相机设置中调用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37687753/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37687753/
</a>
</p>
页:
[1]