Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (173)
Showing
with 21639 additions and 2 deletions
**/.DS_Store
**/Thumbs.db
docs/html/
/emscripten_output/*
# Created by https://www.gitignore.io/api/emacs
......
[submodule "dependencies/Maximilian"]
path = dependencies/Maximilian
url = https://github.com/micknoise/Maximilian.git
[submodule "dependencies/RapidLib"]
path = dependencies/RapidLib
url = http://gitlab.doc.gold.ac.uk/rapid-mix/RapidLib.git
branch = rapidmix-api
[submodule "dependencies/pipo"]
path = dependencies/pipo
url = https://github.com/Ircam-RnD/pipo
[submodule "dependencies/xmm"]
path = dependencies/xmm
url = https://github.com/Ircam-RnD/xmm
[submodule "dependencies/repovizz2_cpp"]
path = dependencies/repovizz2_cpp
url = https://github.com/slowmountain/repovizz2_cpp.git
cmake_minimum_required(VERSION 2.8.9)
project (rapidmix)
# The version number.
set (rapidmix_VERSION_MAJOR 2)
set (rapidmix_VERSION_MINOR 2)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
# Compiler Flags
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DJSON_DEBUG -fPIC")
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
# Main lib
include_directories(${PROJECT_SOURCE_DIR}/src)
# RAPID-MIX dependencies
include_directories(dependencies/RapidLib/src)
include_directories(dependencies/xmm/src)
include_directories(dependencies/GVF)
include_directories(dependencies/Maximilian)
include_directories(dependencies/Maximilian/libs)
include_directories(dependencies/pipo/sdk/src)
include_directories(dependencies/pipo/sdk/src/host)
include_directories(dependencies/pipo/modules)
include_directories(dependencies/pipo/modules/collection)
include_directories(dependencies/pipo/modules/bayesfilter/src)
include_directories(dependencies/pipo/modules/finitedifferences)
include_directories(dependencies/pipo/modules/rta/src)
include_directories(dependencies/pipo/modules/rta/src/util)
include_directories(dependencies/pipo/modules/rta/src/statistics)
include_directories(dependencies/pipo/modules/rta/src/signal)
include_directories(dependencies/pipo/modules/rta/bindings/lib)
# Third party dependencies
include_directories(dependencies/third_party/json)
# Source Files
file(GLOB_RECURSE RAPIDMIX_SRC "${PROJECT_SOURCE_DIR}/src/*.cpp")
file(GLOB GVF_SRC "${PROJECT_SOURCE_DIR}/dependencies/GVF/GVF.cpp")
# Maximilian
file(GLOB MAXI_SRC "${PROJECT_SOURCE_DIR}/dependencies/Maximilian/maximilian.cpp")
file(GLOB MAXI_SRC ${MAXI_SRC} "${PROJECT_SOURCE_DIR}/dependencies/Maximilian/libs/maxiFFT.cpp")
file(GLOB MAXI_SRC ${MAXI_SRC} "${PROJECT_SOURCE_DIR}/dependencies/Maximilian/libs/fft.cpp")
#PiPo
file(GLOB_RECURSE PIPO_SRC "${PROJECT_SOURCE_DIR}/dependencies/pipo/sdk/src/*")
file(GLOB_RECURSE PIPO_SRC ${PIPO_SRC} "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/bayesfilter/src/*")
file(GLOB_RECURSE PIPO_SRC ${PIPO_SRC} "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/collection/*")
file(GLOB_RECURSE PIPO_SRC ${PIPO_SRC} "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/finitedifferences/*")
file(GLOB_RECURSE PIPO_SRC ${PIPO_SRC} "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/rta/src/util/*")
file(GLOB_RECURSE PIPO_SRC ${PIPO_SRC} "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/rta/src/signal/*")
file(GLOB_RECURSE PIPO_SRC ${PIPO_SRC} "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/rta/src/statistics/*")
list(REMOVE_ITEM PIPO_SRC "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/rta/src/signal/rta_onepole.c")
list(REMOVE_ITEM PIPO_SRC "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/rta/src/signal/rta_resample.c")
list(REMOVE_ITEM PIPO_SRC "${PROJECT_SOURCE_DIR}/dependencies/pipo/modules/rta/src/statistics/rta_cca.c")
# RapidLib
file(GLOB RAPIDLIB_SRC "${PROJECT_SOURCE_DIR}/dependencies/RapidLib/src/*.cpp")
file(GLOB RAPIDLIB_DEP "${PROJECT_SOURCE_DIR}/dependencies/RapidLib/dependencies/libsvm/libsvm.cpp")
# XMM
file(GLOB_RECURSE XMM_SRC "${PROJECT_SOURCE_DIR}/dependencies/xmm/src/*")
file(GLOB JSON_SRC "${PROJECT_SOURCE_DIR}/dependencies/third_party/jsoncpp.cpp")
# Set the source for the main library, using the groups defined above
set(RAPIDMIX_FULL_SRC ${RAPIDMIX_SRC}
${GVF_SRC}
${MAXI_SRC}
${PIPO_SRC}
${RAPIDLIB_SRC}
${RAPIDLIB_DEP}
${XMM_SRC}
${JSON_SRC}
)
add_library(RAPID-MIX_API SHARED ${RAPIDMIX_FULL_SRC})
add_executable(rapidmixTest tests/rapidMixTest.cpp )
add_executable(helloRapidMix ${PROJECT_SOURCE_DIR}/examples/HelloRapidMix/HelloRapidMix/main.cpp)
if (APPLE)
find_library(ACCELERATE Accelerate)
if (NOT ACCELERATE)
message(FATAL_ERROR "Accelearate not found")
endif()
target_link_libraries(RAPID-MIX_API ${ACCELERATE})
endif()
target_link_libraries(rapidmixTest RAPID-MIX_API)
target_link_libraries(helloRapidMix RAPID-MIX_API)
Copyright (c) 2017 Goldsmiths College University of London
Copyright (c) 2017 by IRCAM – Centre Pompidou, Paris, France
All rights reserved.
The RAPID-MIX API wrapper, in the /src directory, is licenced by the BSD license below. Submodules in the /dependances
folder have their own copyrights and licenses, including MIT, BSD, and GPLv3 licenses. Users are requested to check
individual folders for license details, or to contact RAPID-MIX developers.
BSD 3-clause
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
RAPID-MIX API is an easy-to-use toolkit designed to make sensor integration, machine learning and interactive audio accessible for artists, designers, makers, educators, and beginners, as well as creative companies and independent developers.
**RAPID-MIX API** is an easy-to-use toolkit designed to make sensor integration, machine learning and interactive audio accessible for artists, designers, makers, educators, and beginners, as well as creative companies and independent developers.
RAPID-MIX API includes JavaScript and C++ libraries, built with RAPID-MIX technologies, that make it easy to combine sensor data, machine learning algorithms and interactive audio. They provide a full set of functionalities for cross-device and cross-platform development, modular components, and cloud-based services and multimodal data storage
\ No newline at end of file
It has been built with RAPID-MIX technologies, that make it easy to combine sensor data, machine learning algorithms and interactive audio. They provide a full set of functionalities for cross-device and cross-platform development, modular components, and cloud-based services and multimodal data storage.
## Dependencies
Use `git submodule update --init --recursive` to pull the following library dependencies.
1. RapidLib
1. XMM
1. PiPo
1. GVF
1. RepoVizz2 Client
## Documentation
Full documentation at http://www.rapidmixapi.com/
## Testing
We are using Catch for C++ testing. Look at the test fixtures in the /tests/test_projetc/test_project.xcodeproj for an example of how to implement them.
## Building with CMake
Navigate to /RAPID-MIX_API and run this in a terminal:
`mkdir build
cd build
cmake ..
make
`
Or run the shell script: `./rmix_build_test.sh`
\ No newline at end of file
This diff is collapsed.
/**
* Gesture Variation Follower class allows for early gesture recognition and variation tracking
*
* @details Original algorithm designed and implemented in 2011 at Ircam Centre Pompidou
* by Baptiste Caramiaux and Nicola Montecchio. The library has been created and is maintained by Baptiste Caramiaux
*
* Copyright (C) 2015 Baptiste Caramiaux, Nicola Montecchio
* STMS lab Ircam-CRNS-UPMC, University of Padova, Goldsmiths College University of London
*
* The library is under the GNU Lesser General Public License (LGPL v3)
*/
#ifndef _H_GVF
#define _H_GVF
#include "GVFUtils.h"
#include "GVFGesture.h"
#include <random>
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <random>
#include <cmath>
using namespace std;
class GVF
{
public:
/**
* GVF possible states
*/
enum GVFState
{
STATE_CLEAR = 0, /**< STATE_CLEAR: clear the GVF and be in standby */
STATE_LEARNING, /**< STATE_LEARNING: recording mode, input gestures are added to the templates */
STATE_FOLLOWING, /**< STATE_FOLLOWING: tracking mode, input gestures are classifed and their variations tracked (need the GVF to be trained) */
STATE_BYPASS /**< STATE_BYPASS: by pass GVF but does not erase templates or training */
};
#pragma mark - Constructors
/**
* GVF default constructor
* @details use default configuration and parameters, can be changed using accessors
*/
GVF();
/**
* GVF default destructor
*/
~GVF();
#pragma mark - Gesture templates
/**
* Start a gesture either to be recorded or followed
*/
void startGesture();
/**
* Add an observation to a gesture template
* @details
* @param data vector of features
*/
void addObservation(vector<float> data);
/**
* Add gesture template to the vocabulary
*
* @details a gesture template is a GVFGesture object and can be added directly to the vocabulqry or
* recorded gesture templates by using this method
* @param gestureTemplate the gesture template to be recorded
*/
void addGestureTemplate(GVFGesture & gestureTemplate);
/**
* Replace a specific gesture template by another
*
* @param gestureTemplate the gesture template to be used
* @param index the gesture index (as integer) to be replaced
*/
void replaceGestureTemplate(GVFGesture & gestureTemplate, int index);
/**
* Remove a specific template
*
* @param index the gesture index (as integer) to be removed
*/
void removeGestureTemplate(int index);
/**
* Remove every recorded gesture template
*/
void removeAllGestureTemplates();
/**
* Get a specific gesture template a gesture template by another
*
* @param index the index of the template to be returned
* @return the template
*/
GVFGesture & getGestureTemplate(int index);
/**
* Get every recorded gesture template
*
* @return the vecotr of gesture templates
*/
vector<GVFGesture> & getAllGestureTemplates();
/**
* Get number of gesture templates in the vocabulary
* @return the number of templates
*/
int getNumberOfGestureTemplates();
/**
* Get gesture classes
*/
vector<int> getGestureClasses();
#pragma mark - Recognition and tracking
/**
* Set the state of GVF
* @param _state the state to be given to GVF, it is a GVFState
* @param indexes an optional argument providing a list of gesture index.
* In learning mode the index of the gesture being recorded can be given as an argument
* since the type is vector<int>, it should be something like '{3}'. In following mode, the list of indexes
* is the list of active gestures to be considered in the recognition/tracking.
*/
void setState(GVFState _state, vector<int> indexes = vector<int>());
/**
* Return the current state of GVF
* @return GVFState the current state
*/
GVFState getState();
/**
* Compute the estimated gesture and its potential variations
*
* @details infers the probability that the current observation belongs to
* one of the recorded gesture template and track the variations of this gesture
* according to each template
*
* @param observation vector of the observation data at current time
* @return the estimated probabilities and variaitons relative to each template
*/
GVFOutcomes & update(vector<float> & observation);
/**
* Define a subset of gesture templates on which to perform the recognition
* and variation tracking
*
* @details By default every recorded gesture template is considered
* @param set of gesture template index to consider
*/
void setActiveGestures(vector<int> activeGestureIds);
/**
* Restart GVF
* @details re-sample particles at the origin (i.e. initial prior)
*/
void restart();
/**
* Clear GVF
* @details delete templates
*/
void clear();
/**
* Translate data according to the first point
* @details substract each gesture feature by the first point of the gesture
* @param boolean to activate or deactivate translation
*/
void translate(bool translateFlag);
/**
* Segment gestures within a continuous gesture stream
* @details if segmentation is true, the method will segment a continuous gesture into a sequence
* of gestures. In other words no need to call the method startGesture(), it is done automatically
* @param segmentationFlag boolean to activate or deactivate segmentation
*/
void segmentation(bool segmentationFlag);
#pragma mark - [ Accessors ]
#pragma mark > Parameters
/**
* Set tolerance between observation and estimation
* @details tolerance depends on the range of the data
* typially tolerance = (data range)/3.0;
* @param tolerance value
*/
void setTolerance(float tolerance);
/**
* Get the obervation tolerance value
* @details see setTolerance(float tolerance)
* @return the current toleranc value
*/
float getTolerance();
void setDistribution(float _distribution);
/**
* Set number of particles used in estimation
* @details default valye is 1000, note that the computational
* cost directly depends on the number of particles
* @param new number of particles
*/
void setNumberOfParticles(int numberOfParticles);
/**
* Get the current number of particles
* @return the current number of particles
*/
int getNumberOfParticles();
/**
* Number of prediciton steps
* @details it is possible to leave GVF to perform few steps of prediction
* ahead which can be useful to estimate more fastly the variations. Default value is 1
* which means no prediction ahead
* @param the number of prediction steps
*/
void setPredictionSteps(int predictionSteps);
/**
* Get the current number of prediction steps
* @return current number of prediciton steps
*/
int getPredictionSteps();
/**
* Set resampling threshold
* @details resampling threshold is the minimum number of active particles
* before resampling all the particles by the estimated posterior distribution.
* in other words, it re-targets particles around the best current estimates
* @param the minimum number of particles (default is (number of particles)/2)
*/
void setResamplingThreshold(int resamplingThreshold);
/**
* Get the current resampling threshold
* @return resampling threshold
*/
int getResamplingThreshold();
#pragma mark > Dynamics
/**
* Change variance of adaptation in dynamics
* @details if dynamics adaptation variance is high the method will adapt faster to
* fast changes in dynamics. Dynamics is 2-dimensional: the first dimension is the speed
* The second dimension is the acceleration.
*
* Typically the variance is the average amount the speed or acceleration can change from
* one sample to another. As an example, if the relative estimated speed can change from 1.1 to 1.2
* from one sample to another, the variance should allow a change of 0.1 in speed. So the variance
* should be set to 0.1*0.1 = 0.01
*
* @param dynVariance dynamics variance value
* @param dim optional dimension of the dynamics for which the change of variance is applied (default value is 1)
*/
void setDynamicsVariance(float dynVariance, int dim = -1);
/**
* Change variance of adaptation in dynamics
* @details See setDynamicsVariance(float dynVariance, int dim) for more details
* @param dynVariance vector of dynamics variances, each vector index is the variance to be applied to
* each dynamics dimension (consequently the vector should be 2-dimensional).
*/
void setDynamicsVariance(vector<float> dynVariance);
/**
* Get dynamics variances
* @return the vector of variances (the returned vector is 2-dimensional)
*/
vector<float> getDynamicsVariance();
#pragma mark > Scalings
/**
* Change variance of adaptation in scalings
* @details if scalings adaptation variance is high the method will adapt faster to
* fast changes in relative sizes. There is one scaling variance for each dimension
* of the input gesture. If the gesture is 2-dimensional, the scalings variances will
* also be 2-dimensional.
*
* Typically the variance is the average amount the size can change from
* one sample to another. As an example, if the relative estimated size changes from 1.1 to 1.15
* from one sample to another, the variance should allow a change of 0.05 in size. So the variance
* should be set to 0.05*0.05 = 0.0025
*
* @param scalings variance value
* @param dimension of the scalings for which the change of variance is applied
*/
void setScalingsVariance(float scaleVariance, int dim = -1);
/**
* Change variance of adaptation in dynamics
* @details See setScalingsVariance(float scaleVariance, int dim) for more details
* @param vector of scalings variances, each vector index is the variance to be applied to
* each scaling dimension.
* @param vector of variances (should be the size of the template gestures dimension)
*/
void setScalingsVariance(vector<float> scaleVariance);
/**
* Get scalings variances
* @return the vector of variances
*/
vector<float> getScalingsVariance();
#pragma mark > Rotations
/**
* Change variance of adaptation in orientation
* @details if rotation adaptation variance is high the method will adapt faster to
* fast changes in relative orientation. If the gesture is 2-dimensional, there is
* one variance value since the rotation can be defined by only one angle of rotation. If
* the gesture is 3-dimensional, there are 3 variance values since the rotation in 3-d is
* defined by 3 rotation angles. For any other dimension, the rotation is not defined.
*
* The variance is the average amount the orientation can change from one sample to another.
* As an example, if the relative orientation in rad changes from 0.1 to 0.2 from one observation
* to another, the variance should allow a change of 0.1 in rotation angle. So the variance
* should be set to 0.1*0.1 = 0.01
*
* @param rotationsVariance rotation variance value
* @param dim optional dimension of the rotation for which the change of variance is applied
*/
void setRotationsVariance(float rotationsVariance, int dim = -1);
/**
* Change variance of adaptation in orientation
* @details See setRotationsVariance(float rotationsVariance, int dim) for more details
* @param vector of rotation variances, each vector index is the variance to be applied to
* each rotation angle (1 or 3)
* @param vector of variances (should be 1 if the the template gestures are 2-dim or 3 if
* they are 3-dim)
*/
void setRotationsVariance(vector<float> rotationsVariance);
/**
* Get rotation variances
* @return the vector of variances
*/
vector<float> getRotationsVariance();
#pragma mark > Others
/**
* Get particle values
* @return vector of list of estimated particles
*/
const vector<vector<float> > & getParticlesPositions();
/**
* Set the interval on which the dynamics values should be spread at the beginning (before adaptation)
* @details this interval can be used to concentrate the potential dynamics value on a narrow interval,
* typically around 1 (the default value), for instance between -0.05 and 0.05, or to allow at the very
* beginning, high changes in dynamics by spreading, for instance between 0.0 and 2.0
* @param min lower value of the inital values for dynamics
* @param max higher value of the inital values for dynamics
* @param dim the dimension on which the change of initial interval should be applied (optional)
*/
void setSpreadDynamics(float min, float max, int dim = -1);
/**
* Set the interval on which the scalings values should be spread at the beginning (before adaptation)
* @details this interval can be used to concentrate the potential scalings value on a narrow interval,
* typically around 1.0 (the default value), for instance between 0.95 and 1.05, or to allow at the very
* beginning high changes in dynamics by spreading, for instance, between 0.0 and 2.0
* @param min lower value of the inital values for scalings
* @param max higher value of the inital values for scalings
* @param dim the dimension on which the change of initial interval should be applied (optional)
*/
void setSpreadScalings(float min, float max, int dim = -1);
/**
* Set the interval on which the angle of rotation values should be spread at the beginning (before adaptation)
* @details this interval can be used to concentrate the potential angle values on a narrow interval,
* typically around 0.0 (the default value), for instance between -0.05 and 0.05, or to allow at the very
* beginning, high changes in orientation by spreading, for instance, between -0.5 and 0.5
* @param min lower value of the inital values for angle of rotation
* @param max higher value of the inital values for angle of rotation
* @param dim the dimension on which the change of initial interval should be applied (optional)
*/
void setSpreadRotations(float min, float max, int dim = -1);
#pragma mark - Import/Export templates
/**
* Export template data in a filename
* @param filename file name as a string
*/
void saveTemplates(string filename);
/**
* Import template data in a filename
* @details needs to respect a given format provided by saveTemplates()
* @param file name as a string
*/
void loadTemplates(string filename);
protected:
GVFConfig config; // Structure storing the configuration of GVF (in GVFUtils.h)
GVFParameters parameters; // Structure storing the parameters of GVF (in GVFUtils.h)
GVFOutcomes outcomes; // Structure storing the outputs of GVF (in GVFUtils.h)
GVFState state; // State (defined above)
GVFGesture theGesture; // GVFGesture object to handle incoming data in learning and following modes
vector<GVFGesture> gestureTemplates; // vector storing the gesture templates recorded when using the methods addObservation(vector<float> data) or addGestureTemplate(GVFGesture & gestureTemplate)
vector<float> dimWeights; // TOOD: to be put in parameters?
vector<float> maxRange;
vector<float> minRange;
int dynamicsDim; // dynamics state dimension
int scalingsDim; // scalings state dimension
int rotationsDim; // rotation state dimension
float globalNormalizationFactor; // flagged if normalization
int mostProbableIndex; // cached most probable index
int learningGesture;
vector<int> classes; // gesture index for each particle [ns x 1]
vector<float > alignment; // alignment index (between 0 and 1) [ns x 1]
vector<vector<float> > dynamics; // dynamics estimation [ns x 2]
vector<vector<float> > scalings; // scalings estimation [ns x D]
vector<vector<float> > rotations; // rotations estimation [ns x A]
vector<float> weights; // weight of each particle [ns x 1]
vector<float> prior; // prior of each particle [ns x 1]
vector<float> posterior; // poserior of each particle [ns x 1]
vector<float> likelihood; // likelihood of each particle [ns x 1]
// estimations
vector<float> estimatedGesture; // ..
vector<float> estimatedAlignment; // ..
vector<vector<float> > estimatedDynamics; // ..
vector<vector<float> > estimatedScalings; // ..
vector<vector<float> > estimatedRotations; // ..
vector<float> estimatedProbabilities; // ..
vector<float> estimatedLikelihoods; // ..
vector<float> absoluteLikelihoods; // ..
bool tolerancesetmanually;
vector<vector<float> > offsets; // translation offset
vector<int> activeGestures;
vector<float> gestureProbabilities;
vector< vector<float> > particles;
private:
// random number generator
std::random_device rd;
std::mt19937 normgen;
std::normal_distribution<float> *rndnorm;
std::default_random_engine unifgen;
std::uniform_real_distribution<float> *rndunif;
#pragma mark - Private methods for model mechanics
void initPrior();
void initNoiseParameters();
void updateLikelihood(vector<float> obs, int n);
void updatePrior(int n);
void updatePosterior(int n);
void resampleAccordingToWeights(vector<float> obs);
void estimates(); // update estimated outcome
void train();
};
#endif
\ No newline at end of file
//
// GVFGesture.h
// gvf
//
// Created by Baptiste Caramiaux on 22/01/16.
//
//
#ifndef GVFGesture_h
#define GVFGesture_h
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
class GVFGesture
{
public:
GVFGesture()
{
inputDimensions = 2;
setAutoAdjustRanges(true);
templatesRaw = vector<vector<vector<float > > >();
templatesNormal = vector<vector<vector<float > > >();
clear();
}
GVFGesture(int inputDimension){
inputDimensions = inputDimension;
setAutoAdjustRanges(true);
templatesRaw = vector<vector<vector<float > > >();
templatesNormal = vector<vector<vector<float > > >();
clear();
}
~GVFGesture(){
clear();
}
void setNumberDimensions(int dimensions){
assert(dimensions > 0);
inputDimensions = dimensions;
}
void setAutoAdjustRanges(bool b){
// if(b) bIsRangeMinSet = bIsRangeMaxSet = false;
bAutoAdjustNormalRange = b;
}
void setMax(float x, float y){
assert(inputDimensions == 2);
vector<float> r(2);
r[0] = x; r[1] = y;
setMaxRange(r);
}
void setMin(float x, float y){
assert(inputDimensions == 2);
vector<float> r(2);
r[0] = x; r[1] = y;
setMinRange(r);
}
void setMax(float x, float y, float z){
assert(inputDimensions == 3);
vector<float> r(3);
r[0] = x; r[1] = y; r[2] = z;
setMaxRange(r);
}
void setMin(float x, float y, float z){
assert(inputDimensions == 3);
vector<float> r(3);
r[0] = x; r[1] = y; r[2] = z;
setMinRange(r);
}
void setMaxRange(vector<float> observationRangeMax){
this->observationRangeMax = observationRangeMax;
// bIsRangeMaxSet = true;
normalise();
}
void setMinRange(vector<float> observationRangeMin){
this->observationRangeMin = observationRangeMin;
// bIsRangeMinSet = true;
normalise();
}
vector<float>& getMaxRange(){
return observationRangeMax;
}
vector<float>& getMinRange(){
return observationRangeMin;
}
void autoAdjustMinMax(vector<float> & observation){
if(observationRangeMax.size() < inputDimensions){
observationRangeMax.assign(inputDimensions, -INFINITY);
observationRangeMin.assign(inputDimensions, INFINITY);
}
for(int i = 0; i < inputDimensions; i++){
observationRangeMax[i] = MAX(observationRangeMax[i], observation[i]);
observationRangeMin[i] = MIN(observationRangeMin[i], observation[i]);
}
}
void addObservation(vector<float> observation, int templateIndex = 0){
if (observation.size() != inputDimensions)
inputDimensions = int(observation.size());
// check we have a valid templateIndex and correct number of input dimensions
assert(templateIndex <= templatesRaw.size());
assert(observation.size() == inputDimensions);
// if the template index is same as the number of temlates make a new template
if(templateIndex == templatesRaw.size()){ // make a new template
// reserve space in raw and normal template storage
templatesRaw.resize(templatesRaw.size() + 1);
templatesNormal.resize(templatesNormal.size() + 1);
}
if(templatesRaw[templateIndex].size() == 0)
{
templateInitialObservation = observation;
templateInitialNormal = observation;
}
for(int j = 0; j < observation.size(); j++)
observation[j] = observation[j] - templateInitialObservation[j];
// store the raw observation
templatesRaw[templateIndex].push_back(observation);
autoAdjustMinMax(observation);
normalise();
}
void normalise()
{
templatesNormal.resize(templatesRaw.size());
for(int t = 0; t < templatesRaw.size(); t++)
{
templatesNormal[t].resize(templatesRaw[t].size());
for(int o = 0; o < templatesRaw[t].size(); o++)
{
templatesNormal[t][o].resize(inputDimensions);
for(int d = 0; d < inputDimensions; d++)
{
templatesNormal[t][o][d] = templatesRaw[t][o][d] / (observationRangeMax[d] - observationRangeMin[d]);
templateInitialNormal[d] = templateInitialObservation[d] / (observationRangeMax[d] - observationRangeMin[d]);
}
}
}
}
void setTemplate(vector< vector<float> > & observations, int templateIndex = 0){
for(int i = 0; i < observations.size(); i++){
addObservation(observations[i], templateIndex);
}
}
vector< vector<float> > & getTemplate(int templateIndex = 0){
assert(templateIndex < templatesRaw.size());
return templatesRaw[templateIndex];
}
int getNumberOfTemplates(){
return int(templatesRaw.size());
}
int getNumberDimensions(){
return inputDimensions;
}
int getTemplateLength(int templateIndex = 0){
return int(templatesRaw[templateIndex].size());
}
int getTemplateDimension(int templateIndex = 0){
return int(templatesRaw[templateIndex][0].size());
}
vector<float>& getLastObservation(int templateIndex = 0){
return templatesRaw[templateIndex][templatesRaw[templateIndex].size() - 1];
}
vector< vector< vector<float> > >& getTemplates(){
return templatesRaw;
}
vector<float>& getInitialObservation(){
return templateInitialObservation;
}
void deleteTemplate(int templateIndex = 0)
{
assert(templateIndex < templatesRaw.size());
templatesRaw[templateIndex].clear();
templatesNormal[templateIndex].clear();
}
void clear()
{
templatesRaw.clear();
templatesNormal.clear();
observationRangeMax.assign(inputDimensions, -INFINITY);
observationRangeMin.assign(inputDimensions, INFINITY);
}
private:
int inputDimensions;
bool bAutoAdjustNormalRange;
vector<float> observationRangeMax;
vector<float> observationRangeMin;
vector<float> templateInitialObservation;
vector<float> templateInitialNormal;
vector< vector< vector<float> > > templatesRaw;
vector< vector< vector<float> > > templatesNormal;
vector<vector<float> > gestureDataFromFile;
};
#endif /* GVFGesture_h */
//
// GVFTypesAndUtils.h
//
//
//
#ifndef __H_GVFTYPES
#define __H_GVFTYPES
#include <map>
#include <vector>
#include <iostream>
#include <random>
#include <iostream>
#include <math.h>
#include <assert.h>
using namespace std;
/**
* Configuration structure
*/
typedef struct
{
int inputDimensions; /**< input dimesnion */
bool translate; /**< translate flag */
bool segmentation; /**< segmentation flag */
} GVFConfig;
/**
* Parameters structure
*/
typedef struct
{
float tolerance; /**< input dimesnion */
float distribution;
int numberParticles;
int resamplingThreshold;
float alignmentVariance;
float speedVariance;
vector<float> scaleVariance;
vector<float> dynamicsVariance;
vector<float> scalingsVariance;
vector<float> rotationsVariance;
// spreadings
float alignmentSpreadingCenter;
float alignmentSpreadingRange;
float dynamicsSpreadingCenter;
float dynamicsSpreadingRange;
float scalingsSpreadingCenter;
float scalingsSpreadingRange;
float rotationsSpreadingCenter;
float rotationsSpreadingRange;
int predictionSteps;
vector<float> dimWeights;
} GVFParameters;
// Outcomes structure
typedef struct
{
int likeliestGesture;
vector<float> likelihoods;
vector<float> alignments;
vector<vector<float> > dynamics;
vector<vector<float> > scalings;
vector<vector<float> > rotations;
} GVFOutcomes;
//--------------------------------------------------------------
// init matrix by allocating memory
template <typename T>
inline void initMat(vector< vector<T> > & M, int rows, int cols){
M.resize(rows);
for (int n=0; n<rows; n++){
M[n].resize(cols);
}
}
//--------------------------------------------------------------
// init matrix and copy values from another matrix
template <typename T>
inline void setMat(vector< vector<T> > & C, vector< vector<float> > & M){
int rows = int(M.size());
int cols = int(M[0].size());
//C.resize(rows);
C = vector<vector<T> >(rows);
for (int n=0; n<rows; n++){
//C[n].resize(cols);
C[n] = vector<T>(cols);
for (int m=0;m<cols;m++){
C[n][m] = M[n][m];
}
}
}
//--------------------------------------------------------------
// init matrix by allocating memory and fill with T value
template <typename T>
inline void setMat(vector< vector<T> > & M, T value, int rows, int cols){
M.resize(rows);
for (int n=0; n<rows; n++){
M[n].resize(cols);
for (int m=0; m<cols; m++){
M[n][m] = value;
}
}
}
//--------------------------------------------------------------
// set matrix filled with T value
template <typename T>
inline void setMat(vector< vector<T> > & M, T value){
for (int n=0; n<M.size(); n++){
for (int m=0; m<M[n].size(); m++){
M[n][m] = value;
}
}
}
//--------------------------------------------------------------
template <typename T>
inline void printMat(vector< vector<T> > & M){
for (int k=0; k<M.size(); k++){
cout << k << ": ";
for (int l=0; l<M[0].size(); l++){
cout << M[k][l] << " ";
}
cout << endl;
}
cout << endl;
}
//--------------------------------------------------------------
template <typename T>
inline void printVec(vector<T> & V){
for (int k=0; k<V.size(); k++){
cout << k << ": " << V[k] << (k == V.size() - 1 ? "" : " ,");
}
cout << endl;
}
//--------------------------------------------------------------
template <typename T>
inline void initVec(vector<T> & V, int rows){
V.resize(rows);
}
//--------------------------------------------------------------
template <typename T>
inline void setVec(vector<T> & C, vector<int> &V){
int rows = int(V.size());
C = vector<T>(rows);
//C.resize(rows);
for (int n=0; n<rows; n++){
C[n] = V[n];
}
}
//--------------------------------------------------------------
template <typename T>
inline void setVec(vector<T> & C, vector<float> & V){
int rows = int(V.size());
C.resize(rows);
for (int n=0; n<rows; n++){
C[n] = V[n];
}
}
//--------------------------------------------------------------
template <typename T>
inline void setVec(vector<T> & V, T value){
for (int n=0; n<V.size(); n++){
V[n] = value;
}
}
//--------------------------------------------------------------
template <typename T>
inline void setVec(vector<T> & V, T value, int rows){
V.resize(rows);
setVec(V, value);
}
//--------------------------------------------------------------
template <typename T>
inline vector< vector<T> > dotMat(vector< vector<T> > & M1, vector< vector<T> > & M2){
// TODO(Baptiste)
}
//--------------------------------------------------------------
template <typename T>
inline vector< vector<T> > multiplyMatf(vector< vector<T> > & M1, T v){
vector< vector<T> > multiply;
initMat(multiply, M1.size(), M1[0].size());
for (int i=0; i<M1.size(); i++){
for (int j=0; j<M1[i].size(); j++){
multiply[i][j] = M1[i][j] * v;
}
}
return multiply;
}
//--------------------------------------------------------------
template <typename T>
inline vector< vector<T> > multiplyMatf(vector< vector<T> > & M1, vector< vector<T> > & M2){
assert(M1[0].size() == M2.size()); // columns in M1 == rows in M2
vector< vector<T> > multiply;
initMat(multiply, M1.size(), M2[0].size()); // rows in M1 x cols in M2
for (int i=0; i<M1.size(); i++){
for (int j=0; j<M2[i].size(); j++){
multiply[i][j] = 0.0f;
for(int k=0; k<M1[0].size(); k++){
multiply[i][j] += M1[i][k] * M2[k][j];
}
}
}
return multiply;
}
//--------------------------------------------------------------
template <typename T>
inline vector<T> multiplyMat(vector< vector<T> > & M1, vector< T> & Vect){
assert(Vect.size() == M1[0].size()); // columns in M1 == rows in Vect
vector<T> multiply;
initVec(multiply, int(Vect.size()));
for (int i=0; i<M1.size(); i++){
multiply[i] = 0.0f;
for (int j=0; j<M1[i].size(); j++){
multiply[i] += M1[i][j] * Vect[j];
}
}
return multiply;
}
//--------------------------------------------------------------
template <typename T>
inline float getMeanVec(vector<T>& V){
float tSum = 0.0f;
for (int n=0; n<V.size(); n++){
tSum += V[n];
}
return tSum / (float)V.size();
}
template <typename T>
inline vector<vector<float> > getRotationMatrix3d(T phi, T theta, T psi)
{
vector< vector<float> > M;
initMat(M,3,3);
M[0][0] = cos(theta)*cos(psi);
M[0][1] = -cos(phi)*sin(psi)+sin(phi)*sin(theta)*cos(psi);
M[0][2] = sin(phi)*sin(psi)+cos(phi)*sin(theta)*cos(psi);
M[1][0] = cos(theta)*sin(psi);
M[1][1] = cos(phi)*cos(psi)+sin(phi)*sin(theta)*sin(psi);
M[1][2] = -sin(phi)*cos(psi)+cos(phi)*sin(theta)*sin(psi);
M[2][0] = -sin(theta);
M[2][1] = sin(phi)*cos(theta);
M[2][2] = cos(phi)*cos(theta);
return M;
}
template <typename T>
float distance_weightedEuclidean(vector<T> x, vector<T> y, vector<T> w)
{
int count = int(x.size());
if (count <= 0) return 0;
float dist = 0.0;
for(int k = 0; k < count; k++) dist += w[k] * pow((x[k] - y[k]), 2);
return dist;
}
////--------------------------------------------------------------
//vector<vector<float> > getRotationMatrix3d(float phi, float theta, float psi)
//{
// vector< vector<float> > M;
// initMat(M,3,3);
//
// M[0][0] = cos(theta)*cos(psi);
// M[0][1] = -cos(phi)*sin(psi)+sin(phi)*sin(theta)*cos(psi);
// M[0][2] = sin(phi)*sin(psi)+cos(phi)*sin(theta)*cos(psi);
//
// M[1][0] = cos(theta)*sin(psi);
// M[1][1] = cos(phi)*cos(psi)+sin(phi)*sin(theta)*sin(psi);
// M[1][2] = -sin(phi)*cos(psi)+cos(phi)*sin(theta)*sin(psi);
//
// M[2][0] = -sin(theta);
// M[2][1] = sin(phi)*cos(theta);
// M[2][2] = cos(phi)*cos(theta);
//
// return M;
//}
//float distance_weightedEuclidean(vector<float> x, vector<float> y, vector<float> w)
//{
// int count = x.size();
// if (count <= 0) return 0;
// float dist = 0.0;
// for(int k = 0; k < count; k++) dist += w[k] * pow((x[k] - y[k]), 2);
// return dist;
//}
#endif
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Subproject commit 22c4e36d58eb7f2aecf03fb8da7a07211b76432f
RapidLib @ ab5950e8
Subproject commit ab5950e8ff4c20b1c9e1ec9b8f369fcadbabdca6
Subproject commit 9029d999f5d381645cf82ae478b3b875ec19800f
Subproject commit 1d708c1e7f97760239899e1d943751d91aea580e
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
\ No newline at end of file
This diff is collapsed.
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
/// It is intended to be used with #include "json/json-forwards.h"
/// This header provides forward declaration for all JsonCpp types.
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
/*
The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
conditions...
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the
conditions of the MIT License (see below), or 3) under the terms of dual
Public Domain/MIT License conditions described here, as they choose.
The MIT License is about as close to Public Domain as a license can get, and is
described in clear, concise terms at:
http://en.wikipedia.org/wiki/MIT_License
The full text of the MIT License follows:
========================================================================
Copyright (c) 2007-2010 Baptiste Lepilleur
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
========================================================================
(END LICENSE TEXT)
The MIT license is compatible with both the GPL and commercial
software, affording one all of the rights of Public Domain with the
minor nuisance of being required to keep the above copyright notice
and license text in the source code. Note also that by accepting the
Public Domain "license" you can re-license your copy using whatever
license you like.
*/
// //////////////////////////////////////////////////////////////////////
// End of content of file: LICENSE
// //////////////////////////////////////////////////////////////////////
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
# define JSON_FORWARD_AMALGATED_H_INCLUDED
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
#define JSON_IS_AMALGAMATION
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_CONFIG_H_INCLUDED
#define JSON_CONFIG_H_INCLUDED
#include <stddef.h>
#include <string> //typedef String
#include <stdint.h> //typedef int64_t, uint64_t
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of
/// std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
#ifndef JSON_USE_EXCEPTION
#define JSON_USE_EXCEPTION 1
#endif
/// If defined, indicates that the source file is amalgated
/// to prevent private header inclusion.
/// Remarks: it is automatically defined in the generated amalgated header.
// #define JSON_IS_AMALGAMATION
#ifdef JSON_IN_CPPTL
#include <cpptl/config.h>
#ifndef JSON_USE_CPPTL
#define JSON_USE_CPPTL 1
#endif
#endif
#ifdef JSON_IN_CPPTL
#define JSON_API CPPTL_API
#elif defined(JSON_DLL_BUILD)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllexport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#elif defined(JSON_DLL)
#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllimport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#endif // ifdef JSON_IN_CPPTL
#if !defined(JSON_API)
#define JSON_API
#endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
// integer
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
#if defined(_MSC_VER) // MSVC
# if _MSC_VER <= 1200 // MSVC 6
// Microsoft Visual Studio 6 only support conversion from __int64 to double
// (no conversion from unsigned __int64).
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
// characters in the debug information)
// All projects I've ever seen with VS6 were using this globally (not bothering
// with pragma push/pop).
# pragma warning(disable : 4786)
# endif // MSVC 6
# if _MSC_VER >= 1500 // MSVC 2008
/// Indicates that the following function is deprecated.
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
# endif
#endif // defined(_MSC_VER)
// In c++11 the override keyword allows you to explicity define that a function
// is intended to override the base-class version. This makes the code more
// managable and fixes a set of common hard-to-find bugs.
#if __cplusplus >= 201103L
# define JSONCPP_OVERRIDE override
#elif defined(_MSC_VER) && _MSC_VER > 1600
# define JSONCPP_OVERRIDE override
#else
# define JSONCPP_OVERRIDE
#endif
#ifndef JSON_HAS_RVALUE_REFERENCES
#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // MSVC >= 2010
#ifdef __clang__
#if __has_feature(cxx_rvalue_references)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // has_feature
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
#define JSON_HAS_RVALUE_REFERENCES 1
#endif // GXX_EXPERIMENTAL
#endif // __clang__ || __GNUC__
#endif // not defined JSON_HAS_RVALUE_REFERENCES
#ifndef JSON_HAS_RVALUE_REFERENCES
#define JSON_HAS_RVALUE_REFERENCES 0
#endif
#ifdef __clang__
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
# endif // GNUC version
#endif // __clang__ || __GNUC__
#if !defined(JSONCPP_DEPRECATED)
#define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
#if __GNUC__ >= 6
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
#endif
#if !defined(JSON_IS_AMALGAMATION)
# include "version.h"
# if JSONCPP_USING_SECURE_MEMORY
# include "allocator.h" //typedef Allocator
# endif
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
typedef int64_t Int64;
typedef uint64_t UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
#if JSONCPP_USING_SECURE_MEMORY
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
#define JSONCPP_ISTREAM std::istream
#else
#define JSONCPP_STRING std::string
#define JSONCPP_OSTRINGSTREAM std::ostringstream
#define JSONCPP_OSTREAM std::ostream
#define JSONCPP_ISTRINGSTREAM std::istringstream
#define JSONCPP_ISTREAM std::istream
#endif // if JSONCPP_USING_SECURE_MEMORY
} // end namespace Json
#endif // JSON_CONFIG_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/config.h
// //////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
// Copyright 2007-2010 Baptiste Lepilleur
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#ifndef JSON_FORWARDS_H_INCLUDED
#define JSON_FORWARDS_H_INCLUDED
#if !defined(JSON_IS_AMALGAMATION)
#include "config.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef unsigned int ArrayIndex;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED
// //////////////////////////////////////////////////////////////////////
// End of content of file: include/json/forwards.h
// //////////////////////////////////////////////////////////////////////
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
This diff is collapsed.
This diff is collapsed.
Copyright (c) 2000-2017 Chih-Chung Chang and Chih-Jen Lin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither name of copyright holders nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file