{
  "id": 1148,
  "title": "importing data to Octave/R, visualizing with PCA",
  "url": "/competitions/GestureChallenge/discussion/1148",
  "author_name": "",
  "post_date": "2011-12-11T22:09:35.343Z",
  "votes": 8,
  "comment_count": 4,
  "views": 4311,
  "content": "<p>Hi all,</p>\r\n<p>Anyone who doesn't have MATLAB may find this post helpful for importing the data:\r\n<a href=\"http://blog.learnfromdata.com/2011/12/visualizing-gestures-as-paths.html\">\r\nhttp://blog.learnfromdata.com/2011/12/visualizing-gestures-as-paths.html</a>. I'd love to hear of other approaches.</p>\r\n<p>I also made a visualization of the devel01 training data, and all of my code is available on Github.</p>\r\n<p>-David</p>",
  "messages": [
    {
      "id": "7081",
      "postDate": "12/11/2011 22:09:35",
      "content": "<p>Hi all,</p>\r\n<p>Anyone who doesn't have MATLAB may find this post helpful for importing the data:\r\n<a href=\"http://blog.learnfromdata.com/2011/12/visualizing-gestures-as-paths.html\">\r\nhttp://blog.learnfromdata.com/2011/12/visualizing-gestures-as-paths.html</a>. I'd love to hear of other approaches.</p>\r\n<p>I also made a visualization of the devel01 training data, and all of my code is available on Github.</p>\r\n<p>-David</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "7358",
      "postDate": "12/20/2011 04:21:31",
      "content": "<p>Hi again,</p>\r\n<p>I've added a bit more to the visualizations from that previous post. Besides plotting 10 training examples as paths in PC1/PC1 space, I've added paths for test examples (as animations, in a few cases).</p>\r\n<p>Certainly these representations throw away a lot of information, but it might be useful to think about using them as a basis for first-try algorithm.</p>\r\n<p>In any case, I hope it's interesting or fun to look at.</p>\r\n<p>http://blog.learnfromdata.com/2011/12/visualizing-chalearn-gestures-test-data.html</p>\r\n<p>Thanks,<br>\r\nDavid</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "7745",
      "postDate": "01/07/2012 10:05:07",
      "content": "<p>Thanks very much David from another MATLAB-less individual; always great when someone puts up reproducible and very instructive code. One thing I noticed on my system is that the aviread function in octave does not appear to be picking up the frames correctly.\r\n By looking at an animation of the data in R with the EBImage package (compare the following code with the K_40.avi file), there appears to be some odd carry-over effects in the captured frames. Though it may just be related to my setup, or an older octave\r\n version. There is this <a href=\"http://lists.gnu.org/archive/html/octave-bug-tracker/2011-12/msg00366.html\">\r\nbug report</a> on the web that may be related.&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<pre>library(EBImage)<br>K &lt;- readMat(&quot;Data/Ks47.mat&quot;)[[1]]<br>K40 &lt;- do.call(abind, c(K[[40]], along=3))<br>display(aperm(K40,c(2,1,3)))</pre>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "7758",
      "postDate": "01/07/2012 23:58:49",
      "content": "<p>Is there a way to read the data directly from R? Does anybody know a way?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "7762",
      "postDate": "01/08/2012 05:39:47",
      "content": "<p>There isn't one that I know of, however you can write one using the R function system and the system utility ffmpeg. My function below uses ffmpeg to create one jpeg file for each frame and then reads in the frames using EBImage. It does not reproduce the\r\n strange effects created on my set-up with octave's aviread. Both aviread and my R function (both use ffmpeg) produce too many frames at about 40 fps whereas the actual frame rate is 10 fps. I don't know enough about video files to explain this, but the metadata\r\n seems to give zero fps, so perhaps 40 is an ffmpeg default. Anyway, note that about 75% of the frames read give no movement and are unnecessary.</p>\r\n<p>Also, although it's fun to play around with these things in R, it was never designed for image/video analysis, and there are much better things out there if you have access to them.</p>\r\n<pre>library(EBImage)<br>setwd(&quot;/home/alec/Documents/CHALEARN&quot;)<br>readVideo &lt;- function(fname, bw=TRUE, w, h)<br>{<br>  <br>  system(paste(&quot;ffmpeg -i&quot;, fname, &quot;frame%05d.jpg&quot;))<br>  frfiles &lt;- list.files(pattern=&quot;^frame\\\\d{5}\\\\.jpg$&quot;)<br>  nf &lt;- length(frfiles)<br>  if(nf) vid &lt;- vector(&quot;list&quot;, nf) else stop(&quot;no frames created&quot;)<br>  for(i in 1:nf) {<br>    tmp &lt;- readImage(frfiles[i])<br>    if(bw) tmp &lt;- channel(tmp, &quot;gray&quot;)<br>    if(!missing(w) || !missing(h)) tmp &lt;- resize(tmp, w=w, h=h)<br>    vid[[i]] &lt;- tmp<br>  }<br>  system(&quot;rm frame[0-9][0-9][0-9][0-9][0-9].jpg&quot;)<br>  combine(vid)<br>}<br><br>K1vid &lt;- readVideo(&quot;Data/devel01/K_1.avi&quot;, w=100)<br>display(K1vid)<br>M1vid &lt;- readVideo(&quot;Data/devel01/M_1.avi&quot;, bw=FALSE, w=100)<br>display(M1vid)</pre>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 7358,
      "author_name": "dchudz",
      "author_url": "",
      "post_date": "12/20/2011 04:21:31",
      "content": "<p>Hi again,</p>\r\n<p>I've added a bit more to the visualizations from that previous post. Besides plotting 10 training examples as paths in PC1/PC1 space, I've added paths for test examples (as animations, in a few cases).</p>\r\n<p>Certainly these representations throw away a lot of information, but it might be useful to think about using them as a basis for first-try algorithm.</p>\r\n<p>In any case, I hope it's interesting or fun to look at.</p>\r\n<p>http://blog.learnfromdata.com/2011/12/visualizing-chalearn-gestures-test-data.html</p>\r\n<p>Thanks,<br>\r\nDavid</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 7745,
      "author_name": "alecstephenson",
      "author_url": "",
      "post_date": "01/07/2012 10:05:07",
      "content": "<p>Thanks very much David from another MATLAB-less individual; always great when someone puts up reproducible and very instructive code. One thing I noticed on my system is that the aviread function in octave does not appear to be picking up the frames correctly.\r\n By looking at an animation of the data in R with the EBImage package (compare the following code with the K_40.avi file), there appears to be some odd carry-over effects in the captured frames. Though it may just be related to my setup, or an older octave\r\n version. There is this <a href=\"http://lists.gnu.org/archive/html/octave-bug-tracker/2011-12/msg00366.html\">\r\nbug report</a> on the web that may be related.&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<pre>library(EBImage)<br>K &lt;- readMat(&quot;Data/Ks47.mat&quot;)[[1]]<br>K40 &lt;- do.call(abind, c(K[[40]], along=3))<br>display(aperm(K40,c(2,1,3)))</pre>",
      "votes": null,
      "replies": []
    },
    {
      "id": 7758,
      "author_name": "cihanb",
      "author_url": "",
      "post_date": "01/07/2012 23:58:49",
      "content": "<p>Is there a way to read the data directly from R? Does anybody know a way?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 7762,
      "author_name": "alecstephenson",
      "author_url": "",
      "post_date": "01/08/2012 05:39:47",
      "content": "<p>There isn't one that I know of, however you can write one using the R function system and the system utility ffmpeg. My function below uses ffmpeg to create one jpeg file for each frame and then reads in the frames using EBImage. It does not reproduce the\r\n strange effects created on my set-up with octave's aviread. Both aviread and my R function (both use ffmpeg) produce too many frames at about 40 fps whereas the actual frame rate is 10 fps. I don't know enough about video files to explain this, but the metadata\r\n seems to give zero fps, so perhaps 40 is an ffmpeg default. Anyway, note that about 75% of the frames read give no movement and are unnecessary.</p>\r\n<p>Also, although it's fun to play around with these things in R, it was never designed for image/video analysis, and there are much better things out there if you have access to them.</p>\r\n<pre>library(EBImage)<br>setwd(&quot;/home/alec/Documents/CHALEARN&quot;)<br>readVideo &lt;- function(fname, bw=TRUE, w, h)<br>{<br>  <br>  system(paste(&quot;ffmpeg -i&quot;, fname, &quot;frame%05d.jpg&quot;))<br>  frfiles &lt;- list.files(pattern=&quot;^frame\\\\d{5}\\\\.jpg$&quot;)<br>  nf &lt;- length(frfiles)<br>  if(nf) vid &lt;- vector(&quot;list&quot;, nf) else stop(&quot;no frames created&quot;)<br>  for(i in 1:nf) {<br>    tmp &lt;- readImage(frfiles[i])<br>    if(bw) tmp &lt;- channel(tmp, &quot;gray&quot;)<br>    if(!missing(w) || !missing(h)) tmp &lt;- resize(tmp, w=w, h=h)<br>    vid[[i]] &lt;- tmp<br>  }<br>  system(&quot;rm frame[0-9][0-9][0-9][0-9][0-9].jpg&quot;)<br>  combine(vid)<br>}<br><br>K1vid &lt;- readVideo(&quot;Data/devel01/K_1.avi&quot;, w=100)<br>display(K1vid)<br>M1vid &lt;- readVideo(&quot;Data/devel01/M_1.avi&quot;, bw=FALSE, w=100)<br>display(M1vid)</pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "7081": "",
    "7358": "",
    "7745": "",
    "7758": "",
    "7762": ""
  },
  "source": "meta"
}