SFML community forums
Help => Graphics => Topic started by: Tommeh on April 13, 2009, 05:10:23 am
-
I am building an app that takes input from animations/webcam/video files and converts it down to low resolution and greyscale to send to an external LED matrix.
Any tips/pointers as how to greyscale the video output and get it into a matrix (multidimensional array)?
I'm not just looking for an answer, but a point in the right direction would be greatly appreciated.
-
[I'm not an expert.]
Grey means same value for red, green and blue.
So, why not taking an average from this three value of one pixel to "greyize" it ?
-
The best formula is the following:
grey = 0.3 * red + 0.59 * green + 0.11 * blue
It takes in account how the human eye sees the intensity of each component (green is much more brighter than blue).
-
Sorry, I should have been more specific.
Using a normal image and converting it to greyscale (via matricies/loops/whatever) is too slow for realtime, maybe it was just the way I was doing it...
It uses huge amounts of CPU when even crappy free webcam apps can convert the webcam input to greyscale (or perform many other effects) pretty easily without being too taxing on the CPU.
Also, what I have no clue about is how can I actually access the video output information of a SFML window?
-
Usually, this kind of filters is part of the video API, and thus can be highly optimized. What API are you using to capture the webcam output?
-
Im using windows so I guess that means my Video API is directshow?
I was hoping to avoid using directshow since building it with mingw32 is hell.
-
If it's DirectShow, I'm pretty sure you have a filter for that. You should find a good documentation or tutorial for it.
-
Or just use a shader.