ofxLearn -> machine learning for of

i have started working on a general machine learning library that i think people may have some interest in.


the idea is to make easy to use machine learning routines for OF to support tasks in gesture/pattern recognition, data viz, and the like. i’ll be making some examples hopefully over the next little while, but for anyone interested in seeing the somewhat immature version right now, please check it out.

Hello, I’m trying your lib and I’have this error when I compile :

dlib/threads/thread_pool_extension.h|129|erreur: expected class-name before ‘{’ token|

I think the dlib are in the right place in the application folder.

hey mathieu,

which OS are you using? and which example are you trying to compile? make sure you don’t pull in dlib’s actual source into your project, just make sure the libs folder is in your header search path.


I’m working on ubuntu studio 12.04,

I’ve write #include “dlib/queue.h” in testApp.h
and put the dlib folder link to the src folder and the example.cbp.
I’m trying the example-gesture2d

Thanks for your help

you should not need to include dlib/queue.h. just pull in ofxLearn.h and ofxLearn.cpp into your source, include ofxLearn.h, and add the path to dlib ( addons/ofxLearn/libs/ ) to your header search path (or user header search path in xcode). let me know if that works for you.

In codeblocks the project open a file with
#error “Don’t put the dlib folder in your include path”
and an explanation.

In testApp.h there is #include “ofxLearn.h”, the the Learn.cpp and Learn.h are in the src file.
But I don’t know how to put the link for dlib in the headers search path, I’m on Linux.

Thanks for this code. It’s a good job and interesting project.

Smart me up, Machine-Learning-Technologies

Sorry to reply so later.
But anyone can said me where I have to put this line : “…/…/…/addons/ofxLearn/libs/” for the dlib.
genekogan spoke about header search path but I’work on Linux and I don’t know what is it.

Sorry for this question.



I’m trying to start using the dlib, and your openframeworks addon is a very good help.
Unfortunatly I have some problems, because I would like to include other things in the library, and when I start including
image_io.h, etc I receive a lot of error messages…
I tried to use the dlib library by itself, and I could manage to compile the matrix examples on mac osx with xcode. When I tried the image examples, I start receiving a lot of link errors… :frowning:
I tried to include the source.cpp in my project, as explained in the site, but without any good results…
Can you help me? When are you thinking on expanding or addon with the other dlib capabilities?
Can I help you with that…I need some guidance with that :slight_smile:
Thanks in advance…
best regards,

Paulo Trigueiros

I’m enjoying the ofxLearn just now.But it seems that the getsture2d is same as clustering. Please check it, thx!

@genekogan thank you for the addon !
I started to look into the clustering example, the result is not looking as I imagined and I am curious to know if my result is normal or if I am missing something.

I am trying to do clusters from the bright zones in the image on the left side and I have a vbo mesh on the right to display the colored clusters
this is the code I am using

int numclusters = 6;
int increment = 4;
int index = 0;

for (int x = 0;x<myNoise.getWidth();x+= increment) {
	for (int y = 0;y < myNoise.getHeight();y+= increment) {
		ofColor col = myNoise.getColorAtPixel(x, y);
		if (col.r > 100) {
			xyz.push_back(ofMap(y, 0, myNoise.getHeight(), 0, 1.0));

clusters = clusterer.getClusters();

for (int i = 0;i < numclusters;i++) {
	colors.push_back(ofColor(ofRandom(255), ofRandom(255), ofRandom(255)));

for (int i = 0;i < mesh.getNumVertices();i++) {
	mesh.setColor(i, colors[clusters[i]]);

it seems to be doing what i would expect. what is the objective of your clustering? since the data you are using seems to be just the position of the point, it makes sense that it’s clustered according to location. are you expecting another layout?

Thank you for your reply
I was thinking I would get a layout that would look like this

or with another example more like https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/34412/versions/11/screenshot.png rather than https://camo.githubusercontent.com/dcd678740a6e437e733ecf7312b57b5b67a696b4/687474703a2f2f7777772e6d6c2e756e692d736161726c616e642e64652f636f64652f70537065637472616c436c7573746572696e672f696d616765732f636c7573746572735f3137625f6e6f7469746c65322e706e67

k-means is trying to minimize amount of internal variance/interpoint distances in the clusters. if you want to separate out the bands you have, you may want to encode it instead as a radius from a center point instead of x, y – then you may get something closer to that.