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.

  • 1
    $\begingroup$ @rojo "PixelPosition" is an argument of ImageKeypoints. One bracket was misplaced and was easily corrected. $\endgroup$ May 11, 2012 at 19:44

2 Answers 2


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...

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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