MSeg Documentation¶
MSeg is a framework for the ArmarX robot development environment, built to run and evaluate motion segmentation algorithms.
It provides the core functionality to easily integrate motion segmentation algorithms written in various programming languages. To integrate a motion segmentation algorithm, a supplied Programming Language Interface (PLI) can be used.
For more information about the structure of MSeg, please refer to the architectural overview.
Note
If you encounter a problem in the documentation or in MSeg, feel free to open a new issue in the issue tracker or send an email to incoming+h2t/kit-mseg/mseg@gitlab.com (this will create an issue in the issue tracker).
Installation and Setup¶
Install and setup MSeg using the quickstart guide (recommended) or compile it from source.
- Quickstart (recommended)
- Compile MSeg from Source
Integrate a Motion Segmentation Algorithm¶
Guides on how to integrate a motion segmentation algorithm into the core module.
- Integrate a C++ Algorithm
- Integrate a Java Algorithm
- Integrate a Python Algorithm
- Integrate a MATLAB Algorithm
If you are indecisive about the programming language, we would recommend to use Python.
Further Reference¶
Developer Guides¶
Publication¶
- PDF version of the paper
- BibTeX:
@INPROCEEDINGS {Dreher2017,
author = {Christian R. G. Dreher and Nicklas Kulp and Christian Mandery and Mirko W\"achter and Tamim Asfour},
title = {A Framework for Evaluating Motion Segmentation Algorithms},
booktitle = {IEEE/RAS International Conference on Humanoid Robots (Humanoids)},
pages = {83--90},
year = {2017},
}
License¶
The source code of the MSeg framework is licensed under the GPL 2.0 License.
Quickstart¶
This guide will show how to install MSeg on a 64 bit Ubuntu machine. This includes the MSeg Core Module, all PLIs, and all available tools to use with MSeg.
Note
It is strongly recommended to use MSeg with Ubuntu 14.04 x64, as it eases the installation process drastically. If this should be a problem, consider using a virtual machine like VirtualBox and install Ubuntu 14.04 there.
Preconditions¶
- Freshly installed Ubuntu 14.04.5 LTS x64 trusty [64-bit PC (AMD64) desktop image]
sudo
privileges- Approx. hard disk size required: 1 GiB (Make sure to have enough space if you want to install additional software like IDE’s or MATLAB)
Installation¶
Open a terminal ( Ctrl
+ Shift
+ T
) and add the H2T
package server which includes all neccessary binaries.
# Add H2T signing key and package server
$ curl https://packages.humanoids.kit.edu/h2t-key.pub | sudo apt-key add -
$ echo -e "deb http://packages.humanoids.kit.edu/trusty/main trusty main\ndeb http://packages.humanoids.kit.edu/trusty/testing trusty testing" | sudo tee /etc/apt/sources.list.d/armarx.list
# Update lists
$ sudo apt update
Now MSeg can be installed. This command will download roughly 300 MiB, resulting in about 1 GiB after installation.
# Download and install MSeg and all its dependencies
$ sudo apt install mseg
Depending on what programming language(s) you prefer for your algorithm, you should also install the corresponding Programming Language Interface(s):
# For C++ algorithms
$ sudo apt install mseg-pli-cpp
# For Java algorithms
$ sudo apt install mseg-pli-java
# For Python algorithms
$ sudo apt install mseg-pli-python
# For MATLAB algorithms
$ sudo apt install mseg-pli-matlab
Initialisation¶
After the installation, both ArmarX and MSeg need to be initialised.
# Run armarx for the first time. You will be prompted to add a line to
# .bashrc for autocompletion. Accept with `y`
$ armarx
# Source .bashrc as indicated
$ source ~/.bashrc
# Download the MSeg datasets of labelled whole-body motion recordings
$ msegdata fetch
Now we’re ready for the first run.
# First, we need to start ArmarX
$ armarx start
# Now we need to start the MSeg core module
$ msegcm start
# Eventually, launch the ArmarX GUI
$ armarx gui
The GUI will now load and eventualy, a popup should appear.
- You may check the checkbox
Do not show again
. - Push the
Open empty GUI
button. - You can now use the MSeg GUI by clicking on
Add Widget | MSeg
.
The MSeg GUI should now show up like this:

Integrate a C++ Algorithm¶
This guide will show you how to setup your workspace to integrate your own C++ motion segmentation algorithm using the C++ PLI. It is assumed that you either followed the quickstart guide or you compiled MSeg from source.
Install the Skeleton Project¶
We will use the mseggen
terminal tool to install a skeleton project.
# Define the base directory where the project directory should be located
$ export $PROJECT_BASE_DIR=~/projects
# Run the generation tool to create the skeleton.
# If your algorithm requires training, add the --train flag
$ mseggen -b $PROJECT_BASE_DIR --cpp ExampleAlgorithm
Compiling the Algorithm¶
Your project should now look similar to this (If you changed the algorithm name the paths will be slightly altered):
$PROJECT_BASE_DIR/
`--- examplealgorithm
|--- build/
|--- source/
| |--- examplealgorithm.cpp
| |--- examplealgorithm.h
| `--- main.cpp
`--- CMakeLists.txt
To compile the skeleton, we change into the build folder and run the corresponding commands like this:
# Change into the build folder
$ cd $PROJECT_BASE_DIR/examplealgorithm/build
# Run CMake
$ cmake ..
# Run make
$ make
You may get warnings about unused parameters, but eventually, the project should compile.
Run the Algorithm¶
To run the algorithm, both ArmarX and the MSeg core module must be running. You can then start the algorithm like this:
# Change into the build folder
$ cd $PROJECT_BASE_DIR/examplealgorithm/build
# Run the algorithm
$ ./examplealgorithm
You should now see an output like this:
user@machine:~/projects/examplealgorithm/build$ ./examplealgorithm
Connecting to MSeg core module...
Connection established
ExampleAlgorithm ready
You can stop the algorithm with Ctrl
+ C
at any time.
How to Proceed¶
You can now start implementing your algorithm. You may also want to get more familiar with the SegmentationAlgorithm API reference, the MSeg GUI and the msegcm, msegdata, and mseggen terminal tools.
Integrate a Java Algorithm¶
This guide will show you how to setup your workspace to integrate your own Java motion segmentation algorithm using the Java PLI. It is assumed that you either followed the quickstart guide or you compiled MSeg from source.
Install the Skeleton Project¶
We will use the mseggen
terminal tool to install a skeleton project.
# Define the base directory where the project directory should be located
$ export $PROJECT_BASE_DIR=~/projects
# Run the generation tool to create the skeleton.
# If your algorithm requires training, add the --train flag
$ mseggen -b $PROJECT_BASE_DIR --java ExampleAlgorithm
Compiling the Algorithm¶
Your project should now look similar to this (If you changed the algorithm name the paths will be slightly altered):
$PROJECT_BASE_DIR/
`--- examplealgorithm
|--- build/
|--- lib/
|--- src/
| `--- ExampleAlgorithm.java
`--- build.xml
To compile the skeleton, we change into the project root folder and run ant:
# Change into the build folder
$ cd $PROJECT_BASE_DIR/examplealgorithm
# Run ant
$ ant
Run the Algorithm¶
To run the algorithm, both ArmarX and the MSeg core module must be running. You can then start the algorithm like this:
# Change into the build folder
$ cd $PROJECT_BASE_DIR/examplealgorithm/build
# Run the algorithm
$ java -jar examplealgorithm.jar
You should now see an output like this:
user@machine:~/projects/examplealgorithm/build$ java -jar examplealgorithm.jar
Connecting to MSeg core module...
Connection established
ExampleAlgorithm ready
You can stop the algorithm with Ctrl
+ C
at any time.
How to Proceed¶
You can now start implementing your algorithm. You may also want to get more familiar with the SegmentationAlgorithm API reference, the MSeg GUI and the msegcm, msegdata, and mseggen terminal tools.
Integrate a Python Algorithm¶
This guide will show you how to setup your workspace to integrate your own Python motion segmentation algorithm using the Python PLI. It is assumed that you either followed the quickstart guide or you compiled MSeg from source.
Install the Skeleton Project¶
We will use the mseggen
terminal tool to install a skeleton project.
# Define the base directory where the project directory should be located
$ export $PROJECT_BASE_DIR=~/projects
# Run the generation tool to create the skeleton.
# If your algorithm requires training, add the --train flag
$ mseggen -b $PROJECT_BASE_DIR --python ExampleAlgorithm
Run the Algorithm¶
To run the algorithm, both ArmarX and the MSeg core module must be running. You can then start the algorithm like this:
# Change into the project folder
$ cd $PROJECT_BASE_DIR/examplealgorithm
# Run the algorithm
$ python examplealgorithm.py
You should now see an output like this:
user@machine:~/projects/examplealgorithm$ python examplealgorithm.py
Connecting to MSeg core module...
Connection established
ExampleAlgorithm ready
You can stop the algorithm with Ctrl
+ C
at any time.
How to Proceed¶
You can now start implementing your algorithm. You may also want to get more familiar with the SegmentationAlgorithm API reference, the MSeg GUI and the msegcm, msegdata, and mseggen terminal tools.
Integrate a MATLAB Algorithm¶
This guide will show you how to setup your workspace to integrate your own MATLAB motion segmentation algorithm using the MATLAB PLI. It is assumed that you either followed the quickstart guide or you compiled MSeg from source.
Install the Skeleton Project¶
We will use the mseggen
terminal tool to install a skeleton project.
# Define the base directory where the project directory should be located
$ export $PROJECT_BASE_DIR=~/projects
# Run the generation tool to create the skeleton.
# If your algorithm requires training, add the --train flag
$ mseggen -b $PROJECT_BASE_DIR --matlab ExampleAlgorithm
Run the Algorithm¶
To run the algorithm, both ArmarX and the MSeg core module must be running. You can then start the algorithm like this:
# Change into the project folder
$ cd $PROJECT_BASE_DIR/examplealgorithm
# Run the algorithm
$ ./main
Note
The main
executable cannot be started from within MATLAB.
Running the algorithm from the terminal, you should now see an output like this:
user@machine:~/projects/examplealgorithm$ ./main
Initialising MATLAB
Connecting to MSeg core module...
Connection established
ExampleAlgorithm ready
You can stop the algorithm with Ctrl
+ C
at any time.
How to Proceed¶
You can now start implementing your algorithm. You may also want to get more familiar with the SegmentationAlgorithm API reference, the MSeg GUI and the msegcm, msegdata, and mseggen terminal tools.
Compile MSeg from Source¶
This guide will show how to compile the MSeg core module from source on a 64 bit Ubuntu machine.
Note
It is strongly recommended to use the MSeg core module with Ubuntu 14.04, as it eases the installation process drastically. If this should be a problem, consider using a virtual machine like VirtualBox and install Ubuntu 14.04 there.
Preconditions¶
- Freshly installed Ubuntu 14.04.5 LTS x64 “trusty” [64-bit PC (AMD64) desktop image]
sudo
privileges- Approx. hard disk size required: 1 GiB (Make sure to have enough space if you want to install additional software like IDEs or MATLAB)
The H2T Package Server¶
First, we will add the H2T package server so that the packages MSeg depends on become available. Open a terminal
( Ctrl
+ Shift
+ T
) and run:
# Add H2T key and add repositories
$ curl https://packages.humanoids.kit.edu/h2t-key.pub | sudo apt-key add -
$ echo -e "deb http://packages.humanoids.kit.edu/trusty/main trusty main\ndeb http://packages.humanoids.kit.edu/trusty/testing trusty testing" | sudo tee /etc/apt/sources.list.d/armarx.list
# Update lists
$ sudo apt update
The MSeg Umbrella Repository¶
Due to the variety of programming languages, MSeg is split into several repositories. To ease the installation and setup, we provide the MSeg Umbrella Repository which manages the dependencies between the subprojects. To fetch the repository, we will need Git:
# Install Git
$ sudo apt install git
Now we can clone the MSeg Umbrella Repository:
# Clone the MSeg Umbrella Repository
$ git clone https://gitlab.com/h2t/kit-mseg/mseg.git
# Change into the repository
$ cd mseg
If you are a developer, you will probably want to leave the release untouched to use the latest versions of all subprojects and directly skip to the next section.
However, for using MSeg productively or packaging it, a stable release must be checked out. The releases of the MSeg Umbrella Repository are coupled with the MSeg Core Module. Each tagged release of the MSeg Core Module corresponds with a branch in the umbrella repository.
# Check out a stable release
$ git checkout 1.2.0
Initialising MSeg¶
The MSeg Umbrella Repository comes with a makefile which exposes several rules. One of them will be used
to initialise all subprojects of MSeg, namely make init
.
The init
rule is designed to fail as long as the environment is not set up properly for MSeg to run. This
includes cloning and using the right versions, dependency checking, and environment variable setup. When
the init
rule fails, it will print the proper command to fix the situation. Do so, and run make init
again afterwards.
The following setup excerpt will show each possible fail – don’t be confused if the init
rule didn’t fail
for you as depcited here – this just means that the regarding requirement is already met and no action is needed.
Please read the actual error messages you get carefully.
# Run init for the first time. This will take quite long
# as the repositories will have to be downloaded.
$ make init
... Cloning ...
... Checking out stable branches if set ...
ERROR: Dependencies not satisfied. To install them, please run
`make depsdeb | xargs sudo apt install -y`. This may download
up to 1.1 GiB of data
# This error means that there are Debian dependencies which are
# missing. Running the suggested command will collect the required
# Debian packages from all subprojects which can be piped to
# apt
$ make depsdeb | xargs sudo apt install -y
... Installing Debian dependencies ...
# Since the last attempt failed, we need to run init again
$ make init
...
ERROR: Dependencies not satisfied. To install them, please run
`make depspip | xargs sudo pip install`
# This error occurs when there are Python dependencies which are
# missing. Again, we run the suggested command
$ make depspip | xargs sudo pip install
... Installing Python dependencies ...
# Last init attempt failed, so retry
$ make init
...
ERROR: Dependencies not satisfied. To install them, please run
`make depspip3 | xargs sudo pip3 install`
# Similar to Python, the Python3 dependencies may be missing
# and need to be installed as suggested
$ make depspip3 | xargs sudo pip3 install
... Installing Python dependencies ...
# Failed again, so re-run init
$ make init
...
ERROR: bashrc-file changed and needs to be resourced. Run
`source ~/.bashrc`
# This error occurs after the bashrc entries of all subprojects
# were collected and changed or are not sourced at all. Simply
# sourcing the ~/.bashrc should solve that
$ source ~/.bashrc
# init again
$ make init
Initialising: FINISHED SUCCESSFULLY
# Now we're good to go
Installing MSeg¶
After we initialised MSeg successfully, we should now be able to safely compile and install MSeg.
# Install MSeg
$ make install
This rule will install all subprojects of MSeg so that the dependencies between the subprojects are always met.
Note
The install process may take quite a while, but you can utilise your multicore processor if
you have one using the THREADS
environment variable to speed it up. For example, if you
have four cores, you could run THREADS=4 make install
to make use of them. As of now,
this only applies to C++ compilations, though.
Configuring ArmarX¶
With everything being set up, we can now start ArmarX for the first time. Config files needed later will be created then.
# Run armarx for the first time. You will be prompted to add a line to
# .bashrc for autocompletion. Accept with y
$ armarx
# Source .bashrc as indicated
$ source ~/.bashrc
# Run armarx again since the previous step just modified the .bashrc file
$ armarx start
The config file now got created. Run the following command and apply the changes below.
# Open config file
$ gedit ~/.armarx/default.cfg
Changes:
++ Ice.MessageSizeMax=10240
Ice.Default.Locator=IceGrid/Locator:tcp -p 12454 -h localhost
IceGrid.Registry.Client.Endpoints=tcp -p 12454
ArmarX.MongoHost=localhost
ArmarX.MongoPort=12455
#Put your custom ArmarX Packages in this list, e.g. so that the gui can find their plugins.
-- ArmarX.AdditionalPackages=
++ ArmarX.AdditionalPackages=MSeg
Save and close the config file. Finally, restart ArmarX.
# Restart ArmarX
$ armarx reset
# Start ArmarX GUI
$ armarx gui
The GUI will now load and eventualy, a popup should appear.
- You may check the checkbox
Do not show again
. - Push the
Open empty GUI
button.
Starting the MSeg Core Module¶
You can now use the MSeg GUI by clicking on Add Widget | MSeg
. You should see a
window similar to this:

Note the red text which says:
MSeg waiting for EvaluationController and SegmentationController
Both the EvaluationController
and the SegmentationController
, as well as the DataExchange
,
which is not listed here, are components that form the core module. In order for the GUI to work,
these components have to be started.
# Start the core module
$ msegcm start
The components of the core module are now running. If you now head back to the MSeg GUI, you should see that the warning showed before disappeared.

Remember to start these components every time you reboot your computer. Also, when a component
crashes, it may be required to restart them using msegcm restart
. You will be notified if components
need to be restarted by the red text as shown in the first graphic.
Notes on Continuous Integration¶
For the continuous integration, the MSeg Umbrella Repository can be utilised, especially the bash scripts, which will be discussed after the general information.
General¶
For each MSeg Core Module version (i.e. for each tag in the Git repository core
),
a new branch in the umbrella repository will be created. For each patch in one of the
subprojects, the corresponding branch will be updated (i.e. push events on that branch).
The convention is as follows: If the current version of the MSeg Core Module is v1.2.0,
there will be a branch “1.2.0” in the umbrella repository. If a patch for one of the
subprojects is released, that specific release will be updated in the stable-refs.cfg
file.
Any events on the master
branch must be ignored.
Provided Script Files¶
The provided scripts of the MSeg Umbrella Repository are located in the ./scripts
folder. However, they should be called from within the root directory of the umbrella
repository, due to the way bash resolves paths.
./scripts/clone-repos.sh
¶
Clones all subprojects into the expected locations relative to the umbrella repositories root.
./scripts/change-to-stable-refs.sh
¶
Uses the config file ./stable-refs.cfg
to change to the refs known to be stable and
work well with each other.
./scripts/submake.sh
¶
This script helps to execute a make rule on all subprojects. It fails gracefully if the make rule does not exist one or more of the subprojects (i.e. it ignores it).
The script expects an input parameter which is the rule to be executed on all subprojects.
Rules which are usually called are the following:
.depsdeb
: Runningbash ./scripts/submake.sh .depsdeb
yields the Debian dependencies of all subprojects combined. Running this command will result in an unordered list with potential duplicate entries, with the individual entries being separated by new lines\n
. Therefore it is recommended to pipe the result of this rule intosort -u
, which sorts the list and gets rid of all duplicate entries:bash ./scripts/submake.sh .depsdeb | sort -u
..depspip
and.depspip3
: Conceptually the same as.depsdeb
, but these rules yield the Python deps (inpip
) and the Python3 deps (inpip3
) respectively..bashrc
: Returns the entries of each subproject which should be added to the.bashrc
file. Due to the fact that most of those entries are for convenience only, this rule is irrelevant for the CI setup, with the exception of required environment variables. See environment variables for this purpose.install
: Installs all subprojects, however this installation looks like. The responsibility for installing the project correctly is held by the correspondingmakefile
in the subprojects root directory.package
: Packages the subprojects, which yields.deb
releases in thedeb-dist
folder in each subproject. Themakefile
of the corresponding subproject is responsible for a proper packaging. After running this rule, all.deb
releases can be collected by runningmkdir ./deb-dist
&&
mv **/deb-dist/*.deb ./deb-dist/
. Please note: thepackage
rule does not require that theinstall
rule was ran in advance.
Other scripts¶
All other scripts are not relevant or not suitable for CI pipelines.
Environment Variables¶
Some projects require that certain environment variables are set. Some of the following
environment require that the root directory of the MSeg Umbrella Repository is set as
MSEG_DIR
. The name of this environment variable, however, is changable. Change the
exorts accordingly if the environment variable has a different name on your system.
CLASSPATH
¶
With MSEG_DIR
being the root directory of the MSeg Umbrella Repository, the Java
classpath needs to be set as follows:
export CLASSPATH="${CLASSPATH}:${MSEG_DIR}/core-ice/buildjava/build/lib/mseginterfacesjava.jar"
export CLASSPATH="${CLASSPATH}:${MSEG_DIR}/pli-java/build/lib/plijava.jar"
Other than classpath or other environment variables, Java unfortunately does not support a standard way of resolving local dependencies.
MSEG_PLI_MATLAB_DIR
¶
The MATLAB PLI tries to install .m
libraries. If the MSEG_PLI_MATLAB_DIR
is not
set, it will try to install those libraries in system paths where it has no access to.
With MSEG_DIR
being the root directory of the MSeg Umbrella Repository:
export MSEG_PLI_MATLAB_DIR="${MSEG_DIR}/pli-matlab"
MSEG_TOOLS_DIR
¶
MSeg tools tries to install templates to use with the generator. If the MSEG_TOOLS_DIR
is not set, it will try to install those libraries in system paths where it has no access to.
With MSEG_DIR
being the root directory of the MSeg Umbrella Repository:
export MSEG_TOOLS_DIR="${MSEG_DIR}/mseg-tools"
THREADS
¶
While this environment variable is not mandatory, it can drastically speed up the pipeline. Set it to the number of cores available.
Example for a quad-core processor:
export THREADS=4
Currently, this environment variable is only used in C++ builds, but in the future it may be utilised in Java builds, too. Building independend subprojects in parallel may be possible as well.
Architectural Overview¶
The two most important parts of the MSeg framework are the MSeg Core Module on the one hand, and the Programming Language Interfaces (PLI’s) on the other hand. The following diagram shows a general overview.
The individual parts will be explained in detail in the following sections.
MSeg Core Module¶
The MSeg Core Module offers the MSeg GUI, a plugin for the ArmarX GUI, and consists of three components, namely:
- DataExchange: This component is a mediator between the MSeg Core Module
and a segmentation algorithm. With it, a segmentation algorithm can request
motion data which can be segmented, and it can report keyframes where a
segmentation occurs. Each segmentation algorithm has access to the
DataExchange component, exposed through a PLI as
DataExchangeProxy
. - SegmentationController: This component orchestrates the available segmentation algorithms, triggers a segmentation process, and collects the reported keyframes.
- EvaluationController: This component implements several metrics and measures from the literature to access the quality of a segmentation compared to a ground truth. There are three general approaches which are used to derive the number of true positives, false positives, false negatives and true positives (Standard approach, Margin approach, Integrated Kernel approach). With these numbers, several metrics are evaluated, for example precision and recall, F1-score, etc. For more information, please refer to our publication.
The Core Module also defines several communication interfaces (Com. Interfaces) in a programming-language-agnostic language called Slice from the ZeroC Ice library. Slice interfaces can be transpiled into concrete interfaces in a specific programming language. In the context of MSeg, each PLI is such a concrete interface.
PLI (Programming Language Interface)¶
A PLI (Programming Language Interface) is a concrete implementation of the interfaces defined by the MSeg Core Module. In particular, and from the perspective of the Core Module, a PLI is an implementation in a supported programming language (hence the name). Supported are C++, Java, Python and MATLAB.
On another abstraction layer, namely from the perspective of the segmentation
algorithm, the PLI offers an interface which has to be implemented by the
segmentation algoritm (the class SegmentationAlgorithm
).
Communication between the Core Module and an Algorithm¶
The following subsections discuss how the communication between the MSeg Core Module and an algorithm takes place in a particular direction.
Core Module ➜ Algorithm¶
The MSeg Core Module communicates with a segmentation algorithm only indirectly
via a PLI. The PLI is used as a proxy, since its interface is known to MSeg. It
is the responsibility of the PLI to forward the instructions of the Core Module
to the contrete motion segmentation algorithm implementation. For this purpose,
the SegmentationAlgorithm
interface is used, a class which should be derived
by the to-be implemented segmentation algorithm.
Algorithm ➜ Core Module¶
Only one part of the MSeg Core Module is exposed to the motion segmentation
algorithm, namely the DataExchange via the data
attribute of the class
SegmentationAlgorithm
. This attribute is an object of the type
DataExchangeProxy
and offers interfaces for the algorithm to fetch motion
recordings in several data formats for segmentation on the on hand, and to
report keyframes back on the other hand. The segmentation algorithm cannot
access arbitrary data – the segmentation controller decides what data is made
available for the segmentation algorithm. The segmentation controller also keeps
track of how the data was used (i.e. in an online manner “frame-by-frame”, or
offline “all-at-once”).
The mseg*
Terminal Tools¶
MSeg ships with three terminal tools, namely:
msegcm
Control the MSeg core modulemsegdata
Manage the datasetsmseggen
Help setting up new motion segmentation algorithm projects
Note
You can run <command> --help
at any time to get a quick overview on the usage and synopsis. If you need
more detail for a given subcommand, you can run <command> <subcommand> --help
instead. The usage of the tools
may change with future versions of MSeg. If the information on this page is contradicting the information given
from the --help
, always rely on that help.
msegcm
Tool¶
With msegcm
, the MSeg core module can be controlled.
Available subcommands¶
status
: Prints the status of the MSeg core module processesstart
: Start the MSeg core module processesstop
: Stop the MSeg core module processesrestart
: Stop and start the MSeg core module processes
If an unexpected error leads to the crash of one or more processes, you will need to restart the MSeg core module using
msegcm restart
. A crash can be diagnosed if msegcm status
indicates that the status of the MSeg core module is
either “mixed” or “stopped”.
Note
The MSeg core module cannot start properly if ArmarX is not running. You can query the status of ArmarX by
running armarx status
, and you can start it by running armarx start
.
msegdata
Tool¶
With msegdata
, the datasets available with MSeg can be managed. The datasets are not included by default because
newer datasets may still be useful for older versions of MSeg. The datasets are versioned separately for that reason.
Available subcommands¶
fetch
: Fetches the datasets and stores them locally into~/.mseg/datasets
(This is a Git repository). This subcommand must be ran once to initialise the datasets (see quickstart guide)update
: Updates the local datasets to the newest versions. Old versions will remain untouched
Note
If you are experienced with Git, then please note that msegdata
is merely a façade for the corresponding
Git repository (~/.mseg/datasets
) of the datasets. If you prefer, you can use Git in first place instead of
msegdata
. You are still advised to at least run msegdata fetch
to clone the Git repository into the
correct location.
mseggen
Tool¶
The mseggen
command is a helper tool to kick-start a new motion segmentation algorithm project. It creates all
source files (and build files, if appropriate) needed for a given programming language with well-commented stubs and
dummy-implementations.
Synopsis¶
mseggen [--base-path BASE_PATH] [--train] (--cpp | --python | --java | --matlab) <project-name>
- The option
--base-path
can be used to set the base path in which the project should be created. It defaults to the current working directory - The flag
--train
is optional. If set, the code will be included to use the train API. If not set, those parts will be commented out - The flags
--cpp
,--python
,--java
and--matlab
are mutually exclusive. Exactly one of them must be set <project-name>
is the name of the project, respectively the motion segmentation algorithm. It must me alphanumeric and start with a character
Examples¶
- To implement the PCA approach by Barbič in Java the usage would be:
mseggen --java PCABarbic
- To implement a machine learning algorithm in Python, located in
~/projects
:mseggen --base-path ~/projects --train --java MLApproach
The MSeg Graphical User Interface¶
Coming soon
SegmentationAlgorithm
Interface¶
All PLIs offer the class SegmentationAlgorithm
which can be derived in order to communicate with the core module.
Properties¶
Properties of SegmentationAlgorithm
.
data
¶
- Type:
- DataExchangeProxy
- Description
- Proxy to exchange data between the PLI and the core module. This property is initialised by the corresponding PLI and must not be overwritten.
name
¶
- Type:
- String
- Description:
- The name of the algorithm. The name must not be empty and must be alphanumeric and start with a character. Set this property in the constructor.
requiresTraining
¶
- Type:
- bool
- Default:
- false
- Description:
- Flag to indicate whether the algorithm should be trained. Set this property in the constructor.
trainingGranularity
¶
- Type:
- Granularity
- Default:
- Granularity.Medium
- Description:
- Used to filter the training ground truth data for the set granularity. Possible values are
Granularity.Fine
,Granularity.Medium
, andGranularity.Rough
. Set this property in the constructor. This property is only considered ifrequiresTraining
is set to true.
Methods¶
Methods of SegmentationAlgorithm
.
SegmentationAlgorithm()
or __init__()
or constructor.m
¶
- Signature:
SegmentationAlgorithm
()- Description:
- Constructor. Set properties like
name
,requiresTraining
ortrainingGranularity
here. Set algorithm parameters here.
train()
or train.m
¶
- Signature:
- void
train
()- Return:
- void
- Description:
- This method will be called for each motion recording in the training dataset. You can fetch the current motion recording here using the
data
property and use it to train your variables.
resetTraining()
or reset_training.m
¶
- Signature:
- void
resetTraining
()- Return:
- void
- Description:
- This method will be called after one part of the cross validation was executed. Make sure to reset all trained variables to not falsify the evaluation.
segment()
or segment.m
¶
- Signature:
- void
segment
()- Return:
- void
- Description:
- This method will be called for each motion recording in the testing dataset.
registerBoolParameter()
¶
- Signature:
- void
registerBoolParameter
(Stringname
, Stringdescription
, booldefaultValue
)- Return:
- void
- Description:
- Registers a boolean parameter
name
with a default value ofdefaultValue
to tweak in the GUI.
registerIntParameter()
¶
- Signature:
- void
registerIntParameter
(Stringname
, Stringdescription
, intdefaultValue
, intminimumValue
= INT_MIN, intmaximumValue
= INT_MAX)- Return:
- void
- Description:
- Registers an int parameter
name
with a default value ofdefaultValue
to tweak in the GUI. The allowed range of values can be controlled withminimumValue
andmaximumValue
.
registerFloatParameter()
¶
- Signature:
- void
registerFloatParameter
(Stringname
, Stringdescription
, floatdefaultValue
, intdecimals
= 2, floatminimumValue
= -FLOAT_MAX, floatmaximumValue
= FLOAT_MAX)- Return:
- void
- Description:
- Registers a float parameter
name
with a default value ofdefaultValue
to tweak in the GUI. The allowed range of values can be controlled withminimumValue
andmaximumValue
. The precision (number of decimals) can be controlled withdecimals
.
registerStringParameter()
¶
- Signature:
- void
registerStringParameter
(Stringname
, Stringdescription
, StringdefaultValue
)- Return:
- void
- Description:
- Registers a String parameter
name
with a default value ofdefaultValue
to tweak in the GUI.
registerJsonParameter()
¶
- Signature:
- void
registerJsonParameter
(Stringname
, Stringdescription
, JSONdefaultValue
)- Return:
- void
- Description:
- Registers a JSON parameter
name
with a default value ofdefaultValue
to tweak in the GUI.
getBoolParameter()
¶
- Signature:
- bool
getBoolParameter
(Stringname
)- Return:
- bool
- Description:
- Get a registered bool parameter by its
name
.
getIntParameter()
¶
- Signature:
- int
getIntParameter
(Stringname
)- Return:
- int
- Description:
- Get a registered int parameter by its
name
.
getFloatParameter()
¶
- Signature:
- float
getFloatParameter
(Stringname
)- Return:
- float
- Description:
- Get a registered float parameter by its
name
.
getStringParameter()
¶
- Signature:
- String
getStringParameter
(Stringname
)- Return:
- String
- Description:
- Get a registered String parameter by its
name
.
getJsonParameter()
¶
- Signature:
- JSON
getJsonParameter
(Stringname
)- Return:
- JSON
- Description:
- Get a registered JSON parameter by its
name
.
DataExchangeProxy
Interface¶
An instance of the DataExchangeProxy
class is accessible via the data
property of the derived
SegmentationAlgorithm instance. It is used to communicate with the core
module to exchange data.
Methods¶
Methods of DataExchangeProxy
.
getFrameCount()
¶
- Signature:
- int
getFrameCount
()- Return:
- int
- Description:
- Returns the total number of frames for the current motion recording.
getMMMFile()
¶
- Signature:
- String
getMMMFile
()- Return:
- String
- Description:
- Returns the MMM file of the current motion recording as String. MMM is an XML format file which can be parsed with various XML readers or the already existing MotionReaderXML for C++.
getGroundTruth()
¶
- Signature:
- List<int>
getGroundTruth
()- Return:
- List<int>
- Description:
- Returns the ground truth for the current motion recording with the granularity determined by the
trainingGranularity
property of the derived SegmentationAlgorithm instance.
getJointAnglesForFrame()
¶
- Signature:
- List<float>
getJointAnglesForFrame
(intframeNumber
)- Return:
- List<float>
- Description:
- Returns the joint angles of the frame with the number
frameNumber
for the current motion recording.
reportKeyFrame()
¶
- Signature:
- void
reportKeyFrame
(intframeNumber
)- Return:
- void
- Description:
- Reports that the frame with the number
frameNumber
is a key frame where a segmentation occurs.
reportKeyFrames()
¶
- Signature:
- void
reportKeyFrames
(List<int>frameNumbers
)- Return:
- void
- Description:
- Reports that the list of frame numbers
frameNumbers
are key frames where segmentations occur.
Data Type Mappings¶
Data types used in this documentation map to different data structures or constructs depending on the used programming language. The following table shows the corresponding mappings.
Language | bool | int | float | String | List | JSON |
---|---|---|---|---|---|---|
C++ | bool | int | double | std::string | std::vector | Json::Value |
Java | boolean | int | double | String | Array | org.json.JSONObject |
Python | bool | int | float | str | list | json |
Java | bool | int | float | char | list | py.json |
Changelog¶
Version 1.2¶
Bugfixes
- Fix a CMake dependency problem (core#81)
- Enable evaluation result export button only if results arrive (core#83)
Features
Version 1.1¶
Features
Bugfixes
- Load motions in the background (core#65)
- Disable segment current button (not yet implemented) (core#67)
- Fix a bug where motions are loaded twice (core#68)
- Disable segment and evaluate buttons while a new dataset ist being opened (core#71)
- Fix an issue where thousands separators could cause crashes (core#75)
- Fix issues with a more recent version of MMMTools (core#80)
Version 1.0¶
Bugfixes
- Fix an unimplemented method preventing Java PLI from compiling (core#30, core#31)
- Fix MATLAB dependency issues (core#56)
- Fix stacktrace output for MATLAB exceptions (core#59)
- Made everything locale independent (core#33, core#61)
- Fix various UI issues (core#44, core#60, core#64)
- Fix a bug where shutting down a Java algorithm would raise an exception
Features
- Include ZVC algorithm (core#25)
- Allow algorithms to require training data of a certain granularity (core#27)
- Add
mseg
tool - Add subcommand to
mseg
to generate a C++ skeleton project (core#35) - Add subcommand to
mseg
to generate a Python skeleton project (core#36) - Add commands to
mseg
to start/stop/restart the core module (core#37) - Add subcommand to
mseg
to generate a Java skeleton project (core#40) - Include MATLAB PLI (core#23)
- Add subcommand to
mseg
to generate a MATLAB skeleton project (core#42) - Improved error handling (core#47, core#49, core#50)
- Refactor algorithm name handling (core#48)
- Unify PLI output (core#45)
License¶
GNU GENERAL PUBLIC LICENSE¶
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble¶
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software–to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation’s software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author’s protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors’ reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone’s free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION¶
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The “Program”, below, refers to any such program or work, and a “work based on the Program” means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term “modification”.) Each licensee is addressed as “you”.
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the 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 Program specifies a version number of this License which applies to it and “any later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS¶
How to Apply These Terms to Your New Programs¶
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
one line to give the program's name and an idea of what it does.
Copyright (C) yyyy name of author
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'. This is free software, and you are welcome
to redistribute it under certain conditions; type `show c'
for details.
The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than show w and show c; they could even be mouse-clicks or menu items–whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a “copyright disclaimer” for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright
interest in the program `Gnomovision'
(which makes passes at compilers) written
by James Hacker.
signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.