Loading...
Logo
Processing Forum
jorrebor's Profile
17 Posts
22 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Hi all,

    I have setup my kinect camera and now I want to track the wrists (or torso, or head for that matter). I see that I can draw the skeleton. But i would like to get the actual position vectors of these joints, because I want to calculate the speed.

    Something like:

    SimpleOpenNI context = new SimpleOpenNI();
    PVector vector = context.getLimb(SimpleOpenNI.SKEL_TORSO).getPVector(); 

    What function to call? 

    Iterating over a RealWorldMap and storing all differences seem overdone for this purpose. 

    Thank you.


    Hi all,

    i am new to OS x and wanted to copy my processing sketches (from ubuntu) to my new mac. But I run into an error when i try to use GSvideo, see below. The sketch did run fine when i copied from windows to ubuntu. 

    EDIT: OK sorry, need to install the library again for osx
    1. Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Unable to load library 'gstreamer-0.10': dlopen(libgstreamer-0.10.dylib, 9): image not found
    2. at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
    3. at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
    4. at com.sun.jna.Library$Handler.<init>(Library.java:140)
    5. at com.sun.jna.Native.loadLibrary(Native.java:379)
    6. at org.gstreamer.lowlevel.GNative.loadNativeLibrary(GNative.java:48)
    7. at org.gstreamer.lowlevel.GNative.loadLibrary(GNative.java:45)
    8. at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
    9. at org.gstreamer.lowlevel.GstNative.load(GstNative.java:39)
    10. at org.gstreamer.Gst.<clinit>(Gst.java:59)
    11. at codeanticode.gsvideo.GSVideo.initImpl(GSVideo.java:129)
    12. at codeanticode.gsvideo.GSVideo.init(GSVideo.java:86)
    13. at codeanticode.gsvideo.GSMovie.<init>(GSMovie.java:92)
    14. at codeanticode.gsvideo.GSMovie.<init>(GSMovie.java:69)
    15. at Motion_Recorder_mac.setNextMovie(Motion_Recorder_mac.java:351)
    16. at Motion_Recorder_mac.setup(Motion_Recorder_mac.java:152)
    17. at processing.core.PApplet.handleDraw(PApplet.java:1608)
    18. at processing.core.PApplet.run(PApplet.java:1530)
    19. at java.lang.Thread.run(Thread.java:680)



    Hi all,

    i get this error sometimes when showing a GSMovie. 

    What can cause these errors? all videos files are smaller than the sketch. Can it be a nullpointer or something?  

    When using the standard examples from the library i have no problems. 

    Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
    at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java:404)
    at processing.core.PGraphicsJava2D$ImageCache.update(Unknown Source)
    at processing.core.PGraphicsJava2D.imageImpl(Unknown Source)
    at processing.core.PGraphics.image(Unknown Source)
    at processing.core.PApplet.image(Unknown Source)
    at Accelerometer_Capture.draw(Accelerometer_Capture.java:217)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:662)
    EDIT: set framerate to be the same as the framereate of the movie and playback is much smoother. No freezes anymore :0

    Hi all,

    My sketch picks a random video from a set of about 60 movies. All movies are 1024 x 768 px, .avi format. Movies take about 3 seconds

    I declare a movie by 

    1. GSMovie movie
    Then the movie object is instantiated in the function setNextMovie():

    1.   movie = new GSMovie(this, "test_movie.avi");
    I start the movie by calling:
    1.  movie.play()
     then i stop the movie by calling:
    1. movie.stop()
    Then i call setNextMovie again which assigns "movie" to a new movie. 
    The filename is kept test_movie for, well, testing purposes. 

    . When i run the sketch everything is fine. After playing a few movies (i.e. 15 to 20) the sketch becomes unresponsive. 

    I still get respons from my controlP5 buttons, but the video remains frozen, and choosing setnextMovie() and START movie does not yield any effect.  

    Is this a common issue? What is the best video format for GSvideo? 

    I could make the movies smaller, but i want to be sure that it would solve the issue. 

    I post my code hereunder, its large, i know but it is working. Please download the sample movie from here, and put it in your data folder inside the sketch folder.  

    Running the sketch, and choosing START movie, STOP movie, SETUP NEXT movie should freeze the sketch after a while. 

    I guess my working memory is filling up after some movies, i might have to destroy the movie objects?


    Thanks alot in advance!

    1. /**
    2.  This program receives motion data from phone
    3.  
    4.  */
    5. import java.io.*;
    6. import codeanticode.gsvideo.*;
    7. import controlP5.*;
    8. import oscP5.*;
    9. import netP5.*;

    10. NetAddress myRemoteLocation;
    11. OscP5 oscP5;
    12. ControlP5 controlP5;
    13. ControlWindow controlWindow;
    14. Textfield p_field;
    15. Textlabel p_label;

    16. //so we can write
    17. PFont myFont;

    18. //PrintWriter output;
    19. FileWriter output;

    20. GSMovie movie;

    21. //to store participant ID
    22. String participant;

    23. //these hold the motion values
    24. float x, y, z;

    25. //needed for motion recording
    26. boolean record;
    27. int cntr = 0;
    28. //data sequences are stored as vectors
    29. PVector [] mdata = new PVector [2000];

    30. //the number of movies in each pos
    31. int n_movies = 19;

    32. //string holding the movie name
    33. String movie_filename;

    34. //to count which movie is next
    35. int m_counter = 0;
    36. int p_counter = 0;

    37. //needed for order of the performed gestures
    38. int [] p_1 = new int [n_movies];
    39. int [] p_2 = new int [n_movies];
    40. int [] p_3 = new int [n_movies];

    41. //need for random order of positions
    42. int [] position_name = new int [3];

    43. //to keep the order of the positions
    44. int [] p_order = new int [3];

    45. //to store which movies have been shown
    46. int [] movie_name = new int [n_movies];

    47. /////////////////////////////////////////////////////SETUP/////////////////////////////////////////////

    48. void setup() {
    49.   //setup the canvas
    50.   size(1024, 720, P3D);
    51.   frameRate(100);
    52.   background(0);

    53.   myFont = createFont("FFScala", 32);
    54.   textFont(myFont);

    55.   //make a connection with the OpenSoundControlProtocol
    56.   oscP5 = new OscP5(this, 25002);
    57.   myRemoteLocation = new NetAddress("192.168.1.82", 25002);

    58.   //create an interface framework
    59.   controlP5 = new ControlP5(this);
    60.   controlP5.setAutoDraw(true);
    61.   //controlP5.setControlFont(new ControlFont(createFont("Verdana", 15)));

    62.   //create secondary control window for controlling video playback and motion recording
    63.   controlWindow = controlP5.addControlWindow("ControlWindow", 100, 100, 400, 400);
    64.   controlWindow.setTitle("Controls");

    65.   //create control objects
    66.   p_field = controlP5.addTextfield("ParticipantID", 50, 5, 150, 25);
    67.   Button startButton = controlP5.addButton("Start Record", 1, 50, 50, 150, 50);
    68.   Button stopButton =  controlP5.addButton("Stop Record", 2, 50, 110, 150, 50);
    69.   Button storeButton = controlP5.addButton("Store Record", 3, 50, 170, 150, 50);
    70.   Button movieStart =  controlP5.addButton("Start Movie", 4, 220, 50, 150, 50);
    71.   Button moviePause =  controlP5.addButton("Stop Movie", 5, 220, 110, 150, 50);
    72.   Button nextMovie =   controlP5.addButton("Setup Next Movie", 6, 220, 170, 150, 50);
    73.   Button deleteRecord = controlP5.addButton("Clear Gesture Data", 7, 50, 290, 150, 50); 
    74.   //Toggle recordStartStop = controlP5.addToggle("Toggle to start and stop", false, 50, 550, 550, 125);
    75.   //p_label = controlP5.addTextlabel("ParticipantLabel", "NOT SET", 600, 5);

    76.   //position buttons on the controlwindow
    77.   p_field.setWindow(controlWindow);
    78.   startButton.setWindow(controlWindow);
    79.   stopButton.setWindow(controlWindow);
    80.   storeButton.setWindow(controlWindow);
    81.   movieStart.setWindow(controlWindow);
    82.   moviePause.setWindow(controlWindow);
    83.   nextMovie.setWindow(controlWindow);
    84.   deleteRecord.setWindow(controlWindow);
    85.   //recordStartStop.setWindow(controlWindow);
    86.   //p_label.setWindow(controlWindow);

    87.   //populate mdata with actual Vector objects
    88.   for (int i = 0; i < mdata.length; i++) {
    89.     mdata[i] = new PVector();
    90.   }

    91.   //populate movies with actual filenames
    92.   for (int i = 0; i < movie_name.length; i++) {
    93.     movie_name [i] = i + 1;
    94.   }

    95.   //populate positions with actual positions
    96.   for (int i = 0; i < 3; i++) {
    97.     position_name [i] = i + 1;
    98.   }

    99.   //create an array with the order of the positions
    100.   for (int i = 0; i < 3; i++) {
    101.     p_order [i] = getUniquePosition();
    102.   }
    103.  
    104.   //get an array with order of to be performed gestures for each position
    105.   //p_1 is sit, p_2 is stand, p_3 is walk
    106.   for (int i = 0; i < n_movies; i++ ) {
    107.     p_1 [i] = getUniqueMovie();

    108.     //if last position is reached, we should repopulate the movie_name array
    109.     if (i == n_movies - 1) {
    110.       for (int j = 0; j < movie_name.length; j++) {
    111.         movie_name [j] = j + 1;
    112.       }
    113.     }
    114.   }
    115.   
    116.   for (int i = 0; i < n_movies; i++ ) {
    117.     p_2 [i] = getUniqueMovie();

    118.     //if last position is reached, we should repopulate the movie_name array
    119.     if (i == n_movies - 1) {
    120.       for (int j = 0; j < movie_name.length; j++) {
    121.         movie_name [j] = j + 1;
    122.       }
    123.     }
    124.   }

    125.   for (int i = 0; i < n_movies; i++ ) {
    126.     p_3 [i] = getUniqueMovie();

    127.     //if last position is reached, we should repopulate the movie_name array
    128.     if (i == n_movies - 1) {
    129.       for (int j = 0; j < movie_name.length; j++) {
    130.         movie_name [j] = j + 1;
    131.       }
    132.     }
    133.   }

    134.   //setup first movies
    135.   setNextMovie();
    136. }


    137. ////////////////////////////////////////////DRAW////////////////////////////////////////////////
    138. void draw() {

    139.   //draw the movies on the screen
    140.   image(movie, 0, 0);
    141.   //image(profile_view, 640, 0);

    142.   controlP5.draw();
    143. }

    144. ///////////////////////////////////////////Button Event Handling/////////////////////////////////
    145. public void controlEvent(ControlEvent theEvent) {
    146.   int button = int(theEvent.controller().defaultValue());
    147.   switch (button) {
    148.   case 0:
    149.     //set the label of participant id
    150.     participant = theEvent.controller().stringValue();
    151.     println(participant);
    152.     break;
    153.   case 1:
    154.     startRecord();
    155.     break;
    156.   case 2:
    157.     stopRecord();
    158.     break;
    159.   case 3:
    160.     storeRecord();
    161.     break;
    162.   case 4:
    163.     startMovie();
    164.     break;
    165.   case 5:
    166.     stopMovie();
    167.     break;
    168.   case 6:
    169.     setNextMovie();
    170.     break;
    171.   case 7:
    172.     dumpRecord();
    173.     break;
    174.   }
    175. }
    176. void keyPressed () {
    177.   if (key == ' ') {
    178.     if (record == true) {
    179.       stopRecord();
    180.       println("STOP record");
    181.     } 
    182.     else {
    183.       startRecord();    
    184.       println("START record");
    185.     }
    186.   }
    187.   if (key == 's') {
    188.     println(key);
    189.     storeRecord();
    190.   }
    191. }

    192. void toggle(boolean theFlag) {
    193.   if (theFlag==true) {
    194.     record = true;
    195.     println("recording");
    196.   }
    197. }
    198. ///////////////////////////////////////////Motion Recording//////////////////////////////////////
    199. public void startRecord() {
    200.   cntr = 100;
    201.   record = true;
    202. }

    203. public void stopRecord() {
    204.   record = false;
    205. }

    206. public void storeRecord() {
    207.   //write participant id as comment 
    208.   try {  
    209.     output.write( "/* " + participant + " */");
    210.   }
    211.   catch (IOException e)
    212.   {
    213.     println ("error in participant write: " + e);
    214.   }

    215.   //once records stops we write the string to the output file
    216.   for (int i = 0; i < cntr; i++) {
    217.     String out = "[" + mdata[i].x + "\t" + mdata[i].y + "\t" + mdata[i].z + "]; ";
    218.     try {  
    219.       output.write(out);
    220.     }
    221.     catch (IOException e)
    222.     {
    223.       println ("error in stp rec: " + e);
    224.     }
    225.   }

    226.   try {
    227.     output.write("\n"); 
    228.     output.flush(); // Write the remaining data
    229.     output.close(); // Finish the file
    230.     println("GESTURE SEQUENCE STORED");
    231.   }
    232.   catch (IOException e)
    233.   {
    234.     println ("error in stp rec write: " + e);
    235.   }
    236. }

    237. public void dumpRecord() {
    238.   for (int i = 0 ; i < cntr + 1; i++) {
    239.     mdata[i].x = 0;
    240.     mdata[i].y = 0;
    241.     mdata[i].z = 0;
    242.   }
    243.   println("LAST RECORD DELETED");
    244. }

    245. //////////////////////////////////////////Movie Control/////////////////////////////////////////

    246. //setup the next movie
    247. public void setNextMovie() {

    248.   //println("pcounter: " + p_counter);
    249.   int m = p_order[p_counter];

    250.   switch (m) {
    251.   case 1:
    252.     movie_filename = "s " + p_1 [m_counter] + ".avi";
    253.     break;
    254.   case 2:
    255.     movie_filename = "st " + p_2 [m_counter]  + ".avi";
    256.     break;
    257.   case 3:
    258.     movie_filename = "w " + p_3 [m_counter]  + ".avi";
    259.     break;
    260.   }
    261.   if (m_counter == n_movies - 1) {
    262.     //if we reached the last movie in this position category
    263.     //go to next category
    264.     p_counter++;
    265.     m_counter = -1;
    266.   }
    267.   println("mcounter: " + m_counter);
    268.   m_counter++; 

    269.   // init movies, download the movie form
    270.   // http://dl.dropbox.com/u/22416352/test_movie.avi
    271.   movie = new GSMovie(this, "test_movie.avi");

    272.   println("NEXT MOVIE IS: " + movie_filename);
    273.   setNextGestureRecord();
    274. }

    275. //start the movie 
    276. public void startMovie() {
    277.   println("MOVIE START");
    278.   //TODO get movie to play 2 times
    279.   movie.loop();
    280. }

    281. //pauze or stop playback
    282. public void stopMovie() {
    283.   println("MOVIE STOP");
    284.   movie.stop();
    285. }

    286. /////////////////////////////////////////////////////////////////Gesture Record Control////////////////////////////////////

    287. public void setNextGestureRecord() {
    288.   //get a file writer to store the data in a file corresponding to the performed gesture
    289.   String [] parts = split (movie.getFilename(), '.');
    290.   String filename = parts[0];

    291.   try {
    292.     output = new FileWriter("D:\\" + "sequences\\" + filename + ".seq", true);
    293.   }
    294.   catch(IOException ioe) {
    295.     println("error in setup: " + ioe);
    296.   }
    297. }

    298. /////////////////////////////////////////////////////////////////////////Utils////////////////////////////////////////////

    299. //gets a unique movie name
    300. public int getUniqueMovie() {
    301.   int pos = int(random(0, n_movies));

    302.   //pick movie based on position
    303.   int unique = movie_name[pos];
    304.   //make the value 0 so that we can identify that the movie has been picked
    305.   movie_name[pos] = 0; 
    306.   //when movie has been picked its value has been set to zero, so we pick again
    307.   if (unique == 0) {
    308.     unique = getUniqueMovie();
    309.   }
    310.   return unique;
    311. }

    312. public int getUniquePosition() {
    313.   int pos = int(random(0, 3));

    314.   //pick movie based on position
    315.   int unique = position_name[pos];
    316.   //make the value 0 so that we can identify that the movie has been picked
    317.   position_name[pos] = 0; 
    318.   //when movie has been picked its value has been set to zero, so we pick again
    319.   if (unique == 0) {
    320.     unique = getUniquePosition();
    321.   }
    322.   return unique;
    323. }


    324. //this reads the image from the movie in order to display it
    325. void movieEvent(GSMovie thisMovie) {
    326.   thisMovie.read();
    327. }


    328. //Function reads motion data
    329. void oscEvent(OscMessage theOscMessage) {

    330.   if (theOscMessage.checkAddrPattern("/motion")) 
    331.   { 
    332.     //print("getting it: ");
    333.     if (record == true) {
    334.       mdata[cntr].x = theOscMessage.get(0).floatValue(); 
    335.       mdata[cntr].y = theOscMessage.get(1).floatValue();
    336.       mdata[cntr].z = theOscMessage.get(2).floatValue();

    337.       if (frameCount % 10 == 1) {
    338.         println(cntr + ": "+ mdata[cntr].x);
    339.       }
    340.       cntr++;
    341.     }
    342.   }
    343. }

    Hi all,

    i try to write an Pvector array to text file. My code works when i use PrintWriter. SInce PrintWriter doesn't have the ability to append data to files (not built in though), i decided to use FileWriter. My code trows an IO exception.

    Please have look!

    1. /**
    2.  This program receives motion data from phone
    3.  */
    4. import java.io.*;
    5. import codeanticode.gsvideo.*;
    6. import controlP5.*;
    7. import oscP5.*;
    8. import netP5.*;

    9. NetAddress myRemoteLocation;
    10. OscP5 oscP5;
    11. ControlP5 controlP5;
    12. ControlWindow controlWindow;

    13. //PrintWriter output;
    14. FileWriter output;

    15. GSMovie front_view;
    16. GSMovie profile_view;

    17. //these hold the motion values
    18. float x, y, z;

    19. //needed for motion recording
    20. boolean record;
    21. int i;

    22. //data sequences are stored as vectors
    23. PVector [] mdata = new PVector [2000];

    24. //to store which movies have been shown
    25. int [] movies = new int [5];

    26. /////////////////////////////////////////////////////SETUP/////////////////////////////////////////////

    27. void setup() {
    28.   //setup the canvas
    29.   size(1280, 480, P3D);
    30.   frameRate(25);
    31.   background(0);

    32.   //make a connection with the OpenSoundControlProtocol
    33.   oscP5 = new OscP5(this, 25000);
    34.   myRemoteLocation = new NetAddress("192.168.1.77", 25000);

    35.   //create an interface framework
    36.   controlP5 = new ControlP5(this);
    37.   controlP5.setAutoDraw(true);

    38.   //create secondary control window for controlling video playback and motion recording
    39.   controlWindow = controlP5.addControlWindow("ControlWindow", 100, 100, 800, 600);
    40.   controlWindow.setTitle("Controls");

    41.   //get a reference to button objects
    42.   Button startButton = controlP5.addButton("Start Record", 1, 50, 50, 250, 100);
    43.   Button stopButton =  controlP5.addButton("Stop Record", 2, 50, 175, 250, 100);
    44.   Button storeButton = controlP5.addButton("Store Record", 3, 50, 300, 250, 100);
    45.   Button movieStart =  controlP5.addButton("Start Movie", 4, 350, 50, 250, 100);
    46.   Button moviePause =  controlP5.addButton("Pauze Movie", 5, 350, 175, 250, 100);
    47.   Button nextMovie =   controlP5.addButton("Setup Next Movie", 6, 350, 300, 250, 100);

    48.   //position buttons on the controlwindow
    49.   startButton.setWindow(controlWindow);
    50.   stopButton.setWindow(controlWindow);
    51.   storeButton.setWindow(controlWindow);
    52.   movieStart.setWindow(controlWindow);
    53.   moviePause.setWindow(controlWindow);
    54.   nextMovie.setWindow(controlWindow);

    55.   //populate mdata with actual filenames
    56.   for (int i = 0; i < mdata.length; i++) {
    57.     mdata[i] = new PVector();
    58.   }

    59.   //populate movies with actual filenames
    60.   for (int i = 0; i < movies.length - 1; i++) {
    61.     movies [i] = i + 1;
    62.   }

    63.   //setup first movies
    64.   setNextMovie();

    65.   //get a file writer to store the data in a file corresponding to the performed gesture
    66.   String filename = front_view.getFilename();
    67.   
    68.   try {
    69.     FileWriter output = new FileWriter("4A.avi", true);
    70.   }
    71.   catch(IOException ioe) {
    72.     println("error: " + ioe);
    73.   }
    74.   //output = createWriter("4A.avi");
    75. }


    76. ////////////////////////////////////////////DRAW////////////////////////////////////////////////
    77. void draw() {

    78.   //draw the movies on the screen
    79.   image(front_view, 0, 0);
    80.   image(profile_view, 640, 0);

    81.   controlP5.draw();
    82. }

    83. ///////////////////////////////////////////Button Event Handling/////////////////////////////////
    84. public void controlEvent(ControlEvent theEvent) {
    85.   int button = int(theEvent.controller().defaultValue());

    86.   switch (button) {
    87.   case 1:
    88.     startRecord();
    89.     break;
    90.   case 2:
    91.     stopRecord();
    92.     break;
    93.   case 3:
    94.     storeRecord();
    95.     break;
    96.   case 4:
    97.     startMovie();
    98.     break;
    99.   case 5:
    100.     stopMovie();
    101.     break;
    102.   case 6:
    103.     setNextMovie();
    104.     break;
    105.   }
    106. }

    107. public void start (int theValue) {
    108.   println(theValue);
    109. }

    110. ///////////////////////////////////////////Motion Recording//////////////////////////////////////
    111. public void startRecord() {
    112.   record = true;
    113.   i = 0;
    114. }

    115. public void stopRecord() {
    116.   record = false;

    117.   for (int i = 0; i < mdata.length; i++) {
    118.     //why can i not do this?
    119.     //For printwriter i don't need to call toString()
    120.     String out = "[" + mdata[i].x.toString() + "\t" + mdata[i].y + "\t" + mdata[i].z+ "]; ";
    121.     String out_test = "this breaks";
    122.     output.write(out1);
    123.   }
    124.   output.write("\n==========================================================================================================");

    125.   output.flush(); // Write the remaining data
    126.   output.close(); // Finish the file
    127. }

    128. public void storeRecord() {
    129.   //TODO
    130. }

    131. //////////////////////////////////////////Movie Control/////////////////////////////////////////

    132. //setup the next movie
    133. public void setNextMovie() {
    134.   //get a unique integer
    135.   int i = getUniqueInt();

    136.   //create filenames
    137.   String movie_1 = i + "A.avi";
    138.   String movie_2 = i + "B.avi";

    139.   // init movies  
    140.   front_view = new GSMovie(this, movie_1);
    141.   profile_view = new GSMovie(this, movie_2);
    142. }

    143. //start the movie 
    144. public void startMovie() {
    145.   println("in start movie");
    146.   //TODO get movie to play 2 times
    147.   front_view.loop();
    148.   profile_view.loop();
    149. }

    150. //pauze or stop playback
    151. public void stopMovie() {
    152.   front_view.pause();
    153.   profile_view.pause();
    154. }


    155. /////////////////////////////////////////////////////////////////////////Utils////////////////////////////////////////////

    156. //gets a unique integer
    157. public int getUniqueInt() {
    158.   int pos = int(random(0, 4));
    159.   //pick movie based on position
    160.   int unique = movies[pos];
    161.   //make the value 0 so that we can identify that the movie has been picked
    162.   movies[pos] = 0; 
    163.   //when movie has been picked its value has been set to zero, so we pick again
    164.   if (unique == 0) {
    165.     unique = getUniqueInt();
    166.   }
    167.   return unique;
    168. }


    169. //this reads the image from the movie in order to display it
    170. void movieEvent(GSMovie thisMovie) {
    171.   thisMovie.read();
    172. }


    173. //Function reads motion data
    174. void oscEvent(OscMessage theOscMessage) {

    175.   if (theOscMessage.checkAddrPattern("/motion")) 
    176.   {
    177.     if (record == true) {
    178.       mdata[i].x = theOscMessage.get(0).floatValue(); 
    179.       mdata[i].y = theOscMessage.get(1).floatValue();
    180.       mdata[i].z = theOscMessage.get(2).floatValue();
    181.       i++;
    182.     }
    183.   }
    184. }

    Hi all,

    Is it possible to catch intents in android processing? I would like my program do store motion sensor data when the user is on the phone. 

    I know that an intent is send out when the user receives a call, but how can i fetch this in my proccessing app?

    Thanks in advance

    j
    Hi all,

    i just started off with my master thesis in human computer interaction. I want to investigate how people change their movements / gestures over time when they play motion sense enabled games, like wii-sports.

    Since i encountered some time and programming skill constraints i think its better if i get an open source game and modify it to my needs. 

    Does anybody know some simple open source games, preferably which use the accelerometer? 

    thanks alot!

    J
    Hi all,

    Just some general question

    A friend of mine pointed me to the fact that you can create processing sketches in Eclipse. I tried it a little but didnt get anything to work, i should try harder yes.

    Now i wonder whats the advantage of using eclipse? As i understand most people use it? Or are there other editors?

    Thanks for any explanation!

    j.


    Hi everyone!
    for a while now i have been trying to use my android phone as a motion tracker, like a wiimote Plus or Playstation move. 

    Is this in anyway possible or is the accelerometer of my HTC desire simply not engough DOF (what i am guessing)? 

    While being very accurate on rotation movements, lateral movement are very hard to detect (especially on constant speed).

    Anyone experience with this? Any tips and tricks are highly appreciated!

    bye
    Jorrit  
    Hoi everybody!

    i'm stuck with something simple...

    my sketch should draw a graph, but cannot exceed a certain area. So when the max width is reached the graph should shift to the left. 

    1. PVector[] my_array = new PVector[100];

    2. int val;
    3. int j;
    4. void setup() {
    5.   
    6.   frameRate(1);
    7.   
    8.   size(400,400);
    9.   //initialize some values
    10.   for (int i = 0; i < my_array.length; i++) {
    11.     my_array[i] = new PVector();
    12.     my_array[i].x = i;
    13.     my_array[i].y = i*2;
    14.   }
    15. //  printArray(my_array);
    16. // 
    17. //  shiftAndAdd(my_array, 10);
    18. //  printArray(my_array);
    19. //  
    20. //  shiftAndAdd(my_array, 999);
    21. //  printArray(my_array);
    22. }

    23. void draw(){
    24.   background(0);
    25.   stroke(255);
    26.   val = int(random (100,120));
    27.   my_array = shiftAndAdd(my_array, val);
    28.   for(int i = 0; i < my_array.length; i++){
    29.     point(my_array[i].x,my_array[i].y);
    30.   }
    31.   
    32. }

    33. // shift all the values to the left, and set the new value at the end
    34. PVector[] shiftAndAdd(PVector a[], int val){
    35.   int a_length = a.length;
    36.   System.arraycopy(a, 1, a, 0, a_length-1);

    37.   for(int i = 0; i < a.length; i++){
    38.       a[i].x = i;
    39.   }
    40.   printArray(a);
    41.   a[a_length-1].y = val;
    42.   return a;
    43. }

    44. // function to print array values in a row
    45. void printArray(PVector a[]) {
    46.   for (int i = 0; i < a.length; i++) {
    47.     print("x: " + a[i].x + " y: " + a[i].y + ", ");
    48.   }
    49.   println("\n----");
    50. }

    the random value val should be added to the array form which the line is drawn. for some reason this does not happen... The graph shifts, but without the las added item...

    i have no idea why this is; please help!
    thanks
    Does processing not provide a array.pop() / push() function?

    i want to store values coming from the motion sensor of my phone in an array and draw a graph of points based on this array. 

    When the length of the array reaches a certain value (800 in my case) i want to shift all values 1 position to the left and add a new value at position 799. 

    A new graph should be drawn based on this.

     To conclude: if the graph reaches the end of the square the graph should move to the left. For some reason this doesnt happen with my code... i'm left with some flickering stars :(

    1. import peasy.*;

    2. import shapes3d.utils.*;
    3. import shapes3d.animation.*;
    4. import shapes3d.*;

    5. import controlP5.*;
    6. import rwmidi.*;
    7. import processing.opengl.*;
    8. import oscP5.*;
    9. import netP5.*;

    10. NetAddress myRemoteLocation;
    11. OscP5 oscP5;
    12. Graph myGraph;


    13. //global rotation parameters
    14. float rx, ry, rz;

    15. void setup() {
    16.   smooth();
    17.   size(900, 500, OPENGL); 
    18.   background(0);
    19.   lights();


    20.   oscP5 = new OscP5(this, 12000);
    21.   myRemoteLocation = new NetAddress("192.168.1.17", 12000);
    22.   myGraph = new Graph(100,100,800,200,-10,10);
    23. }

    24. void draw() {
    25.   
    26.   rx = random(-10,10);
    27.   myGraph.storePoints();
    28.   myGraph.display();
    29.   if (frameCount > 799){
    30.     myGraph.movePoints();
    31.   }
    32. }


    33. class Graph {

    34.   //fields
    35.   int xPos, yPos, wd, ht, rgL, rgH, c;
    36.   PVector[] pointArray = new PVector[800];

    37.   //constructor
    38.   Graph(int _xPos, int _yPos, int _wd, int _ht, int _rgL, int _rgH ) {  //xpos, ypos, width, height, min_point, max_point

    39.     xPos = _xPos;
    40.     yPos = _yPos;
    41.     wd = _wd;
    42.     ht = _ht;
    43.     rgL = _rgL;
    44.     rgH = _rgH;

    45.     for (int i = 0; i < pointArray.length; i++) {
    46.       pointArray[i] = new PVector();
    47.     }
    48.   }

    49.   //methods
    50.   void display () {
    51.     for (int i = 0; i < pointArray.length; i++) {
    52.       noFill();
    53.       rect(xPos, yPos, wd, ht);

    54.       stroke(255);
    55.       point(xPos + pointArray[i].x, yPos + pointArray[i].y);
    56.     }
    57.   }

    58.   void movePoints () {
    59.     for (int i = 1; i < pointArray.length; i++) {
    60.       pointArray[i-1] =  pointArray[i];
    61.       println("i:" + i);
    62.     }
    63.   }

    64.   //get rotation value and store as y-component of vector
    65.   void storePoints () {
    66.     if (frameCount < 800) {
    67.       pointArray[c].y = map(rx, -10, 10, 0, ht);
    68.       pointArray[c].x = frameCount;
    69.     }
    70.     else {
    71.       pointArray[798].y = map(rx, -10, 10, 0, ht);
    72.       pointArray[798].x = xPos + wd;
    73.     }
    74.   }
    75. }

    Thanks!
    Hi all, 

    i am writing a sort  of game in which an airplane (user controlled) should leave a trailing path. This path is made up from a bezTube. 

    As it is now i record the xyz positions of the plane in a PVector array. The shapes3D lib has a function to create bezier tubes. This function takes the Pvector array as its input and creates the tube. 

    My problem is that the sketch slow, very slow. This is because i let the beziertube be created every loop of the draw function. It should be faster if i could expand the length of the tube in each loop. There does not seem to be a function for that however... 

    Any ideas how  speed things up?

    thanks!

    my code:


    1. void draw() {

    2.   lights();
    3.   background(0);

    4.    //display all floaters
    5.   for (int i=0; i < 1; i++) {
    6.     vlotSet[i].display();
    7.   }

    8.   //record path of floater
    9.   myPath.recordPath();

    10.   //display path of floater
    11.   myPath.display(this);
    12. }

    13. class Path {

    14.   //variables
    15.   Bezier3D form;
    16.   BezTube buis;
    17.   PVector[] vectorArray = new PVector[10000];
    18.   int i = 0;

    19.   //constructor
    20.   Path() {
    21.     //initialize vector array
    22.     for (int x = 0; x < vectorArray.length; x++) {
    23.       vectorArray[x] = new PVector(vlotSet[0].getXpos(), vlotSet[0].getYpos(), vlotSet[0].getZpos());
    24.     }
    25.   }

    26.   //methods
    27.   void recordPath() { //here i store the path

    28.     if (frameCount % 10 == 1) { //not every loop
    29.       vectorArray[i].x = vlotSet[0].getXpos();  
    30.       vectorArray[i].y = vlotSet[0].getYpos();
    31.       vectorArray[i].z = vlotSet[0].getZpos();
    32.       i++;
    33.     }
    34.   }

    35.   PVector[] getPath() {
    36.     return vectorArray;
    37.   }

    38.   void display(PApplet applet) {

    39.     form = new Bezier3D(vectorArray, 1000);
    40.     buis = new BezTube(applet, form, 5, 500, 16);//Bezier3D bez, float rad, int nbrSlices, int nbrSegments
    41.     buis.draw();
    42.     
    43.   }
    44. }



    Thanks in advance!
    Hello,

    I am having troubles with the controlP5 lib. I want to write a class which contains my GUI. Creating a controlp5 object from within my own class works. 

    clicking a button should trigger the method controlEvent (ControlEvent theEvent). Now that i have rewritten the whole thing that it fits in the interfaceBuilder class, the method does not seem to be called anymore...

    I am quite new to object oriented programming so an help in the right direction is greatly appreciated!!

    my code:

    1. class InterfaceBuilder {
    2.   
    3.   //fields
    4.   ControlP5 controlP5;
    5.   Button b;
    6.    
    7.   //constructor
    8.   InterfaceBuilder(PApplet applet) {

    9.     controlP5 = new ControlP5(applet);
    10.     controlP5.addButton("buttonB",255,100,120,80,19); //button name, theValue,  xPos, yPos, width, heigth
    11.   }

    12.   // function buttonB will receive changes from 
    13.   // controller with name buttonB
    14.   public void buttonB(int theValue) {
    15.     println("a button event from buttonA: "+theValue);
    16.   }

    17.   //triggered when button is clicked
    18.   public void controlEvent(ControlEvent theEvent) {
    19.     println(theEvent.controller().name()); //prints name of the clicked button
    20.   }
    21. }


    The example works fine .... 

    I probably have a pointer error somewhere but i cannot figure it out!

    greets jorrit

    Hello,

    I am using the controlP5 library to create a user interface. Since i try to train myself in writing nicely structured OO code i would like to instantiate the controlP5 class from y own interfaceBuilder class as following:

    1. class InterfaceBuilder {
    2.     
    3.   //fields
    4.   Button b;
    5.   ControlP5 controlP5;
    6.   
    7.   //constructor
    8.   InterfaceBuilder() {

    9.     controlP5 = new ControlP5(this);
    10.     
    11.     for (int i = 0; i<8; i++) {
    12.       controlP5.addButton("button" + (i+1), 200, i*100, 0, 100, 20);
    13.     }
    14.   }

    15.   // function buttonA will receive changes from 
    16.   // controller with name buttonA
    17.   public void buttonA (int theValue) {
    18.     println("a button event from buttonA: "+theValue);
    19.     myColor = theValue;
    20.   }

    21.   //triggered when button is clicked
    22.   public void controlEvent(ControlEvent theEvent) {
    23.     println(theEvent.controller().name());
    24.   }
    25. }

    When running this code i get the error message that "the constructor ControlP5(joystick.InterfaceBuilder) is undefined"

    (joystick is the name of my program). 

    When i create an controlP5 object in the setup loop it works fine, but i would like to create a class around it. What is wrong with the above code?

    thanks in advance!

    jorrit
    Hi all,

    i want to use the output of the accelerometer of my HTC in a processing sketch on my desktop (i want to use the values as midi messages). 

    First I thought of sending the values through BlueTooth. It turns out that i do not have a bluetooth device on my computer....

    any ideas on how i can send these values at high speed? Maybe over the wifi network?

    Any help greatly appreciated!

    Jorrit
    Hi all,

    I would like to control ableton with my android phone (e.g. use the accelometer and stuff). 

    i did manage to send midi messages to channels in ableton.  But i would also like to use the "learn" function of ableton (i.e. select MIDI map and move a controller knob -> that knob is now assigned to virtual knob in ableton). 

    I understand that i can use processing to send a controller change message to my KORG nano Kontrol, which can pass the message on to ableton. 

    But is there a way to kick the midi controller out of the equation and replace it with a virtual controller (so that i can more or less use the same code ;))

    Thanks in advance!

    Jorrit