Created
September 11, 2014 19:19
-
-
Save SimonDanisch/fa3993176a015215092c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import VideoIO | |
using GLPlot, React, GLAbstraction | |
device = VideoIO.DEFAULT_CAMERA_DEVICE | |
format = VideoIO.DEFAULT_CAMERA_FORMAT | |
camera = VideoIO.opencamera(device, format) | |
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 =#) | |
img = glplot(Texture(img, 3), kernel=kernel, filternorm=0.1f0) | |
#Get Gpu memory object | |
glimg = img.uniforms[:image] | |
#Asynchronous updating with React: | |
lift(Timing.fpswhen(window.inputs[:open], 30.0)) do x | |
newframe = VideoIO.read(camera) | |
update!(glimg, mapslices(reverse, newframe, 3)) # needs to be mirrored :( | |
end | |
renderloop(window) | |
In case it was not clear, the image looked strange before the Laplacian was applied in your code (during testing). I will try again and see whether it is something in my setup.
Interesting..
Did you try VideoIO.viewcam(), to verify if its my opengl code, or VideoIO ?
@jakebolewski can you post your specs, settings, and the way you execute the code to:
SimonDanisch/GLPlot#8
This issue gets on my nerve, but I can't reproduce it neither on windows nor ubuntu, so it's a little bit like a ghost hunt to me...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the code. I tried it and found it works on my Mac OSX. However, for those new to ffmpeg, I should note that at least on my laptop (Norwegian), the VideoIO.DEFAULT_CAMERA_DEVICE is not properly set by the VideoIO routine from Tim.
First, after installing ffmpeg I checked the following in the bash console
ffmpeg -f avfoundation -list_devices true -i ""
This showed that the "Innebygd iSight" (built-in iSight) was the camera available.
Second, I tested that this device can indeed acquire a stream directly via ffmpeg:
ffmpeg -f avfoundation -i "Integrated" out.mpg
With this information, I changed line 5 of your code to ensure that it works.
device = "Innebygd iSight"
I noticed that the color and image are not what I normally see with the iSight camera. I assume that this is because the format is not set right, but I am not sure what I should change there?