How to record the stream of data (PixelPosition) dynamically?

I need to trace the moving of an object and get the coordinates of such movement. The set of coordinates will be used for the subsequent evaluation and analysis. I can easy get the current real-time coordinates by use of the following expression:

Dynamic[ImageKeypoints[EdgeDetect[CurrentImage[], 30], "PixelPosition"]]


But I need to record all these coordinates in the list in the separate cell or in separate file. I need that this list contains an cumulative set of all coordinates, frame by frame.

Please, suggest how to resolve this issue.

-
@rojo "PixelPosition" is an argument of ImageKeypoints. One bracket was misplaced and was easily corrected. –  Sjoerd C. de Vries May 11 '12 at 19:44

File Output

Use an output stream.

s = OpenWrite["your_filename"];

Dynamic[With[{a = ImageKeypoints[EdgeDetect[CurrentImage[], 30], "PixelPosition"]},
Write[s, a]; a], Deinitialization :> Close[s]]


It will close the stream upon the deletion of the dynamic cell. It is not a bad idea to put time stamp with it.

Dynamic[With[{a = ImageKeypoints[EdgeDetect[CurrentImage[], 30], "PixelPosition"]},
Write[s, AbsoluteTime[] -> a]; a], Deinitialization :> Close[s]]


Notebook Output

Dynamic[With[{a = ImageKeypoints[EdgeDetect[CurrentImage[], 30], "PixelPosition"]},
NotebookWrite[nb, Cell[RawBoxes[ToBoxes[a]]]]; a],
Initialization :> (nb = CreateDocument[, WindowTitle -> "PixelPosition"])]


Appending to List

-
pixpos = {};
Dynamic[
a = EdgeDetect[CurrentImage[], 30];
b = ImageKeypoints[a, "PixelPosition"];
AppendTo[pixpos, b];
a]


Let it run for some time then delete the graphic to stop the Dynamic and plot them to show we indeed collected the results:

Graphics@Table[{Hue[Random[]], Line[i]}, {i, pixpos}]


-