Webcam in Squeak, the OLPC, at 20 frames per second
One thing is to walk in the OLPC old code, and quite another is that code to work in an acceptable manner. In the video processing is, perhaps, one of the most ambitious targets on the OLPC.
Imagine you have to process 20 frames per second, and the image measures 320x240 pixels. Each pixel is composed of 3 data (the Red, the Green and the Blue) that are called RGB (Red, Green, Blue). If we have to process each image point, we will have 320x240 processing times per frame, the operations for the Red, Green and Blue.
have to achieve 20 frames per second with a 320x240 image, we need to do:
320 (W) * 240 (high) * 3 (RGB) * 20 (frames / sec) = 4,608,000 (operations / sec)
In a prosecution like this, the low speed of the OLPC is noted.
Well, the first port Linux code to the OLPC, was virtually without problems BUT processing speed obtained was sorry. Processing only 3 frames per second.
After some changes in the code (to avoid floating point arithmetic, loop unrolling, use of 16-bit bitmaps instead of 32 bits, etc) we managed 20 frames per second.
One thing to note is that the model and the philosophy of Squeak impose greater requirements to code. Put another way: Process Squeak video is not ONLY show full screen video, as soon as possible. If only we did that, we could get the same 30 frames x second with an image of 640x480 pixels to achieve the majority of programs monitoring video cameras. Squeak video processing is to integrate video as a full citizen in the world of objects 100% controllable and programmable.
no good video to see if we can not do anything with it. In Squeak video can be manipulated like any other object (you can rotate, move, resize, etc). It can also be programmed from eToys scripts.
This is the vocabulary of video object:
With this vocabulary (and vocabulary Squeak other objects) can do some interesting experiments .... For example: If we an animation in Squeak, the traditional , but instead of filling the container with drawings made by hand, fill with 1 frame per second from the webcam (using the property # lastFrame), we get a a video animation is fast (like that video of accelerated growth of the plants they put in the documentary channels, or an apple rotting in 20 seconds, etc) than it is to capture the Webcam.
The most interesting this option is that the accelerated video is a production of the child. Do not use the "show accelerated video" that does everything for him, but he has to deal with the problem, using knowledge they already have. Quite in line Squeak.
Finally I leave a question:
What other experiments can be done with the webcam and Squeak?