ofxPatterns: gesture & speech recognition addon, HMMs & more

Hello,

The ofxGesture addon has been renamed to ofxPatterns due to added functionality. In addition to previous mouse / feature vector gesture classification classes & examples, the new version 0.05 includes:

  • a class and accompanying example for speech classification, contributed by Dhi Aurrahman and Arif Setiawan (you can train the class to recognize different words or sentences)

  • a class and accompanying example for on-line mouse gesture recognition, contributed by David Burri (you can use the class to recognize gestures on-line, i.e. without knowing a priori where the gestures begin and end)

Version 0.05 of ofxPatterns is available from sourceforge:
https://sourceforge.net/projects/amelib-…-erns/0.05/
and documentation here:
http://ame4.hc.asu.edu/amelia/ofxpatterns/index.html

There are packages for OS X, Windows (Code::Blocks & MSVC), and Linux. Please note that some examples might not work correctly on some platforms. If you run into problems please let me know.

Future versions of this addon will include general HMM functionality (e.g., a class that allows you to create an arbitrary Markov chain and use it to generate patterns of numbers), and other pattern-related algorithms (e.g., edit distance, dynamic time warping).

Best,

Stjepan

The speech recognition add in is great. I’ve played around with Julius a lot but couldn’t ever get a live way of training sorted out and so had to build dictionaries and grammar trees beforehand. Have you figured out a max number of models that the library supports with good (i.e. ~60-75%) accuracy or a max length?

The speech functionality is pretty infant. For one, each model is non-hierarchical (e.g., if you train it to recognize a couple of words, each model does not break down the words into phonemes to help training or recognition). Being that it only does classification at the moment (as opposed to on-line recognition), it is also pretty sensitive to segmentation. If you segment the recordings well (which can be tricky in the provided example, since you have to press/release the mouse button precisely before/after you speak), it works relatively well, otherwise not so much.

In terms of how many models you can reliably recognize, it depends on how distinguishable they are. If you want to distinguish between longer sentences (that are significantly different from each other), I imagine you can distinguish between quite a few of those (say, tens or hundreds). If you’re distinguishing between short words that share some similarity, it will probably start to deteriorate after only a few.

Adding a hierarchical model should help a lot, but that will take some work. The underlying library supports hierarchical models, but getting that functionality into the addon in a way that is easy to use will be a challenge.

If you try this out, I’d love to hear how it works out (or doesn’t work out) for you.

Best,

Stjepan

Training 1-10 works more or less like I’d expect, a really rough guess would be ~70% accuracy with a single speaker and invariant environment. I’ll report back when I test some more.

Hello,

your addon sounds pretty amazing to me but I can’t get it working. I have a Windows XP Laptop and I use Codeblocks so I downloaded the codeblocks version.

I unpacked the file and copied the folders into my OF folders to apps and addons. Then I opened the examples and tried to build them and this is what I got:

||=== patternsExample, release ===|
…\libs\openFrameworks\utils\ofConstants.h|47|glu.h: No such file or directory|
…\libs\openFrameworks\events\ofEventUtils.h|5|Poco/FIFOEvent.h: No such file or directory|
…\libs\openFrameworks\events\ofEventUtils.h|6|Poco/Delegate.h: No such file or directory|
…\libs\openFrameworks\events\ofEventUtils.h|16|error: Poco' has not been declared| ..\..\..\libs\openFrameworks\events\ofEventUtils.h|16|error: expected template-name before '<' token| ..\..\..\libs\openFrameworks\events\ofEventUtils.h|16|error: expected{’ before ‘<’ token|
…\libs\openFrameworks\events\ofEventUtils.h|16|error: expected unqualified-id before ‘<’ token|
…\libs\openFrameworks\events\ofEventUtils.h||In function void ofAddListener(EventType&, ListenerClass\*, void (ListenerClass::\*)(const void\*, ArgumentsType&))':| ..\..\..\libs\openFrameworks\events\ofEventUtils.h|30|error:Poco’ has not been declared|
…\libs\openFrameworks\events\ofEventUtils.h||In function void ofAddListener(EventType&, ListenerClass\*, void (ListenerClass::\*)(ArgumentsType&))':| ..\..\..\libs\openFrameworks\events\ofEventUtils.h|35|error:Poco’ has not been declared|
…\libs\openFrameworks\events\ofEventUtils.h||In function void ofRemoveListener(EventType&, ListenerClass\*, void (ListenerClass::\*)(const void\*, ArgumentsType&))':| ..\..\..\libs\openFrameworks\events\ofEventUtils.h|50|error:Poco’ has not been declared|
…\libs\openFrameworks\events\ofEventUtils.h||In function void ofRemoveListener(EventType&, ListenerClass\*, void (ListenerClass::\*)(ArgumentsType&))':| ..\..\..\libs\openFrameworks\events\ofEventUtils.h|55|error:Poco’ has not been declared|
…\libs\openFrameworks\events\ofEvents.h|48|error: field setup' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h|49|error: fieldupdate’ has incomplete type|
…\libs\openFrameworks\events\ofEvents.h|50|error: field draw' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h|51|error: fieldexit’ has incomplete type|
…\libs\openFrameworks\events\ofEvents.h|52|error: field windowResized' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h|54|error: fieldkeyPressed’ has incomplete type|
…\libs\openFrameworks\events\ofEvents.h|55|error: field keyReleased' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h|57|error: fieldmouseMoved’ has incomplete type|
…\libs\openFrameworks\events\ofEvents.h|58|error: field mouseDragged' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h|59|error: fieldmousePressed’ has incomplete type|
…\libs\openFrameworks\events\ofEvents.h|60|error: field mouseReleased' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h|62|error: fieldaudioReceived’ has incomplete type|
…\libs\openFrameworks\events\ofEvents.h|63|error: field audioRequested' has incomplete type| ..\..\..\libs\openFrameworks\events\ofEvents.h||In member functionvoid ofCoreEvents::disable()’:expressionless:
…\libs\openFrameworks\events\ofEvents.h|66|error: setup' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|67|error:draw’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|68|error: update' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|69|error: request for memberdisable’ in exit', which is of non-class typevoid ()(int)’|
…\libs\openFrameworks\events\ofEvents.h|70|error: keyPressed' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|71|error:keyReleased’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|72|error: mouseDragged' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|73|error:mouseReleased’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|74|error: mousePressed' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|75|error:mouseMoved’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|76|error: audioReceived' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|77|error:audioRequested’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h||In member function void ofCoreEvents::enable()':| ..\..\..\libs\openFrameworks\events\ofEvents.h|81|error:setup’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|82|error: draw' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|83|error:update’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|84|error: request for member enable' inexit’, which is of non-class type void ()(int)'| ..\..\..\libs\openFrameworks\events\ofEvents.h|85|error:keyPressed’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|86|error: keyReleased' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|87|error:mouseDragged’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|88|error: mouseReleased' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|89|error:mousePressed’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|90|error: mouseMoved' was not declared in this scope| ..\..\..\libs\openFrameworks\events\ofEvents.h|91|error:audioReceived’ was not declared in this scope|
…\libs\openFrameworks\events\ofEvents.h|92|error: audioRequested' was not declared in this scope| ..\..\..\libs\openFrameworks\communication\ofArduino.h|277|error: fieldEDigitalPinChanged’ has incomplete type|
…\libs\openFrameworks\communication\ofArduino.h|280|error: field `EAnalogPinChanged’ has incomplete type|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options…|
||=== Build finished: 50 errors, 0 warnings ===|

So, ehm…help :slight_smile:

hmmm the install.xml of the codeblocks version looks like this:

0.05
Stjepan Rajko
Dhi Aurrahman
David Burri
Arif Setiawan
http://ame4.hc.asu.edu/amelia/patterns/

../../../addons/ofxPatterns/src/ ../../../addons/ofxPatterns/libs/ofxPatterns/lib/osx/libofxPatterns.a ../../../addons/ofxPatterns/libs/ofxPatterns/lib/osx/libboost\_serialization.a

I don’t know if this causes problems but xcode and max is wrong and in the folder structure are now *.a files.

Is this maybe the problem? I don’t know :?:

no one? :frowning:

I really don’t understand whats going wrong.

Or am I doing anything wrong?

copying the files into the right folders, open the examples with cb and error…disturbing!

are you trying to compile a 0.05 codeblocks project in 0.061? You may need to recreate the project in 0.061 by duplicating an empty project and following the steps to make it. Alternatively, you can download OF 0.05 if you want to try compiling the example provided on the source forge site. The errors you are a getting seem to be from compiling an older project in a newer version of OF.

take care,
zach

hey,

i’m using 0061.
I’m going to try to rebuild it by myself. wooo, I’m so excited, I hope it works :smiley:

I’ll report the results.

Thank you so far, zach.

hm ,not working :?

Using an older OF version is no option, because I wanted to use this addon in an existing project, made in 0061.

can you upload a zip of this project?

I’ll take a look – perhaps this addon was built using boost? (which means there might be linking problems… it looks like it’s missing some functions in boost that it needs).

I’m not very familiar with the addon but if you upload this I’ll take a look

take care,
zach

Hey, here is the empty example I created:
http://www.megaupload.com/?d=3DJCRHE5

and thank you very much for your efforts :slight_smile:

Hi, I am having the same errors as vekman.

I am in windows7, with codeblocks 10.05, and I tried it in OF0062 and OF007

Did you find any soluction?

Thanks

Hi venkman, i’m trying to open your example in windows but i can’t (on mac works fine)… codeblocks show to me a lot of errors like this:

||=== emptyExample, debug ===|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve -defaultlib:uuid.lib ' unrecognized| ||Warning: .drectve-defaultlib:uuid.lib ’ unrecognized|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve -defaultlib:LIBCMT ' unrecognized| ||Warning: .drectve-defaultlib:OLDNAMES ’ unrecognized|
||Warning: .drectve /DEFAULTLIB:"LIBC" /DEFAULTLIB:"OLDNAMES" ' unrecognized| obj\debug\src\testApp.o:C:\Users\Jaime\Desktop\of\_preRelease\_v0062\_win\_cb\_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.cpp|75|undefined reference toofPatternClassification<float, SpeechClassificationConfiguration>::numPatterns() const’|
obj\debug\src\testApp.o:C:\Users\Jaime\Desktop\of_preRelease_v0062_win_cb_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.cpp|90|undefined reference to ofPatternClassification<float, SpeechClassificationConfiguration>::save(std::ostream&) const'| obj\debug\src\testApp.o:C:\Users\Jaime\Desktop\of\_preRelease\_v0062\_win\_cb\_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.cpp|98|undefined reference toofPatternClassification<float, SpeechClassificationConfiguration>::load(std::istream&)’|
obj\debug\src\testApp.o:C:\Users\Jaime\Desktop\of_preRelease_v0062_win_cb_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.cpp|106|undefined reference to ofPatternClassification<float, SpeechClassificationConfiguration>::addPatternWithExamples(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&)'| obj\debug\src\testApp.o:C:\Users\Jaime\Desktop\of\_preRelease\_v0062\_win\_cb\_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.cpp|140|undefined reference toofPatternClassification<float, SpeechClassificationConfiguration>::classify(std::vector<float, std::allocator > const&)’|
obj\debug\src\testApp.o||In function ~testApp':| C:\Users\Jaime\Desktop\of\_preRelease\_v0062\_win\_cb\_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.h|39|undefined reference toofPatternClassification<float, SpeechClassificationConfiguration>::~ofPatternClassification()’|
C:\Users\Jaime\Desktop\of_preRelease_v0062_win_cb_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.h|39|undefined reference to ofPatternClassification<float, SpeechClassificationConfiguration>::~ofPatternClassification()'| C:\Users\Jaime\Desktop\of\_preRelease\_v0062\_win\_cb\_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.h|39|undefined reference toofPatternClassification<float, SpeechClassificationConfiguration>::~ofPatternClassification()’|
C:\Users\Jaime\Desktop\of_preRelease_v0062_win_cb_FAT\apps\examples\emptyExample - ReconocimientoAudio\src\testApp.h|39|undefined reference to ofPatternClassification<float, SpeechClassificationConfiguration>::~ofPatternClassification()'| obj\debug\src\main.o:main.cpp:(.text$\_ZN7testAppC1Ev[testApp::testApp()]+0x9c)||undefined reference toofPatternClassification<float, SpeechClassificationConfiguration>::ofPatternClassification()’|
obj\debug\src\main.o:main.cpp:(.text$_ZN7testAppC1Ev[testApp::testApp()]+0xec)||undefined reference to `ofPatternClassification<float, SpeechClassificationConfiguration>::~ofPatternClassification()’|
||=== Build finished: 11 errors, 17 warnings ===|

Please tell me how to do, i need to that works on Windows urgently, thanks a lot!

venkman, the example with which version of the codeblocks work?

Here is the solution of all problems in codeblocks windows, i made this xml, enjoy it!

<?xml version="1.0"?>

- 0.05 Stjepan Rajko Dhi Aurrahman David Burri Arif Setiawan http://ame4.hc.asu.edu/amelia/patterns/ -

- - …/…/…/addons/ofxPatterns/src/ofxMouseGestureClassification.h …/…/…/addons/ofxPatterns/src/ofxPatternClassification.h …/…/…/addons/ofxPatterns/src/ofxPatternRecognition.h …/…/…/addons/ofxPatterns/src/ofxSpeechClassification.h …/…/…/addons/ofxPatterns/src/ofxVectorGestureClassification.h …/…/…/addons/ofxPatterns/src/ofxVectorGestureRecognition.h - …/…/…/addons/ofxPatterns/src …/…/…/addons/ofxPatterns/libs/ofxPatterns/win-cb - …/…/…/addons/ofxPatterns/libs/ofxPatterns/win-cb/libboost_serialization.lib …/…/…/addons/ofxPatterns/libs/ofxPatterns/win-cb/libofxPatterns.lib …/…/…/addons/ofxPatterns/libs/ofxPatterns/lib/osx/libofxPatterns.a …/…/…/addons/ofxPatterns/libs/ofxPatterns/lib/osx/libboost_serialization.a

Hi,
Just trying to use such amazing (and old) addon in OF v08, but with no succesfull
I guess issues saving and building the gestures classification

using OF007 works fine, so there should be an issue in OF008 using ofstream or … Any idea?

I get BAD_ACCESS error when saving the training pattern

Download addon ofxPattern: http://sourceforge.net/projects/amelibraries/files/

pd: Others ways to capture and recognize gestures are by TUIO or PyMT (would need python binding) but they are probably more focused on multitouch finger detection, and I’m more looking for a general patern detection and this one looks pretty good and easy.
After all it would be nice to upload this addon to github and the ofxAddons site.

Any opinion so wellcome.
Cheers

//OF 008 with Xcode 3.2.3 and Mac OS X 10.6.8

Hi @charli_e. Did you manage to find a solution to the use of the amelia library in ofx 008?
Cheers
marinero