Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
1  
@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

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

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

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

 
discard

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.