In [1]:
//!apt-get install freeglut3-dev
//!apt-get install mesa-common-dev
%install-location $cwd/swift-install
%install '.package(path: "$cwd/../../")' GPUImage
//%install '.package(url: "https://github.com/BradLarson/GPUImage2", from: "0.0.1")' GPUImage
In [2]:
import GPUImage
import Foundation
In [3]:
import Python
%include "EnableIPythonDisplay.swift"
let pythonDisplay = Python.import("IPython.display")
The OpenGL context is owned by GLUT, so you have to create a blank offscreen render window for now.
In [4]:
let renderWindow = GLUTRenderWindow()
In [5]:
let pictureInput = PictureInput(path: "../SharedAssets/Lambeau.jpg")!
pythonDisplay.Image(filename: "../SharedAssets/Lambeau.jpg", width: 640, height: 480).display()
In [6]:
let edgeDetection = SobelEdgeDetection()
let pictureOutput = PictureOutput()
In [7]:
pictureInput.removeAllTargets()
edgeDetection.removeAllTargets()
pictureInput --> edgeDetection --> pictureOutput
pictureOutput.saveNextFrameToPath("./test.png", format:.png)
pictureInput.processImage(synchronously: true)
In [8]:
pythonDisplay.Image(filename:"./test.png", width: 640, height: 480).display()
In [ ]: