├── .gitmodules ├── .travis.yml ├── README.md ├── addon_config.mk ├── example_audio_classification ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ ├── heatmap.frag │ │ ├── heatmap.vert │ │ └── verdana.ttf ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_bar_plot ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make ├── images │ └── bar_plot.png └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_classification ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make ├── images │ ├── classification_example_1.png │ ├── classification_spiral_1.png │ ├── classification_spiral_2.png │ ├── classification_step_1.png │ ├── classification_step_2.png │ ├── classification_step_3.png │ ├── classification_step_4.png │ ├── nonlinear_data_1.png │ ├── nonlinear_decision_tree_1.png │ ├── nonlinear_knn_1.png │ ├── nonlinear_mindist_1.png │ ├── nonlinear_rf_10.png │ ├── nonlinear_rf_100.png │ └── nonlinear_rf_200.png └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_dtw ├── Makefile ├── addons.make ├── bin │ └── data │ │ ├── shaders │ │ ├── noise.frag │ │ └── noise.vert │ │ └── verdana.ttf ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_fft ├── Makefile ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_gyrosc_orientation_classification ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make └── src │ ├── gyrosc.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_gyrosc_shake_classification ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make └── src │ ├── gyrosc.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_kinect_expressive_mapping ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ ├── .DS_Store │ │ ├── model │ │ ├── Feisar_Ship.3ds │ │ ├── diffuse.bmp │ │ └── specular.bmp │ │ ├── moonlight_loop.wav │ │ ├── tellier_loop.wav │ │ └── verdana.ttf ├── config.make └── src │ ├── .DS_Store │ ├── SynapseStreamer.cpp │ ├── SynapseStreamer.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_kinect_posture_classification ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make └── src │ ├── SynapseStreamer.cpp │ ├── SynapseStreamer.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_kinect_posture_multidimensional_regression ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ ├── .DS_Store │ │ ├── model │ │ ├── Feisar_Ship.3ds │ │ ├── diffuse.bmp │ │ └── specular.bmp │ │ └── verdana.ttf ├── config.make └── src │ ├── .DS_Store │ ├── SynapseStreamer.cpp │ ├── SynapseStreamer.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_kinect_posture_regression ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ ├── .DS_Store │ │ ├── model │ │ ├── Feisar_Ship.3ds │ │ ├── diffuse.bmp │ │ └── specular.bmp │ │ └── verdana.ttf ├── config.make └── src │ ├── .DS_Store │ ├── SynapseStreamer.cpp │ ├── SynapseStreamer.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_linear_least_squares ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make ├── images │ └── lls_1.png └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_matrix_plot ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ ├── heatmap.frag │ │ ├── heatmap.vert │ │ └── verdana.ttf ├── config.make ├── images │ └── matrix_plot.png └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_mlp_learn ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_regression ├── Makefile ├── README.md ├── addons.make ├── bin │ └── data │ │ ├── TrainingData.grt │ │ └── verdana.ttf ├── config.make ├── images │ ├── regression_step_1.png │ ├── regression_step_10.png │ ├── regression_step_2.png │ ├── regression_step_3.png │ ├── regression_step_4.png │ ├── regression_step_5.png │ ├── regression_step_6.png │ ├── regression_step_7.png │ ├── regression_step_8.png │ └── regression_step_9.png └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── example_timeseries_plot ├── Makefile ├── addons.make ├── bin │ └── data │ │ └── verdana.ttf ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── libs └── .gitignore └── src ├── ofxGrt.h ├── ofxGrtBarPlot.cpp ├── ofxGrtBarPlot.h ├── ofxGrtMatrixPlot.cpp ├── ofxGrtMatrixPlot.h ├── ofxGrtSettings.cpp ├── ofxGrtSettings.h ├── ofxGrtTimeseriesPlot.cpp └── ofxGrtTimeseriesPlot.h /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/grt"] 2 | path = libs/grt 3 | url = https://github.com/nickgillian/grt.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | os: 3 | - linux 4 | - osx 5 | compiler: 6 | - gcc 7 | before_install: 8 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi 9 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test ; fi 10 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test ; fi 11 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update ; fi 12 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq install g++-4.8 ; fi 13 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install cmake ; fi 14 | - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then sudo apt-get install -qq libstdc++-4.8-dev; fi 15 | - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" = "g++" ]]; then export CXX="g++-4.8" CC="gcc-4.8"; fi 16 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget http://openframeworks.cc/versions/v0.9.8/of_v0.9.8_osx_release.zip of_version.zip; fi 17 | before_script: 18 | - ls -lah 19 | script: 20 | branches: 21 | only: 22 | - master 23 | - dev 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ofxGrt 2 | 3 | This repo contains an [openFrameworks](http://openframeworks.cc) extension for the [Gesture Recognition Toolkit](https://github.com/nickgillian/grt) (GRT). 4 | 5 | The GRT is a cross-platform, open-source, C++ machine learning library designed for real-time gesture recognition. 6 | 7 | This extension is designed to make it as easy as possible to use the GRT in openFrameworks. 8 | 9 | Note that this extensions contains a local version of the GRT as a git submodule, which will be compiled from source when you build any of the ofxGrt examples. 10 | 11 | To use ofxGrt: 12 | 13 | - download openFrameworks (you will need an OF version that supports C++11, you can find the latest version on the openFrameworks github page) 14 | 15 | - clone this repo to the openFrameworks addons folder 16 | ```sh 17 | cd openFrameworks/addons 18 | git clone https://github.com/nickgillian/ofxGrt 19 | cd ofxGrt 20 | git submodule init 21 | git submodule update 22 | ``` 23 | 24 | - if you are working off any branch of ofxGrt that is not master (e.g., dev), then you can sync with the remote GRT version of that branch via: 25 | ```sh 26 | git submodule update --remote 27 | ``` 28 | 29 | - to build and run any of the ofxGRT examples, cd to an example folder and run: 30 | ```sh 31 | cd ofxGrt/example_timeseries_plot 32 | make 33 | make run 34 | ``` 35 | 36 | You can find additional README files in each of the examples that describe more details about each specific example. 37 | 38 | ## Examples 39 | 40 | See the specific examples directories for a full description on each example. 41 | 42 | [Classification Example](example_classification) 43 | ![alt text](example_classification/images/classification_example_1.png "Classification Example") 44 | 45 | [Regression Example](example_regression) 46 | ![alt text](example_regression/images/regression_step_10.png "Regression Example") 47 | 48 | [Linear Least Squares Example](example_linear_least_squares) 49 | ![alt text](example_linear_least_squares/images/lls_1.png "Linear Least Squares Example") 50 | 51 | [Matrix Plot Example](example_matrix_plot) 52 | ![alt text](example_matrix_plot/images/matrix_plot.png "Matrix Plot Example") 53 | 54 | [Bar Plot Example](example_bar_plot) 55 | ![alt text](example_bar_plot/images/bar_plot.png "Bar Plot Example") 56 | 57 | ## License 58 | The ofxGRT is available under a MIT license. 59 | -------------------------------------------------------------------------------- /addon_config.mk: -------------------------------------------------------------------------------- 1 | # All variables and this file are optional, if they are not present the PG and the 2 | # makefiles will try to parse the correct values from the file system. 3 | # 4 | # Variables that specify exclusions can use % as a wildcard to specify that anything in 5 | # that position will match. A partial path can also be specified to, for example, exclude 6 | # a whole folder from the parsed paths from the file system 7 | # 8 | # Variables can be specified using = or += 9 | # = will clear the contents of that variable both specified from the file or the ones parsed 10 | # from the file system 11 | # += will add the values to the previous ones in the file or the ones parsed from the file 12 | # system 13 | # 14 | # The PG can be used to detect errors in this file, just create a new project with this addon 15 | # and the PG will write to the console the kind of error and in which line it is 16 | 17 | meta: 18 | ADDON_NAME = ofxGrt 19 | ADDON_DESCRIPTION = Addon for Gesture Recognition Toolkit 20 | ADDON_AUTHOR = Nick Gillian 21 | ADDON_TAGS = "GRT" 22 | ADDON_URL = https://github.com/nickgillian/ofxGrt 23 | 24 | common: 25 | ADDON_INCLUDES = src 26 | ADDON_INCLUDES += libs/grt 27 | ADDON_SOURCES_EXCLUDE = libs/grt/build/% 28 | ADDON_SOURCES_EXCLUDE += libs/grt/data/% 29 | ADDON_SOURCES_EXCLUDE += libs/grt/docs/% 30 | ADDON_SOURCES_EXCLUDE += libs/grt/examples/% 31 | ADDON_SOURCES_EXCLUDE += libs/grt/extensions/% 32 | ADDON_SOURCES_EXCLUDE += libs/grt/gui/% 33 | ADDON_SOURCES_EXCLUDE += libs/grt/jni/% 34 | ADDON_SOURCES_EXCLUDE += libs/grt/tests/% 35 | ADDON_SOURCES_EXCLUDE += libs/grt/third_party/% 36 | ADDON_SOURCES_EXCLUDE += libs/grt/tools/% 37 | ADDON_SOURCES_EXCLUDE += libs/grt/website/% 38 | ADDON_SOURCES_EXCLUDE += libs/grt/wiki/% 39 | ADDON_SOURCES_EXCLUDE += libs/grt/website/% 40 | 41 | # Uncomment the lines below to use the system installed GRT headers and libs 42 | # ADDON_INCLUDES += /usr/local/include/GRT 43 | # ADDON_LDFLAGS = -L/usr/local/lib -lgrt 44 | # ADDON_LIBS_EXCLUDE = libs/grt/% 45 | # ADDON_INCLUDES_EXCLUDE = libs/grt/% 46 | # ADDON_SOURCES_EXCLUDE += libs/grt/GRT/% 47 | 48 | 49 | -------------------------------------------------------------------------------- /example_audio_classification/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_audio_classification/README.md: -------------------------------------------------------------------------------- 1 | ##Audio Classification Example 2 | 3 | This example demonstrates how to perform some basic audio classification using an FFT, a spectrogram and a RandomForests classifier. 4 | 5 | ##Building the example 6 | You can build this example on OSX by opening terminal in this directory and running: 7 | 8 | ```` 9 | make -j4 10 | make run 11 | ```` 12 | 13 | This will compile the example using the pre-built GRT static library packaged with the ofxGrt addon. 14 | 15 | If you want to build this example on Linux or want to compile the example against your own version of the GRT (installed in /usr/local/...) then edit the 16 | main **addon_config.mk** file to change the location of the GRT header and library paths. 17 | 18 | ##Using the example 19 | When you run the example, you should see two real-time graphs on the screen. The top graph shows the instantaneous magnitude data from the FFT. The bottom graph shows the spectrogram data (which shows the frequencies from the FFT over time). The input to the classifier consists of the spectrogram data for a small time segment. 20 | 21 | If you make some noises near your microphone you should see the FFT data and spectrogram data change. 22 | 23 | ###Training 24 | You can record some training data for this example by: 25 | 26 | 1. Press a number key (e.g., 1) to set the class label 27 | 2. Press the **r** key to start the recording 28 | 3. Make some noise to represent the current class label (e.g., the first class could just be generic background noise) 29 | 4. Press another number key (e.g., 2) to change the class label and immediately start making noise for the new class (e.g., start humming) 30 | 5. Repeat this for each audio class you want to add 31 | 6. Press the **r** key to stop the recording 32 | 7. Press the **t** key to train a model (this could take several seconds depending on the number of training samples) 33 | 34 | ###Prediction 35 | After training a model, the application will immediately start real-time prediction. You should now see one additional graph on the screen, this shows the class likelihoods for each class in the model. 36 | 37 | If you make the sound for each class, you should hopefully see the class likelihoods change in the lower graph. -------------------------------------------------------------------------------- /example_audio_classification/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_audio_classification/bin/data/heatmap.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D src_tex_unit0; 4 | uniform vec4 globalColor; 5 | in vec2 texCoordVarying; 6 | 7 | out vec4 fragColor; 8 | 9 | vec3 DARK_BLUE = vec3( 30.0, 95.0, 190.0) / 255.0; 10 | vec3 CYAN = vec3( 0.0, 175.0, 240.0) / 255.0; 11 | vec3 GREEN = vec3(0.0, 255.0, 0.0) / 255.0; 12 | vec3 YELLOW = vec3(255.0, 240.0, 0.0) / 255.0; 13 | vec3 RED = vec3(255.0, 0.0, 0.0) / 255.0; 14 | 15 | vec4 getColor(float value){ 16 | if( value<= 0.0 ) 17 | { 18 | return vec4(DARK_BLUE, value); 19 | } 20 | else if( value<0.25 ) 21 | { 22 | return vec4(CYAN, value); 23 | } 24 | else if( value<0.5 ) 25 | { 26 | return vec4(GREEN, value-0.25); 27 | } 28 | else if( value<0.75 ) 29 | { 30 | return vec4(YELLOW, value-0.5); 31 | } 32 | else if( value<1.0) 33 | { 34 | return vec4(RED,value-0.75); 35 | } 36 | else 37 | { 38 | return vec4(RED,1.0); 39 | } 40 | } 41 | 42 | void main(){ 43 | float value = texture(src_tex_unit0, texCoordVarying).r; 44 | vec4 currC = getColor(value); 45 | vec4 prevC = getColor(value-0.25); 46 | fragColor = vec4(mix(prevC.rgb, currC.rgb, currC.a/0.25),1.0); 47 | } -------------------------------------------------------------------------------- /example_audio_classification/bin/data/heatmap.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | uniform mat4 textureMatrix; 6 | uniform mat4 modelViewProjectionMatrix; 7 | uniform vec4 globalColor; 8 | 9 | in vec4 position; 10 | in vec2 texcoord; 11 | in vec4 color; 12 | in vec3 normal; 13 | 14 | out vec4 colorVarying; 15 | out vec2 texCoordVarying; 16 | out vec4 normalVarying; 17 | 18 | void main() 19 | { 20 | texCoordVarying = texcoord; 21 | gl_Position = modelViewProjectionMatrix * position; 22 | } -------------------------------------------------------------------------------- /example_audio_classification/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_audio_classification/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_audio_classification/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_audio_classification/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_audio_classification/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT FFT algorithm to create a spectrogram for audio classification in openFrameworks 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | 10 | //State that we want to use the GRT namespace 11 | using namespace GRT; 12 | 13 | class ofApp : public ofBaseApp{ 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | void keyPressed (int key); 21 | void keyReleased(int key); 22 | void mouseMoved(int x, int y ); 23 | void mouseDragged(int x, int y, int button); 24 | void mousePressed(int x, int y, int button); 25 | void mouseReleased(int x, int y, int button); 26 | void windowResized(int w, int h); 27 | void dragEvent(ofDragInfo dragInfo); 28 | void gotMessage(ofMessage msg); 29 | 30 | void exit(); 31 | void audioIn(float * input, int bufferSize, int nChannels); 32 | 33 | //Create some variables for the demo 34 | GestureRecognitionPipeline pipeline; 35 | ClassificationData trainingData; 36 | VectorFloat fftInputData; 37 | VectorFloat featureVector; 38 | FastFourierTransform fft; 39 | CircularBuffer< VectorFloat > spectrogram; 40 | CircularBuffer< VectorFloat > spectrogramPlotBuffer; 41 | ofxGrtTimeseriesPlot magnitudePlot; 42 | ofxGrtTimeseriesPlot classLikelihoodsPlot; 43 | ofxGrtMatrixPlot spectrogramPlot; 44 | unsigned int trainingClassLabel; 45 | unsigned int sampleCounter; 46 | bool record; 47 | bool processAudio; 48 | string infoText; 49 | ofShader heatmap; 50 | }; 51 | -------------------------------------------------------------------------------- /example_bar_plot/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_bar_plot/README.md: -------------------------------------------------------------------------------- 1 | ##Bar Plot Example 2 | 3 | This example demonstrates the how to use ofxGrt Bar Plot class. 4 | 5 | The example will generate a basic sine wave signal and plot this using the bar plot class. 6 | 7 | ![alt text](images/bar_plot.png "Bar Plot Example") 8 | 9 | ##Building and running the example 10 | On OS X and Linux, you can build this example by running the following command in terminal: 11 | 12 | ```` 13 | cd THIS_DIRECTORY 14 | make -j4 15 | ```` 16 | 17 | To run the example, run the following in terminal: 18 | 19 | ```` 20 | make run 21 | ```` 22 | 23 | ##Using the example 24 | To use this example, simply build and run it. -------------------------------------------------------------------------------- /example_bar_plot/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_bar_plot/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_bar_plot/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_bar_plot/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_bar_plot/images/bar_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_bar_plot/images/bar_plot.png -------------------------------------------------------------------------------- /example_bar_plot/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /example_bar_plot/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "ofApp.h" 3 | 4 | #define NUM_DIMENSIONS 20 5 | 6 | //-------------------------------------------------------------- 7 | void ofApp::setup(){ 8 | ofSetBackgroundColor(255); 9 | 10 | //Load the font for the graph 11 | font.load("verdana.ttf", 12, true, true); 12 | font.setLineHeight(14.0f); 13 | 14 | //Setup the plot 15 | plot1.setup( NUM_DIMENSIONS, "sine data"); 16 | plot1.setRanges( -1.0, 1.0, true ); 17 | } 18 | 19 | 20 | //-------------------------------------------------------------- 21 | void ofApp::update(){ 22 | 23 | //Update the data 24 | vector< float > data( NUM_DIMENSIONS ); 25 | for(unsigned int i=0; i classColors; 42 | ofTexture texture; 43 | int classifierType; 44 | ofTrueTypeFont largeFont; 45 | ofTrueTypeFont smallFont; 46 | 47 | string classifierTypeToString( const int type ){ 48 | switch( type ){ 49 | case ADABOOST: 50 | return "ADABOOST"; 51 | break; 52 | case DECISION_TREE: 53 | return "DECISION_TREE"; 54 | break; 55 | case KKN: 56 | return "KKN"; 57 | break; 58 | case GAUSSIAN_MIXTURE_MODEL: 59 | return "GMM"; 60 | break; 61 | case NAIVE_BAYES: 62 | return "NAIVE_BAYES"; 63 | break; 64 | case MINDIST: 65 | return "MINDIST"; 66 | break; 67 | case RANDOM_FOREST_10: 68 | return "RANDOM_FOREST_10"; 69 | break; 70 | case RANDOM_FOREST_100: 71 | return "RANDOM_FOREST_100"; 72 | break; 73 | case RANDOM_FOREST_200: 74 | return "RANDOM_FOREST_200"; 75 | break; 76 | case SOFTMAX: 77 | return "SOFTMAX"; 78 | break; 79 | case SVM_LINEAR: 80 | return "SVM_LINEAR"; 81 | break; 82 | case SVM_RBF: 83 | return "SVM_RBF"; 84 | break; 85 | } 86 | return "UNKOWN_CLASSIFIER"; 87 | } 88 | 89 | }; 90 | -------------------------------------------------------------------------------- /example_dtw/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_dtw/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_dtw/bin/data/shaders/noise.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D src_tex_unit0; 4 | uniform vec4 globalColor; 5 | in vec2 texCoordVarying; 6 | 7 | out vec4 fragColor; 8 | 9 | vec3 BLUE = vec3( 0.0, 0.0, 255.0) / 255.0; 10 | vec3 GREEN = vec3(0.0, 255.0, 0.0) / 255.0; 11 | vec3 YELLOW = vec3( 255.0, 240.0, 0.0) / 255.0; 12 | vec3 RED = vec3(255.0, 0.0 , 0.0) / 255.0; 13 | 14 | vec4 getColor(float value){ 15 | if(value<0.25){ 16 | return vec4(BLUE, value); 17 | }else if(value<0.5){ 18 | return vec4(GREEN, value-0.25); 19 | }else if(value<0.75){ 20 | return vec4(YELLOW, value-0.5); 21 | }else if(value<1){ 22 | return vec4(RED, value-0.75); 23 | }else{ 24 | return vec4(1.0,1.0,1.0,1.0); 25 | } 26 | } 27 | 28 | 29 | void main(){ 30 | float value = texture(src_tex_unit0, texCoordVarying).r; 31 | vec4 currC = getColor(value); 32 | vec4 prevC = getColor(value-0.25); 33 | fragColor = vec4(mix(prevC.rgb, currC.rgb, currC.a/0.25),1.0); 34 | } -------------------------------------------------------------------------------- /example_dtw/bin/data/shaders/noise.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | uniform mat4 textureMatrix; 6 | uniform mat4 modelViewProjectionMatrix; 7 | uniform vec4 globalColor; 8 | 9 | in vec4 position; 10 | in vec2 texcoord; 11 | in vec4 color; 12 | in vec3 normal; 13 | 14 | out vec4 colorVarying; 15 | out vec2 texCoordVarying; 16 | out vec4 normalVarying; 17 | 18 | void main() 19 | { 20 | texCoordVarying = texcoord; 21 | gl_Position = modelViewProjectionMatrix * position; 22 | } -------------------------------------------------------------------------------- /example_dtw/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_dtw/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_dtw/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_dtw/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_dtw/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT Dynamic Time Warping algorithm in openFrameworks 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | 10 | //State that we want to use the GRT namespace 11 | using namespace GRT; 12 | 13 | class ofApp : public ofBaseApp{ 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | void drawTimeseries(); 21 | void drawTrainingData(); 22 | void drawDistanceMatrix(); 23 | 24 | void keyPressed (int key); 25 | void keyReleased(int key); 26 | void mouseMoved(int x, int y ); 27 | void mouseDragged(int x, int y, int button); 28 | void mousePressed(int x, int y, int button); 29 | void mouseReleased(int x, int y, int button); 30 | void windowResized(int w, int h); 31 | void dragEvent(ofDragInfo dragInfo); 32 | void gotMessage(ofMessage msg); 33 | 34 | //Create some variables for the demo 35 | TimeSeriesClassificationData trainingData; //This will store our training data 36 | MatrixFloat timeseries; //This will store a single training sample 37 | GestureRecognitionPipeline pipeline; //This is a wrapper for our classifier and any pre/post processing modules 38 | bool record; //This is a flag that keeps track of when we should record training data 39 | UINT trainingClassLabel; //This will hold the current label for when we are training the classifier 40 | string infoText; //This string will be used to draw some info messages to the main app window 41 | ofTrueTypeFont font; 42 | ofShader shader; 43 | ofxGrtTimeseriesPlot predictedClassPlot; 44 | ofxGrtTimeseriesPlot classLikelihoodsPlot; 45 | Vector< std::shared_ptr< ofxGrtTimeseriesPlot > > trainingDataPlot; 46 | Vector< ofxGrtMatrixPlot > distanceMatrixPlots; 47 | }; 48 | -------------------------------------------------------------------------------- /example_fft/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_fft/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_fft/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_fft/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_fft/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_fft/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_fft/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | */ 4 | 5 | #include "ofApp.h" 6 | 7 | #define AUDIO_BUFFER_SIZE 512 8 | #define AUDIO_SAMPLE_RATE 44100 9 | #define FFT_WINDOW_SIZE 2048 10 | #define FFT_HOP_SIZE AUDIO_BUFFER_SIZE 11 | 12 | //-------------------------------------------------------------- 13 | void ofApp::setup(){ 14 | 15 | ofSetFrameRate(60); 16 | 17 | fft.init(FFT_WINDOW_SIZE,FFT_HOP_SIZE,1,FFT::RECTANGULAR_WINDOW,true,false); 18 | 19 | magnitudePlot.setup( FFT_WINDOW_SIZE/2, 1 ); 20 | 21 | ofSoundStreamSetup(2, 1, this, AUDIO_SAMPLE_RATE, AUDIO_BUFFER_SIZE, 4); 22 | } 23 | 24 | //-------------------------------------------------------------- 25 | void ofApp::update(){ 26 | 27 | //Grab the current mouse x and y position 28 | VectorDouble sample(2); 29 | 30 | vector< FastFourierTransform > &results = fft.getFFTResultsPtr(); 31 | magnitudePlot.setData( results[0].getMagnitudeData() ); 32 | } 33 | 34 | //-------------------------------------------------------------- 35 | void ofApp::draw(){ 36 | 37 | ofBackground(0, 0, 0); 38 | 39 | float margin = 10; 40 | magnitudePlot.draw( margin, margin, ofGetWidth() - margin*2, 250 ); 41 | 42 | } 43 | 44 | void ofApp::audioIn(float * input, int bufferSize, int nChannels){ 45 | 46 | GRT::VectorDouble data(1); 47 | for (int i=0; i 11 | #include "ofxAssimpModelLoader.h" 12 | 13 | //State that we want to use the GRT namespace 14 | using namespace GRT; 15 | 16 | #define PRE_RECORDING_COUNTDOWN_TIME 4000 17 | #define RECORDING_TIME 5000 18 | 19 | class ofApp : public ofBaseApp{ 20 | 21 | public: 22 | void setup(); 23 | void update(); 24 | void draw(); 25 | 26 | void keyPressed (int key); 27 | void keyReleased(int key); 28 | void mouseMoved(int x, int y ); 29 | void mouseDragged(int x, int y, int button); 30 | void mousePressed(int x, int y, int button); 31 | void mouseReleased(int x, int y, int button); 32 | void windowResized(int w, int h); 33 | void dragEvent(ofDragInfo dragInfo); 34 | void gotMessage(ofMessage msg); 35 | 36 | //Create some variables for the demo 37 | RegressionData trainingData; //This will store our training data 38 | GestureRecognitionPipeline pipeline; //This is a wrapper for our classifier and any pre/post processing modules 39 | bool recordTrainingData; //This is a flag that keeps track of when we should record training data 40 | bool trainingModeActive; 41 | bool predictionModeActive; 42 | bool drawInfo; 43 | VectorFloat rightHand; 44 | string infoText; //This string will be used to draw some info messages to the main app window 45 | ofTrueTypeFont largeFont; 46 | ofTrueTypeFont smallFont; 47 | ofTrueTypeFont hugeFont; 48 | SynapseStreamer synapseStreamer; 49 | ofxGrtTimeseriesPlot rightHandPlot; 50 | ofxGrtTimeseriesPlot featurePlot; 51 | ofxGrtTimeseriesPlot predictionPlot; 52 | Timer trainingTimer; 53 | float mappingParameter1; 54 | float mappingParameter2; 55 | 56 | ofSoundPlayer track1; 57 | ofSoundPlayer track2; 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /example_kinect_posture_classification/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_kinect_posture_classification/README.md: -------------------------------------------------------------------------------- 1 | ##Gyrosc Orientation Example 2 | 3 | This example interfaces with [gyrosc](http://www.bitshapesoftware.com/instruments/gyrosc), an application that sends sensor data from your iPhone, iPod Touch, or iPad's motion sensors over your local wireless network to this openFrameworks application via the [OSC](http://opensoundcontrol.org/introduction-osc) protocol. 4 | 5 | This example is setup for orientation classification (i.e., detecting which orientation the phone is currently held in), using the **gravity** data from the gyrosc data stream and a GRT Naive Bayes classifier. 6 | 7 | ##Building and running the example 8 | On OS X and Linux, you can build this example by running the following command in terminal: 9 | 10 | ```` 11 | cd THIS_DIRECTORY 12 | make -j4 13 | ```` 14 | 15 | To run the example, run the following in terminal: 16 | 17 | ```` 18 | make run 19 | ```` 20 | 21 | ##Using the example 22 | Download and install the [gyrosc](http://www.bitshapesoftware.com/instruments/gyrosc) app on your iOS device. Set the IP address in the gyrosc app to that of your computer and set the receiving port number to 5000 (both your host machine and iOS device need to be on the same wireless network). 23 | 24 | When you start this example, you should see the graphs on the screen change as you move your iOS device (if not, then check the network settings, IP and port values all match). 25 | 26 | To record a training example, simply orientate your iOS device in a specific orientation (e.g., screen facing up), then press the **r** key to start recording some training examples for that class (the class should default to 1 when you start the example). Move your phone around for a few seconds to add some variation to the orientation, then press the **r** key again to stop the recording. 27 | 28 | Press the **2** number key to switch the class label to 2, move your iOS device to a new orientation (e.g., screen facing down), and press the **r** key again to record some training data for class 2. Move your phone around for a few seconds to add some variation to the orientation, then press the **r** key again to stop the recording. 29 | 30 | Repeat this again for class **3**, holding the phone in a new orientation. 31 | 32 | When you have recorded training data for each class (a few hundred training samples per class should be enough), press the **t** key to train a Naive Bayes classification model. 33 | 34 | After the model has been trained, realtime classification should immediately start and a new graph should appear that shows the real-time probabilities for detecting each class (i.e, orientation). If you trained 3 classes, then the graph colors should represent: 35 | - red: class 1 36 | - green: class 2 37 | - blue: class 3 38 | 39 | As you move your phone around the various orientations, you should see the class probabilities change (with the most likely class being the value closest to 1.0). -------------------------------------------------------------------------------- /example_kinect_posture_classification/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | ofxOsc 3 | -------------------------------------------------------------------------------- /example_kinect_posture_classification/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_classification/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_kinect_posture_classification/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_kinect_posture_classification/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT ANBC algorithm in openFrameworks. See the README file for more info. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | #include "SynapseStreamer.h" 10 | #include 11 | 12 | //State that we want to use the GRT namespace 13 | using namespace GRT; 14 | 15 | #define PRE_RECORDING_COUNTDOWN_TIME 2000 16 | #define RECORDING_TIME 5000 17 | 18 | class ofApp : public ofBaseApp{ 19 | 20 | public: 21 | void setup(); 22 | void update(); 23 | void draw(); 24 | 25 | void keyPressed (int key); 26 | void keyReleased(int key); 27 | void mouseMoved(int x, int y ); 28 | void mouseDragged(int x, int y, int button); 29 | void mousePressed(int x, int y, int button); 30 | void mouseReleased(int x, int y, int button); 31 | void windowResized(int w, int h); 32 | void dragEvent(ofDragInfo dragInfo); 33 | void gotMessage(ofMessage msg); 34 | 35 | //Create some variables for the demo 36 | ClassificationData trainingData; //This will store our training data 37 | GestureRecognitionPipeline pipeline; //This is a wrapper for our classifier and any pre/post processing modules 38 | bool recordTrainingData; //This is a flag that keeps track of when we should record training data 39 | bool trainingModeActive; 40 | bool predictionModeActive; 41 | bool drawInfo; 42 | VectorFloat leftHand; 43 | VectorFloat rightHand; 44 | UINT trainingClassLabel; //This will hold the current label for when we are training the classifier 45 | UINT predictedClassLabel; 46 | string infoText; //This string will be used to draw some info messages to the main app window 47 | ofTrueTypeFont largeFont; 48 | ofTrueTypeFont smallFont; 49 | ofTrueTypeFont hugeFont; 50 | SynapseStreamer synapseStreamer; 51 | ofxGrtTimeseriesPlot leftHandPlot; 52 | ofxGrtTimeseriesPlot rightHandPlot; 53 | ofxGrtTimeseriesPlot predictionPlot; 54 | Timer trainingTimer; 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/README.md: -------------------------------------------------------------------------------- 1 | ##Gyrosc Orientation Example 2 | 3 | This example interfaces with [gyrosc](http://www.bitshapesoftware.com/instruments/gyrosc), an application that sends sensor data from your iPhone, iPod Touch, or iPad's motion sensors over your local wireless network to this openFrameworks application via the [OSC](http://opensoundcontrol.org/introduction-osc) protocol. 4 | 5 | This example is setup for orientation classification (i.e., detecting which orientation the phone is currently held in), using the **gravity** data from the gyrosc data stream and a GRT Naive Bayes classifier. 6 | 7 | ##Building and running the example 8 | On OS X and Linux, you can build this example by running the following command in terminal: 9 | 10 | ```` 11 | cd THIS_DIRECTORY 12 | make -j4 13 | ```` 14 | 15 | To run the example, run the following in terminal: 16 | 17 | ```` 18 | make run 19 | ```` 20 | 21 | ##Using the example 22 | Download and install the [gyrosc](http://www.bitshapesoftware.com/instruments/gyrosc) app on your iOS device. Set the IP address in the gyrosc app to that of your computer and set the receiving port number to 5000 (both your host machine and iOS device need to be on the same wireless network). 23 | 24 | When you start this example, you should see the graphs on the screen change as you move your iOS device (if not, then check the network settings, IP and port values all match). 25 | 26 | To record a training example, simply orientate your iOS device in a specific orientation (e.g., screen facing up), then press the **r** key to start recording some training examples for that class (the class should default to 1 when you start the example). Move your phone around for a few seconds to add some variation to the orientation, then press the **r** key again to stop the recording. 27 | 28 | Press the **2** number key to switch the class label to 2, move your iOS device to a new orientation (e.g., screen facing down), and press the **r** key again to record some training data for class 2. Move your phone around for a few seconds to add some variation to the orientation, then press the **r** key again to stop the recording. 29 | 30 | Repeat this again for class **3**, holding the phone in a new orientation. 31 | 32 | When you have recorded training data for each class (a few hundred training samples per class should be enough), press the **t** key to train a Naive Bayes classification model. 33 | 34 | After the model has been trained, realtime classification should immediately start and a new graph should appear that shows the real-time probabilities for detecting each class (i.e, orientation). If you trained 3 classes, then the graph colors should represent: 35 | - red: class 1 36 | - green: class 2 37 | - blue: class 3 38 | 39 | As you move your phone around the various orientations, you should see the class probabilities change (with the most likely class being the value closest to 1.0). -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | ofxOsc 3 | ofxAssimpModelLoader 4 | -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/bin/data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_multidimensional_regression/bin/data/.DS_Store -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/bin/data/model/Feisar_Ship.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_multidimensional_regression/bin/data/model/Feisar_Ship.3ds -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/bin/data/model/diffuse.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_multidimensional_regression/bin/data/model/diffuse.bmp -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/bin/data/model/specular.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_multidimensional_regression/bin/data/model/specular.bmp -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_multidimensional_regression/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_multidimensional_regression/src/.DS_Store -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp( new ofApp()); 12 | } -------------------------------------------------------------------------------- /example_kinect_posture_multidimensional_regression/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT ANBC algorithm in openFrameworks. See the README file for more info. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | #include "SynapseStreamer.h" 10 | #include 11 | #include "ofxAssimpModelLoader.h" 12 | 13 | //State that we want to use the GRT namespace 14 | using namespace GRT; 15 | 16 | #define PRE_RECORDING_COUNTDOWN_TIME 2000 17 | #define RECORDING_TIME 5000 18 | 19 | class ofApp : public ofBaseApp{ 20 | 21 | public: 22 | void setup(); 23 | void update(); 24 | void draw(); 25 | 26 | void keyPressed (int key); 27 | void keyReleased(int key); 28 | void mouseMoved(int x, int y ); 29 | void mouseDragged(int x, int y, int button); 30 | void mousePressed(int x, int y, int button); 31 | void mouseReleased(int x, int y, int button); 32 | void windowResized(int w, int h); 33 | void dragEvent(ofDragInfo dragInfo); 34 | void gotMessage(ofMessage msg); 35 | 36 | //Create some variables for the demo 37 | RegressionData trainingData; //This will store our training data 38 | GestureRecognitionPipeline pipeline; //This is a wrapper for our classifier and any pre/post processing modules 39 | bool recordTrainingData; //This is a flag that keeps track of when we should record training data 40 | bool trainingModeActive; 41 | bool predictionModeActive; 42 | bool drawInfo; 43 | VectorFloat leftHand; 44 | VectorFloat rightHand; 45 | string infoText; //This string will be used to draw some info messages to the main app window 46 | ofTrueTypeFont largeFont; 47 | ofTrueTypeFont smallFont; 48 | ofTrueTypeFont hugeFont; 49 | SynapseStreamer synapseStreamer; 50 | ofxGrtTimeseriesPlot leftHandPlot; 51 | ofxGrtTimeseriesPlot rightHandPlot; 52 | ofxGrtTimeseriesPlot predictionPlot; 53 | Timer trainingTimer; 54 | //ofx3DModelLoader spacecraft; 55 | ofxAssimpModelLoader spacecraft; 56 | float rollRotationAngle; 57 | float pitchRotationAngle; 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /example_kinect_posture_regression/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_kinect_posture_regression/README.md: -------------------------------------------------------------------------------- 1 | ##Gyrosc Orientation Example 2 | 3 | This example interfaces with [gyrosc](http://www.bitshapesoftware.com/instruments/gyrosc), an application that sends sensor data from your iPhone, iPod Touch, or iPad's motion sensors over your local wireless network to this openFrameworks application via the [OSC](http://opensoundcontrol.org/introduction-osc) protocol. 4 | 5 | This example is setup for orientation classification (i.e., detecting which orientation the phone is currently held in), using the **gravity** data from the gyrosc data stream and a GRT Naive Bayes classifier. 6 | 7 | ##Building and running the example 8 | On OS X and Linux, you can build this example by running the following command in terminal: 9 | 10 | ```` 11 | cd THIS_DIRECTORY 12 | make -j4 13 | ```` 14 | 15 | To run the example, run the following in terminal: 16 | 17 | ```` 18 | make run 19 | ```` 20 | 21 | ##Using the example 22 | Download and install the [gyrosc](http://www.bitshapesoftware.com/instruments/gyrosc) app on your iOS device. Set the IP address in the gyrosc app to that of your computer and set the receiving port number to 5000 (both your host machine and iOS device need to be on the same wireless network). 23 | 24 | When you start this example, you should see the graphs on the screen change as you move your iOS device (if not, then check the network settings, IP and port values all match). 25 | 26 | To record a training example, simply orientate your iOS device in a specific orientation (e.g., screen facing up), then press the **r** key to start recording some training examples for that class (the class should default to 1 when you start the example). Move your phone around for a few seconds to add some variation to the orientation, then press the **r** key again to stop the recording. 27 | 28 | Press the **2** number key to switch the class label to 2, move your iOS device to a new orientation (e.g., screen facing down), and press the **r** key again to record some training data for class 2. Move your phone around for a few seconds to add some variation to the orientation, then press the **r** key again to stop the recording. 29 | 30 | Repeat this again for class **3**, holding the phone in a new orientation. 31 | 32 | When you have recorded training data for each class (a few hundred training samples per class should be enough), press the **t** key to train a Naive Bayes classification model. 33 | 34 | After the model has been trained, realtime classification should immediately start and a new graph should appear that shows the real-time probabilities for detecting each class (i.e, orientation). If you trained 3 classes, then the graph colors should represent: 35 | - red: class 1 36 | - green: class 2 37 | - blue: class 3 38 | 39 | As you move your phone around the various orientations, you should see the class probabilities change (with the most likely class being the value closest to 1.0). -------------------------------------------------------------------------------- /example_kinect_posture_regression/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | ofxOsc 3 | ofxAssimpModelLoader 4 | -------------------------------------------------------------------------------- /example_kinect_posture_regression/bin/data/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_regression/bin/data/.DS_Store -------------------------------------------------------------------------------- /example_kinect_posture_regression/bin/data/model/Feisar_Ship.3ds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_regression/bin/data/model/Feisar_Ship.3ds -------------------------------------------------------------------------------- /example_kinect_posture_regression/bin/data/model/diffuse.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_regression/bin/data/model/diffuse.bmp -------------------------------------------------------------------------------- /example_kinect_posture_regression/bin/data/model/specular.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_regression/bin/data/model/specular.bmp -------------------------------------------------------------------------------- /example_kinect_posture_regression/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_regression/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_kinect_posture_regression/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_kinect_posture_regression/src/.DS_Store -------------------------------------------------------------------------------- /example_kinect_posture_regression/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768, OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp( new ofApp()); 12 | } -------------------------------------------------------------------------------- /example_kinect_posture_regression/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT ANBC algorithm in openFrameworks. See the README file for more info. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | #include "SynapseStreamer.h" 10 | #include 11 | #include "ofxAssimpModelLoader.h" 12 | 13 | //State that we want to use the GRT namespace 14 | using namespace GRT; 15 | 16 | #define PRE_RECORDING_COUNTDOWN_TIME 2000 17 | #define RECORDING_TIME 5000 18 | 19 | class ofApp : public ofBaseApp{ 20 | 21 | public: 22 | void setup(); 23 | void update(); 24 | void draw(); 25 | 26 | void keyPressed (int key); 27 | void keyReleased(int key); 28 | void mouseMoved(int x, int y ); 29 | void mouseDragged(int x, int y, int button); 30 | void mousePressed(int x, int y, int button); 31 | void mouseReleased(int x, int y, int button); 32 | void windowResized(int w, int h); 33 | void dragEvent(ofDragInfo dragInfo); 34 | void gotMessage(ofMessage msg); 35 | 36 | //Create some variables for the demo 37 | RegressionData trainingData; //This will store our training data 38 | GestureRecognitionPipeline pipeline; //This is a wrapper for our classifier and any pre/post processing modules 39 | bool recordTrainingData; //This is a flag that keeps track of when we should record training data 40 | bool trainingModeActive; 41 | bool predictionModeActive; 42 | bool drawInfo; 43 | VectorFloat leftHand; 44 | VectorFloat rightHand; 45 | string infoText; //This string will be used to draw some info messages to the main app window 46 | ofTrueTypeFont largeFont; 47 | ofTrueTypeFont smallFont; 48 | ofTrueTypeFont hugeFont; 49 | SynapseStreamer synapseStreamer; 50 | ofxGrtTimeseriesPlot leftHandPlot; 51 | ofxGrtTimeseriesPlot rightHandPlot; 52 | ofxGrtTimeseriesPlot predictionPlot; 53 | Timer trainingTimer; 54 | //ofx3DModelLoader spacecraft; 55 | ofxAssimpModelLoader spacecraft; 56 | float rollRotationAngle; 57 | float pitchRotationAngle; 58 | 59 | }; 60 | -------------------------------------------------------------------------------- /example_linear_least_squares/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_linear_least_squares/README.md: -------------------------------------------------------------------------------- 1 | ##Linear Least Squares Example 2 | 3 | This example demonstrates the how to use GRT Linear Least Squares algorithms. 4 | 5 | The example will generate a basic linear dataset (using a linear trend plus some random noise) and fit a straight line to this dataset using the LinearLeastSquares algorithm. 6 | 7 | The image below shows the random data points (in blue) and the estimated line fit to the dataset (in red). 8 | 9 | ![alt text](images/lls_1.png "Linear Least Squares Example") 10 | 11 | ##Building and running the example 12 | On OS X and Linux, you can build this example by running the following command in terminal: 13 | 14 | ```` 15 | cd THIS_DIRECTORY 16 | make -j4 17 | ```` 18 | 19 | To run the example, run the following in terminal: 20 | 21 | ```` 22 | make run 23 | ```` 24 | 25 | ##Using the example 26 | To use this example, simply build and run it. -------------------------------------------------------------------------------- /example_linear_least_squares/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_linear_least_squares/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_linear_least_squares/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_linear_least_squares/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_linear_least_squares/images/lls_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_linear_least_squares/images/lls_1.png -------------------------------------------------------------------------------- /example_linear_least_squares/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_linear_least_squares/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | See the README file for more info. 3 | */ 4 | 5 | #include "ofApp.h" 6 | #define NUM_POINTS 50 7 | 8 | //-------------------------------------------------------------- 9 | void ofApp::setup(){ 10 | 11 | ofSetFrameRate(60); 12 | 13 | largeFont.load("verdana.ttf", 12, true, true); 14 | largeFont.setLineHeight(14.0f); 15 | smallFont.load("verdana.ttf", 10, true, true); 16 | smallFont.setLineHeight(12.0f); 17 | 18 | //Initialize the training and info variables 19 | infoText = ""; 20 | drawInfo = true; 21 | 22 | Random random; 23 | float norm = 1.0/NUM_POINTS; 24 | float xNoise = 0.01; 25 | float yNoise = 0.1; 26 | for(UINT i=0; i classColors; 35 | ofTrueTypeFont largeFont; 36 | ofTrueTypeFont smallFont; 37 | 38 | LinearLeastSquares lls; 39 | VectorFloat x; 40 | VectorFloat y; 41 | }; 42 | -------------------------------------------------------------------------------- /example_matrix_plot/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_matrix_plot/README.md: -------------------------------------------------------------------------------- 1 | ##Matrix Plot Example 2 | 3 | This example demonstrates the how to use ofxGrt Matrix Plot class. 4 | 5 | The example will generate three matrices, and plot them with the default grayscale plot and using a heatmap texture. 6 | 7 | ![alt text](images/matrix_plot.png "Matrix Plot Example") 8 | 9 | ##Building and running the example 10 | On OS X and Linux, you can build this example by running the following command in terminal: 11 | 12 | ```` 13 | cd THIS_DIRECTORY 14 | make -j4 15 | ```` 16 | 17 | To run the example, run the following in terminal: 18 | 19 | ```` 20 | make run 21 | ```` 22 | 23 | ##Using the example 24 | To use this example, simply build and run it. -------------------------------------------------------------------------------- /example_matrix_plot/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_matrix_plot/bin/data/heatmap.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D src_tex_unit0; 4 | uniform vec4 globalColor; 5 | in vec2 texCoordVarying; 6 | 7 | out vec4 fragColor; 8 | 9 | vec3 DARK_BLUE = vec3( 30.0, 95.0, 190.0) / 255.0; 10 | vec3 CYAN = vec3( 0.0, 175.0, 240.0) / 255.0; 11 | vec3 GREEN = vec3(0.0, 255.0, 0.0) / 255.0; 12 | vec3 YELLOW = vec3(255.0, 240.0, 0.0) / 255.0; 13 | vec3 RED = vec3(255.0, 0.0, 0.0) / 255.0; 14 | 15 | vec4 getColor(float value){ 16 | if( value<= 0.0 ) 17 | { 18 | return vec4(DARK_BLUE, value); 19 | } 20 | else if( value<0.25 ) 21 | { 22 | return vec4(CYAN, value); 23 | } 24 | else if( value<0.5 ) 25 | { 26 | return vec4(GREEN, value-0.25); 27 | } 28 | else if( value<0.75 ) 29 | { 30 | return vec4(YELLOW, value-0.5); 31 | } 32 | else if( value<1.0) 33 | { 34 | return vec4(RED,value-0.75); 35 | } 36 | else 37 | { 38 | return vec4(RED,1.0); 39 | } 40 | } 41 | 42 | void main(){ 43 | float value = texture(src_tex_unit0, texCoordVarying).r; 44 | vec4 currC = getColor(value); 45 | vec4 prevC = getColor(value-0.25); 46 | fragColor = vec4(mix(prevC.rgb, currC.rgb, currC.a/0.25),1.0); 47 | } -------------------------------------------------------------------------------- /example_matrix_plot/bin/data/heatmap.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform mat4 projectionMatrix; 4 | uniform mat4 modelViewMatrix; 5 | uniform mat4 textureMatrix; 6 | uniform mat4 modelViewProjectionMatrix; 7 | uniform vec4 globalColor; 8 | 9 | in vec4 position; 10 | in vec2 texcoord; 11 | in vec4 color; 12 | in vec3 normal; 13 | 14 | out vec4 colorVarying; 15 | out vec2 texCoordVarying; 16 | out vec4 normalVarying; 17 | 18 | void main() 19 | { 20 | texCoordVarying = texcoord; 21 | gl_Position = modelViewProjectionMatrix * position; 22 | } -------------------------------------------------------------------------------- /example_matrix_plot/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_matrix_plot/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_matrix_plot/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_matrix_plot/images/matrix_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_matrix_plot/images/matrix_plot.png -------------------------------------------------------------------------------- /example_matrix_plot/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = true; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /example_matrix_plot/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "ofApp.h" 3 | 4 | #define TIMESERIES_LENGTH 200 5 | #define NUM_DIMENSIONS 2 6 | float lastX = 0; 7 | float lastY = 0; 8 | float lastTic = 0; 9 | 10 | //-------------------------------------------------------------- 11 | void ofApp::setup(){ 12 | ofSetBackgroundColor(255); 13 | 14 | //Load the font for the graph 15 | font.load("verdana.ttf", 12, true, true); 16 | font.setLineHeight(14.0f); 17 | heatmap.load("heatmap"); 18 | 19 | //Set the font and text for each plot 20 | plot1.setFont( &font, ofColor( 255, 255, 255 ) ); 21 | plot1.setTitle( "plot 1" ); 22 | plot2.setFont( &font, ofColor( 255, 255, 255 ) ); 23 | plot2.setTitle( "plot 2" ); 24 | plot3.setFont( &font, ofColor( 255, 255, 255 ) ); 25 | plot3.setTitle( "plot 3" ); 26 | 27 | //Setup the first matrix, this will plot a sigmoid function 28 | { 29 | const unsigned int numRows = 250; 30 | const unsigned int numCols = 100; 31 | const float cx = numRows * 0.2f; 32 | const float cy = numCols * 0.5f; 33 | const float sigma = 10.0f; 34 | Matrix mat( numRows, numCols ); 35 | for(unsigned int i=0; i mat( numRows, numCols ); 48 | for(unsigned int i=0; i mat( numRows, numCols ); 61 | for(unsigned int i=0; i plots; 86 | plots.push_back( &plot1 ); 87 | plots.push_back( &plot2 ); 88 | plots.push_back( &plot3 ); 89 | 90 | //Draw the matrices 91 | for(auto mat : plots){ 92 | ofSetColor(255,255,255); 93 | ofFill(); 94 | plotW = mat->getWidth() * zoom; 95 | plotH = mat->getHeight() * zoom; 96 | mat->draw( plotX, plotY, plotW, plotH ); 97 | plotX += spacer + plotW; 98 | } 99 | 100 | //Draw the same matrices but with the shader 101 | for(auto mat : plots){ 102 | ofSetColor(255,255,255); 103 | ofFill(); 104 | plotW = mat->getWidth() * zoom; 105 | plotH = mat->getHeight() * zoom; 106 | mat->draw( plotX, plotY, plotW, plotH, heatmap ); 107 | plotX += spacer + plotW; 108 | } 109 | } 110 | 111 | //-------------------------------------------------------------- 112 | void ofApp::keyPressed(int key){ 113 | 114 | switch(key){ 115 | case 'q': 116 | { 117 | ofImage img; 118 | img.grabScreen(0, 0 , ofGetWidth(), ofGetHeight()); 119 | img.save( ofToDataPath( "screenshot_" + Util::timeAsString() + ".png") ); 120 | } 121 | break; 122 | } 123 | 124 | } 125 | 126 | //-------------------------------------------------------------- 127 | void ofApp::keyReleased(int key){ 128 | 129 | } 130 | 131 | //-------------------------------------------------------------- 132 | void ofApp::mouseMoved(int x, int y ){ 133 | 134 | } 135 | 136 | //-------------------------------------------------------------- 137 | void ofApp::mouseDragged(int x, int y, int button){ 138 | 139 | } 140 | 141 | //-------------------------------------------------------------- 142 | void ofApp::mousePressed(int x, int y, int button){ 143 | 144 | } 145 | 146 | //-------------------------------------------------------------- 147 | void ofApp::mouseReleased(int x, int y, int button){ 148 | 149 | } 150 | 151 | //-------------------------------------------------------------- 152 | void ofApp::mouseEntered(int x, int y){ 153 | 154 | } 155 | 156 | //-------------------------------------------------------------- 157 | void ofApp::mouseExited(int x, int y){ 158 | 159 | } 160 | 161 | //-------------------------------------------------------------- 162 | void ofApp::windowResized(int w, int h){ 163 | } 164 | 165 | //-------------------------------------------------------------- 166 | void ofApp::gotMessage(ofMessage msg){ 167 | 168 | } 169 | 170 | //-------------------------------------------------------------- 171 | void ofApp::dragEvent(ofDragInfo dragInfo){ 172 | 173 | } 174 | -------------------------------------------------------------------------------- /example_matrix_plot/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief ofxGrtTimeseriesPlot Example: this example demonstrates how to use the TimeseriesPlot class to plot mouse data over time 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ofMain.h" 9 | #include "ofxGrt.h" 10 | 11 | using namespace GRT; 12 | 13 | class ofApp : public ofBaseApp{ 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | void keyPressed(int key); 21 | void keyReleased(int key); 22 | void mouseMoved(int x, int y ); 23 | void mouseDragged(int x, int y, int button); 24 | void mousePressed(int x, int y, int button); 25 | void mouseReleased(int x, int y, int button); 26 | void mouseEntered(int x, int y); 27 | void mouseExited(int x, int y); 28 | void windowResized(int w, int h); 29 | void dragEvent(ofDragInfo dragInfo); 30 | void gotMessage(ofMessage msg); 31 | 32 | float gauss(float x,float mu,float sigma){ 33 | return exp( -SQR(x-mu)/(2.0*SQR(sigma)) ); 34 | } 35 | 36 | ofTrueTypeFont font; 37 | ofxGrtMatrixPlot plot1; 38 | ofxGrtMatrixPlot plot2; 39 | ofxGrtMatrixPlot plot3; 40 | ofShader heatmap; 41 | }; 42 | -------------------------------------------------------------------------------- /example_mlp_learn/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_mlp_learn/README.md: -------------------------------------------------------------------------------- 1 | ##MLP Learn Example 2 | 3 | This example demonstrates the main GRT Multilayer Perceptron Neural Network algorithm. 4 | 5 | -------------------------------------------------------------------------------- /example_mlp_learn/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_mlp_learn/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_mlp_learn/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_mlp_learn/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_mlp_learn/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_mlp_learn/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT regression algorithms in openFrameworks. See the README file for more info. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | 10 | //State that we want to use the GRT namespace 11 | using namespace GRT; 12 | 13 | class ofApp : public ofBaseApp{ 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | void keyPressed (int key); 21 | void keyReleased(int key); 22 | void mouseMoved(int x, int y ); 23 | void mouseDragged(int x, int y, int button); 24 | void mousePressed(int x, int y, int button); 25 | void mouseReleased(int x, int y, int button); 26 | void windowResized(int w, int h); 27 | void dragEvent(ofDragInfo dragInfo); 28 | void gotMessage(ofMessage msg); 29 | 30 | //Create some variables for the demo 31 | RegressionData trainingData; //This will store our training data 32 | GestureRecognitionPipeline pipeline; //This is a wrapper for our regression and any pre/post processing modules 33 | bool record; //This is a flag that keeps track of when we should record training data 34 | bool drawInfo; 35 | GRT::VectorFloat targetVector; //This will hold the current label for when we are training the classifier 36 | string infoText; //This string will be used to draw some info messages to the main app window 37 | ofTexture texture; 38 | ofTrueTypeFont largeFont; 39 | ofTrueTypeFont smallFont; 40 | 41 | }; 42 | -------------------------------------------------------------------------------- /example_regression/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example_regression/addons.make: -------------------------------------------------------------------------------- 1 | ofxGrt 2 | -------------------------------------------------------------------------------- /example_regression/bin/data/TrainingData.grt: -------------------------------------------------------------------------------- 1 | GRT_LABELLED_REGRESSION_DATA_FILE_V1.0 2 | DatasetName: NOT_SET 3 | InfoText: 4 | NumInputDimensions: 2 5 | NumTargetDimensions: 1 6 | TotalNumTrainingExamples: 222 7 | UseExternalRanges: 0 8 | RegressionData: 9 | 0.491406 0.3375 0.5 10 | 0.461719 0.355556 0.5 11 | 0.476562 0.390278 0.5 12 | 0.514062 0.448611 0.5 13 | 0.474219 0.425 0.5 14 | 0.513281 0.376389 0.5 15 | 0.492969 0.311111 0.5 16 | 0.482031 0.365278 0.5 17 | 0.446875 0.429167 0.5 18 | 0.4375 0.433333 0.5 19 | 0.495312 0.436111 0.5 20 | 0.502344 0.391667 0.5 21 | 0.447656 0.404167 0.5 22 | 0.435156 0.380556 0.5 23 | 0.477344 0.452778 0.5 24 | 0.445312 0.4625 0.5 25 | 0.510938 0.445833 0.5 26 | 0.516406 0.365278 0.5 27 | 0.484375 0.330556 0.5 28 | 0.448437 0.345833 0.5 29 | 0.483594 0.416667 0.5 30 | 0.439063 0.473611 0.5 31 | 0.429688 0.419444 0.5 32 | 0.46875 0.402778 0.5 33 | 0.491406 0.379167 0.5 34 | 0.516406 0.318056 0.5 35 | 0.46875 0.327778 0.5 36 | 0.441406 0.386111 0.5 37 | 0.486719 0.431944 0.5 38 | 0.516406 0.368056 0.5 39 | 0.471094 0.377778 0.5 40 | 0.450781 0.426389 0.5 41 | 0.446094 0.420833 0.5 42 | 0.528906 0.4 0.5 43 | 0.482031 0.354167 0.5 44 | 0.467187 0.420833 0.5 45 | 0.427344 0.438889 0.5 46 | 0.485156 0.430556 0.5 47 | 0.501563 0.404167 0.5 48 | 0.45625 0.416667 0.5 49 | 0.447656 0.372222 0.5 50 | 0.49375 0.361111 0.5 51 | 0.521094 0.425 0.5 52 | 0.466406 0.434722 0.5 53 | 0.452344 0.419444 0.5 54 | 0.455469 0.347222 0.5 55 | 0.516406 0.366667 0.5 56 | 0.467187 0.416667 0.5 57 | 0.420312 0.413889 0.5 58 | 0.436719 0.365278 0.5 59 | 0.461719 0.297222 0.5 60 | 0.440625 0.322222 0.5 61 | 0.434375 0.409722 0.5 62 | 0.449219 0.472222 0.5 63 | 0.478906 0.465278 0.5 64 | 0.515625 0.456944 0.5 65 | 0.541406 0.411111 0.5 66 | 0.514062 0.35 0.5 67 | 0.492969 0.315278 0.5 68 | 0.457031 0.306944 0.5 69 | 0.411719 0.388889 0.5 70 | 0.436719 0.481944 0.5 71 | 0.484375 0.484722 0.5 72 | 0.4875 0.448611 0.5 73 | 0.514062 0.409722 0.5 74 | 0.51875 0.343056 0.5 75 | 0.490625 0.330556 0.5 76 | 0.460938 0.373611 0.5 77 | 0.464062 0.422222 0.5 78 | 0.471875 0.472222 0.5 79 | 0.514844 0.434722 0.5 80 | 0.522656 0.356944 0.5 81 | 0.496094 0.301389 0.5 82 | 0.472656 0.331944 0.5 83 | 0.521094 0.368056 0.5 84 | 0.473438 0.408333 0.5 85 | 0.433594 0.408333 0.5 86 | 0.425781 0.375 0.5 87 | 0.453906 0.356944 0.5 88 | 0.454688 0.386111 0.5 89 | 0.467187 0.390278 0.5 90 | 0.479687 0.3875 0.5 91 | 0.500781 0.413889 0.5 92 | 0.476562 0.431944 0.5 93 | 0.439063 0.451389 0.5 94 | 0.438281 0.391667 0.5 95 | 0.0382813 0.95 0 96 | 0.0796875 0.916667 0 97 | 0.075 0.883333 0 98 | 0.0523438 0.958333 0 99 | 0.053125 0.986111 0 100 | 0.0460938 0.958333 0 101 | 0.075 0.9125 0 102 | 0.0515625 0.865278 0 103 | 0.065625 0.915278 0 104 | 0.0703125 0.938889 0 105 | 0.103906 0.918056 0 106 | 0.0914062 0.872222 0 107 | 0.0695313 0.8875 0 108 | 0.096875 0.959722 0 109 | 0.121094 0.965278 0 110 | 0.114062 0.940278 0 111 | 0.0789062 0.948611 0 112 | 0.109375 0.855556 0 113 | 0.0453125 0.852778 0 114 | 0.0609375 0.943056 0 115 | 0.0984375 0.963889 0 116 | 0.107031 0.961111 0 117 | 0.1 0.9 0 118 | 0.0765625 0.845833 0 119 | 0.0804688 0.844444 0 120 | 0.113281 0.920833 0 121 | 0.0625 0.936111 0 122 | 0.0421875 0.920833 0 123 | 0.0398437 0.901389 0 124 | 0.0664062 0.8625 0 125 | 0.125 0.8625 0 126 | 0.130469 0.961111 0 127 | 0.0875 0.980556 0 128 | 0.107031 0.926389 0 129 | 0.123438 0.881944 0 130 | 0.065625 0.870833 0 131 | 0.0859375 0.963889 0 132 | 0.107813 0.941667 0 133 | 0.065625 0.95 0 134 | 0.0539063 0.906944 0 135 | 0.05 0.883333 0 136 | 0.0898438 0.848611 0 137 | 0.090625 0.836111 0 138 | 0.096875 0.894444 0 139 | 0.065625 0.938889 0 140 | 0.0617188 0.908333 0 141 | 0.125 0.855556 0 142 | 0.0710937 0.854167 0 143 | 0.107813 0.9375 0 144 | 0.0851563 0.954167 0 145 | 0.0914062 0.927778 0 146 | 0.090625 0.915278 0 147 | 0.0648438 0.945833 0 148 | 0.0882813 0.9625 0 149 | 0.125 0.916667 0 150 | 0.108594 0.872222 0 151 | 0.084375 0.844444 0 152 | 0.0546875 0.843056 0 153 | 0.0328125 0.906944 0 154 | 0.0523438 0.956944 0 155 | 0.075 0.961111 0 156 | 0.107813 0.943056 0 157 | 0.136719 0.886111 0 158 | 0.115625 0.854167 0 159 | 0.0765625 0.840278 0 160 | 0.065625 0.890278 0 161 | 0.0820312 0.934722 0 162 | 0.935156 0.8875 1 163 | 0.951562 0.833333 1 164 | 0.925 0.826389 1 165 | 0.946875 0.927778 1 166 | 0.908594 0.888889 1 167 | 0.9375 0.876389 1 168 | 0.900781 0.938889 1 169 | 0.9 0.876389 1 170 | 0.922656 0.859722 1 171 | 0.930469 0.884722 1 172 | 0.9125 0.931944 1 173 | 0.948438 0.909722 1 174 | 0.948438 0.8125 1 175 | 0.903125 0.816667 1 176 | 0.921875 0.913889 1 177 | 0.899219 0.8625 1 178 | 0.953125 0.863889 1 179 | 0.917188 0.768056 1 180 | 0.917969 0.858333 1 181 | 0.875 0.909722 1 182 | 0.923438 0.925 1 183 | 0.907031 0.822222 1 184 | 0.870313 0.830556 1 185 | 0.0398437 0.0416667 1 186 | 0.040625 0.0416667 1 187 | 0.084375 0.0541667 1 188 | 0.05 0.0541667 1 189 | 0.0445313 0.106944 1 190 | 0.040625 0.0763889 1 191 | 0.0625 0.0430556 1 192 | 0.0289063 0.0430556 1 193 | 0.0265625 0.136111 1 194 | 0.0632812 0.109722 1 195 | 0.0359375 0.0888889 1 196 | 0.015625 0.0652778 1 197 | 0.0578125 0.0208333 1 198 | 0.0296875 0.0402778 1 199 | 0.0671875 0.113889 1 200 | 0.0367188 0.156944 1 201 | 0.0671875 0.0930556 1 202 | 0.0570312 0.0694444 1 203 | 0.0859375 0.129167 1 204 | 0.0664062 0.154167 1 205 | 0.0945312 0.0694444 1 206 | 0.0570312 0.105556 1 207 | 0.0914062 0.0472222 1 208 | 0.0515625 0.0194444 1 209 | 0.0226562 0.0375 1 210 | 0.0226562 0.104167 1 211 | 0.05 0.106944 1 212 | 0.05625 0.15 1 213 | 0.0601563 0.176389 1 214 | 0.0429688 0.131944 1 215 | 0.084375 0.0777778 1 216 | 0.04375 0.025 1 217 | 0.0132812 0.0569444 1 218 | 0.0234375 0.120833 1 219 | 0.0375 0.0944444 1 220 | 0.0242188 0.0916667 1 221 | 0.034375 0.161111 1 222 | 0.0742188 0.141667 1 223 | 0.0828125 0.0777778 1 224 | 0.0742188 0.0458333 1 225 | 0.084375 0.0222222 1 226 | 0.0921875 0.0722222 1 227 | 0.107031 0.123611 1 228 | 0.0609375 0.143056 1 229 | 0.040625 0.141667 1 230 | 0.0851563 0.0736111 1 231 | -------------------------------------------------------------------------------- /example_regression/bin/data/verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/bin/data/verdana.ttf -------------------------------------------------------------------------------- /example_regression/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example_regression/images/regression_step_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_1.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_10.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_2.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_3.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_4.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_5.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_6.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_7.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_8.png -------------------------------------------------------------------------------- /example_regression/images/regression_step_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/example_regression/images/regression_step_9.png -------------------------------------------------------------------------------- /example_regression/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofGLFWWindowSettings settings; 7 | settings.setGLVersion(3,2); 8 | settings.width = 1280; 9 | settings.height = 720; 10 | settings.resizable = false; 11 | ofCreateWindow(settings); 12 | 13 | // this kicks off the running of my app 14 | // can be OF_WINDOW or OF_FULLSCREEN 15 | // pass in width and height too: 16 | ofRunApp(new ofApp()); 17 | } -------------------------------------------------------------------------------- /example_regression/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | This example demonstrates how to use the GRT regression algorithms in openFrameworks. See the README file for more info. 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "ofMain.h" 8 | #include "ofxGrt.h" 9 | 10 | //State that we want to use the GRT namespace 11 | using namespace GRT; 12 | 13 | class ofApp : public ofBaseApp{ 14 | 15 | public: 16 | enum RegressifierType{ LINEAR_REGRESSION=0, LOGISTIC_REGRESSION, NEURAL_NET, NUM_REGRESSIFIERS }; /// data(2); 42 | 43 | //Update the 1st plot 44 | data[0] = mouseX; 45 | data[1] = mouseY; 46 | plot1.update( data ); 47 | 48 | //Update the 2nd plot 49 | data[0] = lastX > 0 ? (mouseX-lastX) / delta : 0.0; 50 | data[1] = lastY > 0 ? (mouseY-lastY) / delta : 0.0; 51 | plot2.update( data ); 52 | 53 | //Store the mouse values for the next update 54 | lastX = mouseX; 55 | lastY = mouseY; 56 | lastTic = tic; 57 | } 58 | 59 | //-------------------------------------------------------------- 60 | void ofApp::draw(){ 61 | 62 | int plotX = 20; 63 | int plotY = 20; 64 | int plotW = ofGetWidth() - (plotX*2); 65 | int plotH = 200; 66 | 67 | plot1.draw( plotX, plotY, plotW, plotH ); 68 | 69 | plotY += 25 + plotH; 70 | plot2.draw( plotX, plotY, plotW, plotH ); 71 | } 72 | 73 | //-------------------------------------------------------------- 74 | void ofApp::keyPressed(int key){ 75 | switch( key ){ 76 | case 'r': 77 | //Reset the data contents and ranges of the plot 78 | plot1.reset(); 79 | plot2.reset(); 80 | break; 81 | } 82 | } 83 | 84 | //-------------------------------------------------------------- 85 | void ofApp::keyReleased(int key){ 86 | 87 | } 88 | 89 | //-------------------------------------------------------------- 90 | void ofApp::mouseMoved(int x, int y ){ 91 | 92 | } 93 | 94 | //-------------------------------------------------------------- 95 | void ofApp::mouseDragged(int x, int y, int button){ 96 | 97 | } 98 | 99 | //-------------------------------------------------------------- 100 | void ofApp::mousePressed(int x, int y, int button){ 101 | 102 | } 103 | 104 | //-------------------------------------------------------------- 105 | void ofApp::mouseReleased(int x, int y, int button){ 106 | 107 | } 108 | 109 | //-------------------------------------------------------------- 110 | void ofApp::mouseEntered(int x, int y){ 111 | 112 | } 113 | 114 | //-------------------------------------------------------------- 115 | void ofApp::mouseExited(int x, int y){ 116 | 117 | } 118 | 119 | //-------------------------------------------------------------- 120 | void ofApp::windowResized(int w, int h){ 121 | } 122 | 123 | //-------------------------------------------------------------- 124 | void ofApp::gotMessage(ofMessage msg){ 125 | 126 | } 127 | 128 | //-------------------------------------------------------------- 129 | void ofApp::dragEvent(ofDragInfo dragInfo){ 130 | 131 | } 132 | -------------------------------------------------------------------------------- /example_timeseries_plot/src/ofApp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief ofxGrtTimeseriesPlot Example: this example demonstrates how to use the TimeseriesPlot class to plot mouse data over time 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ofMain.h" 9 | #include "ofxGrt.h" 10 | 11 | using namespace GRT; 12 | 13 | class ofApp : public ofBaseApp{ 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | void keyPressed(int key); 21 | void keyReleased(int key); 22 | void mouseMoved(int x, int y ); 23 | void mouseDragged(int x, int y, int button); 24 | void mousePressed(int x, int y, int button); 25 | void mouseReleased(int x, int y, int button); 26 | void mouseEntered(int x, int y); 27 | void mouseExited(int x, int y); 28 | void windowResized(int w, int h); 29 | void dragEvent(ofDragInfo dragInfo); 30 | void gotMessage(ofMessage msg); 31 | 32 | ofTrueTypeFont font; 33 | ofxGrtTimeseriesPlot plot1; 34 | ofxGrtTimeseriesPlot plot2; 35 | }; 36 | -------------------------------------------------------------------------------- /libs/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nickgillian/ofxGrt/689c068b76af9e614f7124dbd4f38c8640c3a06d/libs/.gitignore -------------------------------------------------------------------------------- /src/ofxGrt.h: -------------------------------------------------------------------------------- 1 | /* 2 | GRT MIT License 3 | Copyright (c) <2012> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 6 | and associated documentation files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all copies or substantial 12 | portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 15 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 18 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | */ 20 | 21 | #pragma once 22 | #include "ofMain.h" 23 | #include "GRT/GRT.h" 24 | #include "ofxGrtMatrixPlot.h" 25 | #include "ofxGrtTimeseriesPlot.h" 26 | #include "ofxGrtBarPlot.h" 27 | 28 | -------------------------------------------------------------------------------- /src/ofxGrtBarPlot.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxGrtBarPlot.h" 2 | 3 | ofxGrtBarPlot::ofxGrtBarPlot(){ 4 | numDimensions = 0; 5 | drawGrid = false; 6 | initialized = false; 7 | rangesComputed = false; 8 | lockRanges = false; 9 | drawInfoText = true; 10 | constrainValuesToGraph = true; 11 | backgroundColor[0] = 0; 12 | backgroundColor[1] = 0; 13 | backgroundColor[2] = 0; 14 | gridColor[0] = 100; 15 | gridColor[1] = 100; 16 | gridColor[2] = 100; 17 | barColor[0] = 255; 18 | barColor[1] = 0; 19 | barColor[2] = 0; 20 | 21 | warningLog.setKey("WARNING ofxGrtBarPlot"); 22 | } 23 | 24 | ofxGrtBarPlot::~ofxGrtBarPlot(){ 25 | } 26 | 27 | bool ofxGrtBarPlot::setup(unsigned int numDimensions,const std::string title){ 28 | 29 | std::unique_lock lock( mtx ); 30 | 31 | initialized = true; 32 | this->numDimensions = numDimensions; 33 | this->title = title; 34 | lockRanges = false; 35 | rangesComputed = false; 36 | constrainValuesToGraph = true; 37 | data.resize(numDimensions,0); 38 | minRanges.resize(numDimensions,0); 39 | maxRanges.resize(numDimensions,0); 40 | return true; 41 | } 42 | 43 | bool ofxGrtBarPlot::resetAxisRanges(){ 44 | 45 | std::unique_lock lock( mtx ); 46 | 47 | if( !lockRanges ){ 48 | rangesComputed = false; 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | bool ofxGrtBarPlot::setRanges( const float minY, const float maxY, const bool lockRanges, const bool linkRanges, const bool dynamicScale ){ 55 | 56 | std::unique_lock lock( mtx ); 57 | 58 | for(unsigned int i=0; ilockRanges = lockRanges; 63 | return true; 64 | } 65 | 66 | bool ofxGrtBarPlot::setRanges( const vector< GRT::MinMax > &ranges, const bool lockRanges, const bool linkRanges, const bool dynamicScale ){ 67 | 68 | std::unique_lock lock( mtx ); 69 | 70 | for(unsigned int i=0; ilockRanges = lockRanges; 75 | this->linkRanges = linkRanges; 76 | this->dynamicScale = dynamicScale; 77 | return true; 78 | } 79 | 80 | bool ofxGrtBarPlot::update( const vector< double > &data ){ 81 | 82 | std::unique_lock lock( mtx ); 83 | 84 | if( !initialized ){ 85 | warningLog << "update( const vector< double > &data ) the plot has not been initialized!" << endl; 86 | return false; 87 | } 88 | 89 | for(unsigned int n=0; ndata[n] = data[n]; 92 | 93 | if( !lockRanges ){ 94 | if( this->data[n] < minRanges[n] ){ minRanges[n] = this->data[n]; } 95 | else if( this->data[n] > maxRanges[n] && this->data[n] != maxRanges[n] ){ maxRanges[n] = this->data[n]; } 96 | } 97 | 98 | } 99 | 100 | //Flag that the ranges have been computed 101 | rangesComputed = true; 102 | 103 | return true; 104 | } 105 | 106 | bool ofxGrtBarPlot::update( const vector< float > &data ){ 107 | 108 | std::unique_lock lock( mtx ); 109 | 110 | if( !initialized ){ 111 | warningLog << "update( const vector< float > &data ) the plot has not been initialized!" << endl; 112 | return false; 113 | } 114 | 115 | for(unsigned int n=0; ndata[n] = data[n]; 118 | 119 | if( !lockRanges ){ 120 | if( this->data[n] < minRanges[n] ){ minRanges[n] = this->data[n]; } 121 | else if( this->data[n] > maxRanges[n] && this->data[n] != maxRanges[n] ){ maxRanges[n] = this->data[n]; } 122 | } 123 | 124 | } 125 | 126 | //Flag that the ranges have been computed 127 | rangesComputed = true; 128 | 129 | return true; 130 | } 131 | 132 | 133 | bool ofxGrtBarPlot::draw(unsigned int x,unsigned int y,unsigned int w,unsigned int h){ 134 | 135 | std::unique_lock lock( mtx ); 136 | 137 | if( !initialized ) return false; 138 | 139 | float xStart = 0; 140 | float xEnd = 0; 141 | float yStart = 0; 142 | float yEnd = 0; 143 | 144 | ofPushMatrix(); 145 | ofEnableAlphaBlending(); 146 | ofTranslate(x, y); 147 | 148 | //Draw the background 149 | ofFill(); 150 | ofSetColor(backgroundColor[0],backgroundColor[1],backgroundColor[2]); 151 | ofDrawRectangle(0,0,w,h); 152 | 153 | //Draw the grid if required 154 | if( drawGrid ){ 155 | ofSetColor(gridColor[0],gridColor[1],gridColor[2]); 156 | unsigned int numVLines = 20; 157 | unsigned int numHLines = 10; 158 | 159 | //Draw the horizontal lines 160 | for(unsigned int i=0; i ofxGrtSettings::mVariables; 11 | 12 | ofTrueTypeFont ofxGrtSettings::variables::fontSmall; 13 | ofTrueTypeFont ofxGrtSettings::variables::fontNormal; 14 | ofTrueTypeFont ofxGrtSettings::variables::fontLarge; 15 | std::string ofxGrtSettings::variables::fontFile = "verdana.ttf"; 16 | ofColor ofxGrtSettings::variables::activeTextColor = {30,30,30}; 17 | ofColor ofxGrtSettings::variables::gridColor = {200,200,200}; 18 | ofColor ofxGrtSettings::variables::axisColor = {40,40,40}; 19 | ofColor ofxGrtSettings::variables::backgroundColor = {255,255,255}; 20 | ofColor ofxGrtSettings::variables::disabledTextColor = {160,160,160}; 21 | int ofxGrtSettings::variables::titleTextSpacer = 5; 22 | int ofxGrtSettings::variables::axisTicksSize = 5; 23 | int ofxGrtSettings::variables::info_margin = 15; 24 | 25 | -------------------------------------------------------------------------------- /src/ofxGrtSettings.h: -------------------------------------------------------------------------------- 1 | // 2 | // ofxGrtSettings.h 3 | // 4 | // Created by luca lolli on 11/08/2016. 5 | // Updated: nickgillian: 26/09/2016 6 | // 7 | 8 | #pragma once 9 | 10 | #include "ofMain.h" 11 | 12 | class ofxGrtSettings 13 | { 14 | 15 | 16 | public: 17 | struct variables 18 | { 19 | variables() 20 | { 21 | fontSmall.load(fontFile,8); 22 | fontNormal.load(fontFile,10); 23 | fontLarge.load(fontFile,14); 24 | } 25 | 26 | static int info_margin; 27 | 28 | static std::string fontFile; 29 | 30 | static ofTrueTypeFont fontSmall; 31 | static ofTrueTypeFont fontNormal; 32 | static ofTrueTypeFont fontLarge; 33 | static ofColor activeTextColor; 34 | static ofColor gridColor; 35 | static ofColor axisColor; 36 | static ofColor backgroundColor; 37 | static ofColor disabledTextColor; 38 | static int titleTextSpacer; 39 | static int axisTicksSize; 40 | 41 | }; 42 | 43 | ofxGrtSettings() 44 | { 45 | mVariables = shared_ptr( new variables()); 46 | } 47 | 48 | static ofxGrtSettings& GetInstance() 49 | { 50 | static ofxGrtSettings config; 51 | return config; 52 | } 53 | 54 | std::shared_ptr get() 55 | { 56 | return mVariables; 57 | } 58 | 59 | private: 60 | 61 | static std::shared_ptr mVariables; 62 | 63 | ofxGrtSettings(const ofxGrtSettings&); 64 | ofxGrtSettings& operator=(const ofxGrtSettings&); 65 | 66 | }; 67 | 68 | --------------------------------------------------------------------------------