Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
@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

Use NotebookWrite.

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

Appending to List

Already answered by Mr. Sjoerd C. de Vries...

share|improve this answer
pixpos = {};
  a = EdgeDetect[CurrentImage[], 30]; 
  b = ImageKeypoints[a, "PixelPosition"]; 
  AppendTo[pixpos, b]; 

enter image description here

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}]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.