Skip to content

Instantly share code, notes, and snippets.

@kmsquire
Forked from SimonDanisch/webcam.jl
Last active August 29, 2015 14:06
Show Gist options
  • Save kmsquire/f54c36896a25ce7aeb09 to your computer and use it in GitHub Desktop.
Save kmsquire/f54c36896a25ce7aeb09 to your computer and use it in GitHub Desktop.
import VideoIO
using GLPlot, Reactive, GLAbstraction
camera = VideoIO.opencamera()
img = VideoIO.read(camera)
# Just for fun, lets apply a laplace filter:
kernel = [-1 -1 -1;
-1 8 -1;
-1 -1 -1]
#async=true, for REPL use. Then you don't have to call renderloop(window)
window = createdisplay(#=async=true =#)
glimg = glplot(Texture(img, 3), kernel=kernel, filternorm=0.1f0)
#Get Gpu memory object
glimg2 = glimg.uniforms[:image]
#Asynchronous updating with React:
lift(fpswhen(window.inputs[:open], 30.0)) do x
VideoIO.read!(camera, img)
update!(glimg2, mapslices(reverse, img, 3)) # needs to be mirrored :(
end
renderloop(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment