Stores the annotated data from the Watche(s) at the no-sql mongodb database and starts a trainings classification.
Navigate into the folder config
and create four files with extactly the following names:
database.js
secrets.js
pythonconfig.js
stats_data_pathes.js
In this version the MongoDB database runs locally on the server so there is no direct access to the database via http requests or something else. The webservers backend connects to the database server so webserver and database server has to run on the same machine.
The annotation data is stored in the MongoDB database with the:
Database-Name: nativeannodb
Database-Collection: nativeannotateddatasets
This settings are declared in the files DataModels.js and database.js so update explaination here if changes to this files occurred!
Paste the following code snippet in your database.js file and edit the secret and database name to your needs:
module.exports = {
'secret': 'meansecure',
'database': 'mongodb://localhost/nativeannodb'
};
To access the api there is an authentication process. To specify the authentication data, the valid username and password the needs to be hard coded in the file called secrets.js
in folder config
.
Paste the following code snippet in your secrets.js file and edit the username and password to your ones:
module.exports = {
'APIUSER': 'TypeUsernameHere',
'APIACCESS': 'TypeAPIAccessPasswordHere'
};
Note: The secrets.js file is not part of this repo. After cloning the repository you have to create the file in the config folder and paste your own authentication code in form of the example code shown above. Otherwise you will alwas get authentication errors while transmitting data to the server.
It is highly recommended to use a authentication and do not let the api routes be unprotected!
To start a live classification the live classification script path needs to be declared. Also the path to the python excecutable needs to be defined in the pythonconfig.js
file.
Paste the following code snippet in your pythonconfig.js file and edit the path of the live_classification script and the path of the python executable to your needs:
// Script paths and python executable
module.exports = {
'scriptPath': 'C:/path-to-the-file/live_classification.py',
'pythonExecutable':'C:/path-to-your/Python37/python.exe'
};
To start a live classification the live classification script path needs to be declared. Also the path to the python excecutable needs to be defined in the pythonconfig.js
file.
Paste the following code snippet in your stats_data_pathes.js file and edit the path of the files needed for the system to store the data in:
// Paths to the stats and punch data files
module.exports = {
'punch_data_path': 'C:/path-to-the-file/punch_data.json',
'clear_punch_recognition_stats_path': 'C:/path-to-the-file/clear_punch_stats.json',
'punch_recognition_stats_path': 'C:/path-to-the-file/punch_stats.json'
};
Important: Make shure to create the following files under the path you defined above:
- punch_data.json
- clear_punch_stats.json
- punch_stats.json
Copy the content below in the punch_data.json
file:
{}
Copy the content below in the punch_stats.json
AND the clear_punch_stats
file:
{
"absoluteFailWinSums": [
{
"hands": [
[
0,
0
],
[
0,
0
]
]
},
{
"hands": [
[
0,
0
],
[
0,
0
]
]
},
{
"hands": [
[
0,
0
],
[
0,
0
]
]
},
{
"hands": [
[
0,
0
],
[
0,
0
]
]
}
],
"absoluteHandOnlyFailsSums": [
0,
0
],
"absolutePunchTypeOnlyFailsSums": [
0,
0,
0,
0
],
"absoluteHandOnlyWinsSums": [
0,
0
],
"absolutePunchTypeOnlyWinsSums": [
0,
0,
0,
0
],
"absolutePositiveAccuracy": 0,
"absoluteNegativeAccuracy": 0,
"relativeAccuracy": 0
}
In the project root run via the cli the command below to install all dependencies into the node_modules folder:
npm i
First: The MongoDB database server has to run to start the webserver. So please make shure to start your MongoDB database server first.
After the database server is running, in the main project root enter the following line in the cli and press enter to start the server:
node ./bin/www
Note: If you don't want to use a database server you have to uncomment the following lines in the app.js
file to avoid the error message of the missing database server instance when starting the webserver:
/**
* Try to connect to database
* Uncomment the block below if you dont have
* a database server running at the moment
*/
/*
mongoose.connect(config.database, { promiseLibrary: require('bluebird') })
.then(() => console.log('connection succesful'))
.catch((err) => {
console.error(err.message);
console.log("Error while connection to database. Exit process!");
process.exit(0);
}
);
*/
It is highly recommended to use a MongoDB database server to use the annotation functionalities of the smartwatch app.