We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I am new to the world of ccv, tuio and processing and would be greatful for any help with exporting data from blobs in ccv to a file. I have managed to set up ccv to recognize blobs on the field of my camera and would like now to export the position and size of these blobs into a text file (as a comma separated file that gets updated as the blobs move and new ones come into the field of vision). I am trying to do it with processing (i already loaded the TUIO library), but havent managed to go very far with the coding. Any ideas where to start? Thanks
Answers
If you have the data in memory and know what the CSV file should look like, then one option is to use Table.
Create your Table, add a row for each blob, and when you are done, save the table to disk -- it will handle all the specifics of the comma-separated format.
Is your question about what commands to use to save data to a file? Or how to get the x/y information from the library? Can you post a MCVE of what you have so far?
You can check the reference (https://processing.org/reference/) under the section Output>>Files related to the former. For your blobs, what library are you using?
Kf
Hi jeremydouglass and kfrajer,
Thanks for your input.
This is what i have so far (I moved to tsps and osc in stead of ccv and tuio). So far I can see in the console the data being received, but i want now to, in addition to seeing it, to store it in a csv continuously, as the data comes in. Since i am new to processing (and programming), been trying with tables and saving to a file, but with no success. If you can point me in the right direction, maybe with some examples, I will be grateful.
Cheers,
import tsps.*; TSPS tspsReceiver;
void setup(){ tspsReceiver= new TSPS(this, 12000); };
void draw(){ TSPSPerson[] people = tspsReceiver.getPeopleArray(); // loop through people for (int i=0; i<people.length; i++){ // get person TSPSPerson person = people[i];
println("-", person.id,"-", person.age,"-", person.centroid.x,"-",
person.centroid.y,"-", person.velocity.x,"-", person.boundingRect.width,"-", person.boundingRect.height);
}
Look at the reference: loadTable Table etc.
Can you share your attempt? Have you tried the Table / saveTable examples in the reference?
Thanks for all the input. I finally managed with output.println this is what finally works:
Hello,
I have the following code (new to this, so apologies for inconsistencies in the code below) that saves the raw data stream sent by TSPS communicating via OSD to a txt. Raw data is OK, but now would like to summarize the raw data to the .txt file. If anyone can help me with the following two questions, I would be very grateful:
-I would like now to average, "person.boundingRect.width" and "person.boundingRect.width" for each of the blobs ("person.id") that show up, and send these to the txt.
-Also, I need a conditional formula to evaluate if a person is moving right or left (I guess by subtracting the last and first position (i.e. person.centroid.x) for each person.id) and send this to the same .txt.
Thanks in advance for any help on this.
You want to average a number with itself? That will always be equal to the original number.
hi jeremydouglass, thanks. Sorry but my question was not clear enough. I am attaching a capture of the output table, hopefully it is clearer this way. As you will see, the "id", is a new individual, and the raw output shows, for each frame, the size of the bounding rectange (width and height) and I would like to get the average bounding rectangle for each id. Hope that clarifies it...
Are you trying to create an avgwidth, avgheight columns in your output data? Like:
no...something like this...
One approach:
Table
(!)Now, for each id:
Now you know the avgWidth for each id.
Another easy way of saving id-linked results is also with a HashMap:
That makes it easy to build your list of unique ids, easy to store values associated with an id in your dictionary, and easy to look them up. In your case, the HashMap key could be an int (id) and the value could be a PVector (avgWidth, avgHeight). However as you start storing more and more information in the hashmap (like direction) it might be easier to just use Table.
You could also technically store per-id width and height averages with two floatDicts, but again you end up with one new Dict per column as you add more information -- Table is probably easier.
will try with table. thanks!