ToneMatrix – Webcam Object Tracking
During our subject Interface Culture we (Matthias Schmidt, Bettina Steger and my humble self) were working on a project that uses hand-drawn objects on a white paper for making music.
Note: You have to allow the webcam!
Hold a white paper with black (or dark) objects that you painted on it in front of the camera. The red rectangle indicates the tracked area, the green rectangles indicates the tracked objects. Then hit the space-bar (Note: be sure that the flash movie gets the focus)
The flash-app uses the webcam for accessing three different videos. The normal video that we convert into two other videos: A threshold video and a palette video.
The palette video is used for tracking the brightest area in the video and reducing the tracking-area to this area (e.g. the white paper is usual the brightest color in the video, so objects that are in the background aren't tracked any longer). The threshold video is used for tracking the darkest objects within the brightest area.
How does this work? In the treshold video it is supposed that the red pixels are the objects, and coherent pixels belongs to one object. I've implemented a flood fill algorithm that counts the pixel of each object and returns the x,y position and width and height of an object. With this information we can nearly perfectly track the object and use for example the pixelamount for the volume of the sound and the x,y/width,height information for the timeline.
When all objects are tracked and you press the Space-Bar the tracked area is converted into a matrix of 16x16 fields. Each field represents a sound, fields that are lower plays a lower sound, fields that are higher a higher one. The timeline goes from left to right.
The source code is available here: ToneMatrixSource
QuadTrees Actionscript 3
Note: Hence, I write my articles in english (and I'm glad if you notice any mistake and send it to me).
In our course Computergraphics I've developed an implementation of QuadTrees for Actionscript 3. A QuadTree is a datastructure for increasing the efficiency of collisiondetection or nearest neighbour appointment.
You can enable the collisiondetection by hitting a "C" and switch between QuadTree and Bruteforce by hitting Space. The amount of objects can be changed by typing it in the field labeled with 50.
SourceCode: QuadTreeSource
Flex mit Ruby on Rails + authlogic authenitifizieren
Bei meinem aktuellen Rails Projekt loggen sich die Benutzer per authlogic auf der Seite ein, alles über Rails. Da jedoch ein Teil der Seite mit einer Flex App realisiert wird, musste ich das Zusammenspiel zwischen Rails und Flex ein wenig erforschen.
Mein erster Blick fiel auf WebORB mit dem passenden Flex Plugin indem man sehr einfach die einzelnen Modells und somit die Datenbank ansprechen kann. (http://sujitreddyg.wordpress.com/2009/10/13/ruby-on-rails-extension-for-flash-builder-4/)
Hier habe ich zwar Zugriff auf das UserSession-Modell von authlogic, jedoch nicht auf die aktuelle Session und somit die eingeloggten User. Die Cookies und Sessions werden erst im UserSessionsController festgelegt.
Um nun in der Flex Anwendung zu wissen "Ist der User eingeloggt" und wenn ja "Welcher User bist du denn?" erweitert man den UserSessions Controller um folgende Methode:
def checkLogin
if logged_in?
xml = "
<usersessions>
<login>true</login>
<currentid>#{current_user_session.user.id}</currentid>
</usersessions>"
else
xml = "
<usersessions>
<login>false</login>
<currentid>false</currentid>
</usersessions>"
end
respond_to do |format|
format.xml { render : xml => xml }
end
end
Hiermit stellen wir eine Methode bereit die uns ein XML File rendert das sagt, bin ich eingeloggt, oder nicht (über das Format der XML ließe sich streiten).
In der Flex App kreiert man nun einen HTTP-Service, der auf die URL der Methode verweist, und bei erfolgreichem Result das ganze als XML ausgibt.
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
public function switchStates(event:ResultEvent):void {
var xml:XML = event.result as XML;
var loggedInP:Boolean = xml.login as Boolean;
var currentID:int = xml.currentid;
trace(currentID);
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService resultFormat="e4x" id="login" url="http://localhost:3000/user_sessions/checkLogin" result="switchStates(event)" fault="trace('fault');"/>
</fx:Declarations>
Natürlich muss im Application tag noch
creationComplete="login.send()
gesetzt werden. Und schon hat man zwei Variablen, die den User authentifizieren.



