Perl 6 - the future is here, just unevenly distributed

IRC log for #openframeworks, 2014-11-18

| Channels | #openframeworks index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:13 r618 joined #openframeworks
00:33 darthdeus joined #openframeworks
00:44 neue joined #openframeworks
01:16 w4ffles joined #openframeworks
01:30 ar_tama joined #openframeworks
02:06 reqshark joined #openframeworks
03:26 lukaszw joined #openframeworks
04:21 w4ffles joined #openframeworks
04:36 pizthewiz joined #openframeworks
05:34 rat_ joined #openframeworks
06:01 ar_tama_ joined #openframeworks
06:10 pizthewiz joined #openframeworks
06:18 petrusd987 joined #openframeworks
06:40 w4ffles joined #openframeworks
07:19 admsyn joined #openframeworks
07:58 marcocanc joined #openframeworks
08:01 kritzikratzi joined #openframeworks
08:10 mhashmi joined #openframeworks
08:13 Eibx joined #openframeworks
08:29 lukaszw joined #openframeworks
08:41 mhashmi_ joined #openframeworks
09:05 Eibx joined #openframeworks
09:18 mhashmi joined #openframeworks
09:21 Poelsesnak- joined #openframeworks
09:44 ilbot3 joined #openframeworks
09:44 Topic for #openframeworks is now Welcome :) Site: http://openframeworks.cc/ Logs: http://irclog.perlgeek.de/openframeworks/ Nov 2 Meetup notes: https://openframeworks.hackpad.com/IRC-Meetup-November-2-1024
11:08 kritzikratzi joined #openframeworks
11:20 mhash joined #openframeworks
12:11 mhash joined #openframeworks
12:17 kritzikratzi joined #openframeworks
12:41 mhash joined #openframeworks
13:11 mhash joined #openframeworks
13:26 marcocanc joined #openframeworks
13:48 tmm88 joined #openframeworks
13:49 tmm88 hey guys. what's up? can someone tell me what's the equivalent of has waiting message() method for osc receive but for osc send, and how can I implement it within this code   ofxOscMessage a;     ofxOscMessage b;      if(counterMillis==0){                 for (int i = 0; i < contourFinder.nBlobs; i++){              if(contourFinder.blobs[i].hole){              a.setAddress("/blob/xypos");             a.addIntArg(i);
14:24 kritzikratzi joined #openframeworks
14:43 admsyn hi tmm88
14:44 admsyn I don't really understand the question, what're you looking to do?
14:53 w4ffles joined #openframeworks
15:10 tmm88 so basically I am trying to send blob detection (position and width) from ofx to maxmsp
15:10 tmm88 but it turns to be that I am sending data at an extremely high rate
15:11 tmm88 and when I check the activity monitor on mac
15:11 tmm88 i have more than 80% of cpu load
15:11 tmm88 of ofx debug
15:11 tmm88 to be clear and precise I want to apply some sort of filtering to my code
15:11 tmm88 that enables me to send only the essential data to max
15:11 admsyn there's a bit of a weird interaction with OF and vsync on OSX, that'll make the app do update()/draw() way too fast when the app is in the background
15:12 admsyn you can get around it by doing an ofSetVerticalSync(true); AND doing an ofSetFrameRate(60);
15:14 admsyn but a more direct way around that might be to check ofGetElapsedTimeMillis() every update and only send your OSC data once in awhile
15:15 tmm88 I was trying to implement something similar
15:15 tmm88 to that
15:15 tmm88 but with my own code
15:15 tmm88 since that was a common strategy in processing
15:16 tmm88 when you want to avoid too much data
15:16 tmm88 i was setting a counterMillis variable in the update()
15:16 tmm88 and whenever it reached 24 or 60 it would send the data
15:16 tmm88 but it was not working
15:18 reqshark joined #openframeworks
15:19 admsyn so is the issue that you're using 80% cpu in your OF app, or that your OSC isn't working because it's being sent too fast?
15:30 tmm88 both
15:30 tmm88 I have 80% of cpu being used
15:30 tmm88 and is not working properly
15:31 tmm88 i have this in my main file
15:31 tmm88 #include "ofMain.h" #include "ofApp.h" using namespace std; //======================================================================== int main( ){      ofSetupOpenGL(320,240, OF_WINDOW);// <-------- setup the GL context      // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN // pass in width and height too: ofRunApp( new ofApp());     ofSetVerticalSync(true);     ofSetFrameRate(24);       }
15:31 tmm88 and then my draw is something like
15:31 admsyn can you post the code in pastebin instead?
15:31 tmm88 void ofApp::draw(){          int counterMillis=ofGetElapsedTimeMillis();     counterMillis%=100;     if(counterMillis==0){              ofxOscMessage a;     ofxOscMessage b;      if(counterMillis==0){                 for (int i = 0; i < contourFinder.nBlobs; i++){              if(contourFinder.blobs[i].hole){              a.setAddress("/blob/xypos");             a.addIntArg(i);             a.addFloatArg(contourFinder.blobs[i
15:31 admsyn don't do that
15:32 tmm88 so how shall i do that
15:32 admsyn i mean don't paste your code into IRC, use pastebin.com or something similar
15:32 tmm88 ah ok sorry
15:34 tmm88 http://pastebin.com/cSkbEVdb
15:35 admsyn alright, your 80% cpu usage might just be because of the contour tracking stuff
15:35 admsyn your OSC probably isn't working because your counter thing isn't doing what you probably think it's doing
15:36 admsyn what you're doing there is checking if the number of milliseconds since the app launched is divisible by 100, and if it is then sending a message
15:37 admsyn or in other words it's basically just randomly working one in every hundred update()s
15:38 admsyn what you can do instead, is keep track of the last time you sent a message, and then on the next update() check if it's been long enough since the last message
15:39 admsyn so if(currentMillis - lastMessageMillis > 100) would be every 100ms
15:45 tmm88 can you make a little scratch code in paste bins and post it here
15:45 tmm88 :)
15:45 tmm88 thanks
15:46 admsyn what I wrote is basically the gist, though. On update() currentMillis = ofGetElapsedTimeMillis(), then do the check I wrote above
15:47 admsyn then when you send the message do lastMessageMillis = currentMillis
15:47 admsyn make sure you set lastMessageMillis to 0 in your setup() or you might get weird behaviour
15:52 pizthewiz joined #openframeworks
15:53 sebllll joined #openframeworks
16:06 tmm88 I think there might be a better algorithm for doing that. and I applied this in max to fft data. once i was also feeding it to open sound control and it was too noisy.. so what I did was basically to make a zl stream 100 and zl median, and then loosing some data resolution by getting only one char decimal point float between one and zero and outputting the data only if there is a change in the value. is there a way to implemen
16:07 tmm88 so basically creating a stream of the last 100 values
16:07 tmm88 and then making a median
16:07 admsyn sure, that'd work too
16:08 tmm88 and multiplying it by a certain and value and making data type conversion
16:08 tmm88 how could I implement this in c++ (sorry I am not so fluent in c++ as I am in max)
16:09 admsyn you mean calculate the median and send that every 100 frames?
16:09 admsyn err 100ms
16:10 tmm88 no that's not this
16:10 tmm88 calculating the median of 1000 values for an instance
16:10 tmm88 than if the range is for an instance 0-1000
16:11 tmm88 dividing it by 1000 multiplying it by ten converting to int and divide it back by ten
16:11 tmm88 and then checking if there are changes in the data
16:11 tmm88 if there are changes
16:11 tmm88 i mean if a value changes
16:11 tmm88 than dumping out the new value as a osc message
16:12 tmm88 otherwise do nothing
16:12 admsyn well, there's like 4ish parts to what you're describing
16:12 admsyn you can use a std::queue to keep track of the last 1000 samples
16:12 ar_tama joined #openframeworks
16:12 admsyn so every update you add a value in a take a value out the end
16:12 tmm88 yes but then smoothing the data
16:12 tmm88 would generate less output
16:13 admsyn well, I've got to go right now, but I think you may be getting overly complicated right now if your issue is just that you seem to be sending OSC too often
16:14 admsyn your rate limiter was broken before, which may have been the real issue
16:14 admsyn everything you're describing is just .. math, so I'm not sure how to make it any clearer since you already seem to know the math part
16:14 admsyn I'll be back in a few hours or so though, good luck!
16:21 w4ffles joined #openframeworks
16:55 pizthewiz joined #openframeworks
18:38 lukaszw joined #openframeworks
18:54 w4ffles joined #openframeworks
19:33 marcocanc joined #openframeworks
19:43 reqshark joined #openframeworks
19:45 admsyn joined #openframeworks
19:49 kritzikratzi joined #openframeworks
19:50 vdps joined #openframeworks
19:50 admsyn tmm88: any luck?
19:53 tmm88 I tried to search for the instructions on the c++ reference for finding the methods (objects in this case) to do the operations but I was not pretty successful. as I said I am not a tough c++ programmer. I know about algorithms because I have to implement them in another programming languages in which i am more fluent. but this is not the case of c++. I still have to think a lot to do things that take me seconds or few minutes
19:54 tmm88 anyway I will be posting the algorithm that I have in max in paste bin.com so that you can have a more clear picture of what I am talking about
19:54 admsyn alright, well if you pick maybe a small part of the problem you're trying to solve I can point you in the right direction
19:54 tmm88 and then if you can help I appreciate it, otherwise I will keep trying myself
20:01 tmm88 http://pastebin.com/cZbFjZ9s
20:01 tmm88 this is what I am doing in max and i am trying to implement in ofx
20:01 admsyn ah I don't have max unfortunately
20:01 tmm88 ah ok
20:02 tmm88 and can you read max code
20:02 tmm88 ?
20:02 tmm88 otherwise I post an image somewhere
20:02 tmm88 with the code
20:02 admsyn is there a part that's tripping you up in particular though? keeping track of 1000 readings? the median calculation? etc?
20:02 admsyn not really no unless we're talking fairly basic stuff
20:05 tmm88 http://pastebin.com/EX5gH494
20:05 admsyn alright, here's sort of an abstract step-by-step:
20:06 tmm88 this is not so difficult to be done, the thing is applying it to a vecotr
20:06 tmm88 vector
20:06 tmm88 like this one
20:06 admsyn stream n values - use a std::queue to keep track of n values
20:06 admsyn push() adds a value, pop() takes out the oldest value
20:07 tmm88 and out do i limit the rang of the stream
20:07 tmm88 let's say if i want to stream only a certain amount of values
20:07 tmm88 and when this value is reached
20:07 admsyn ofMap will do that for you
20:07 admsyn so mappedValue = ofMap(value, minValue, maxValue, 0, 1)
20:08 tmm88 keep concatenating and deleting the old ones
20:08 admsyn will map value from min-max to 0-1
20:08 admsyn > concatenating and deleting the old ones that's what std::queue and push()/pop() will do
20:09 tmm88 ok
20:09 admsyn are you familiar with std::vector?
20:09 tmm88 not really I know what is an array (of course, that's basic).. but not really familiar with std vector
20:09 admsyn vector is pretty much an array, but you can call functions like size() on it
20:10 admsyn so like myVector.size()
20:10 admsyn and other functions to add stuff to the vector
20:10 tmm88 ok
20:10 admsyn std::queue is similar, but handles "add new value" and "remove old value" for you
20:11 tmm88 so i can say for an instance std::queue myVector.push()/pop/
20:11 admsyn yeah pretty much
20:12 tmm88 and then doing ofMap(myVector, 0, ofGetWidth), 0, 1)
20:12 tmm88 and then doing ofMap(myVector, 0, ofGetWidth(), 0, 1)
20:12 admsyn yepp
20:13 tmm88 then i Just do normal myvector * 10
20:13 tmm88 (int)myVector
20:13 admsyn I assume you know the multiply and divide operators, but if you're doing a weird cast thing be aware that multiply and divide will implicitly cast the result to whatever's on the right side of the operation
20:13 tmm88 myVector/10.
20:13 admsyn is myVector like an x/y thing or a std::vector?
20:14 tmm88 a vector with all the blobs
20:14 tmm88 i have to send to max
20:14 admsyn ofMap is going to work on one float at a time, not a whole vector
20:16 tmm88 ok
20:17 tmm88 so I have to strip the vector and do it slowly
20:17 tmm88 index by index
20:17 tmm88 i mean
20:17 admsyn yes
20:18 admsyn got to go again, best of luck
20:23 vdps joined #openframeworks
20:35 tmm88 so i am solving the queue thing like this. but i am getting some mistakes. i'd appreciate some hints http://pastebin.com/MzsP3NMQ
20:36 tmm88 ah and i am doing in draw so think that also have something else to fix
20:48 dcunit3d joined #openframeworks
20:49 admsyn joined #openframeworks
21:01 w4ffles joined #openframeworks
21:47 tmm88 http://pastebin.com/vRZ7Ryqz i'd appreciate some help to fix this :D adminserv who quit the chat has helped me with some tips on how to implement an algorithm but i am sure i didn't do it properly and as i am a noobish guy in c++. i'd appreciate all the help possible.. kind regards
22:14 pizthewiz joined #openframeworks
22:16 petrusd987 joined #openframeworks
23:00 vdps_ joined #openframeworks
23:15 ChanServ joined #openframeworks

| Channels | #openframeworks index | Today | | Search | Google Search | Plain-Text | summary