GPUImage Swift HelloWorld example

I am trying to set up a hello-world type GPUImage example in Swift. The code builds without errors, but I get a simple white screen without an image. Changing the background color of the GPUImageView to red in the storyboard changes the color on the device, but using the setBackgroundColorRed(...) method of the class has no effect.

Here are the steps I took to install:

  • Installed GPUImage with CocoaPods
  • Closed the project and reopened using .xcworkspace
  • Put #include "GPUImage.h" in the header of the bridge file
  • Drag and drop the generic UIView into the storyboard, add autolayout restrictions, change my class to GPUImageView and create an output in my ViewController class
  • Created GPUImagePicture from a photo in my application bundle
  • Added view as image target and image processed
 import UIKit class ViewController: UIViewController { let image = GPUImagePicture(image: UIImage(named: "cameraman.png")) @IBOutlet weak var imageView: GPUImageView! override func viewDidLoad() { super.viewDidLoad() self.image.addTarget(self.imageView) self.image.processImage() } } 

If I print an imageView or image , I get non-zero pointers, and imageView has a non-zero frame. Oddly enough, I used GPUImage in other projects without any problems and cannot think what I did differently this time - I'm sure this is something very small that I am missing, but I can’t show my finger on it. I downloaded the project here:

https://bitbucket.org/DVigneault/stack/downloads

Edit:

I am using Xcode 6.3 and iOS 8.3

Edit 2:

Same result after upgrading to Xcode 6.3.1

Edit 3:

If I add self.image.processImage() to viewDidAppear , I will get the desired result (i.e. an image will appear). It occurs to me that at any time when I used GPUImage in the past, I called processImage() at least once after the view has appeared. processImage() you always need to call processImage() after viewing?

+6
source share

Source: https://habr.com/ru/post/985841/


All Articles