48  NeuralNetwork* nnObj = MMgetPointer<NeuralNetwork*>(m, MTOP(obj));
 
   50  MMsetPointer<NeuralNetwork*>(m, MTOP(obj), 0);
 
 
   66  int sensibility = MMpull(m);
 
   67  int nbval = MMpull(m);
 
   69  int channel = MMget(m, 0);
 
   71  if (channel == NIL || nbval == NIL)
 
   74    MMechostr(MSKDEBUG, 
"_CRml : failed -> NIL parameter used during contruction\n");
 
   78  if (sensibility == NIL)
 
   79    sensibility = FTOM(0.8f);
 
   91  catch (
const cv::Exception& e)
 
   93    MMechostr(MSKDEBUG, 
const_cast<char*
>(e.what()));
 
   98  if ((MMpushPointer(m, neuralnetwork) != 0))
 
  101    SAFE_DELETE(neuralnetwork);
 
  102    MMechostr(MSKDEBUG, 
"_CRML : Memory allocation failed\n");
 
  107  MMechostr(MSKDEBUG, 
"_CRML ...object creation successful\n");
 
  108        return OBJcreate(m, 
OBJMLSCOL, SCOL_PTR neuralnetwork, NIL, 0);
 
 
  120MMechostr(MSKDEBUG, 
"_DSml\n");
 
  123  int mlTab = MMget(m, 0);
 
  126    MMechostr(MSKDEBUG, 
"_DSML : object NIL");
 
  133        MMset(m, 0, ITOM(0));
 
  136  MMechostr(MSKDEBUG, 
"ok\n");
 
 
  150  int list = MMpull(m);
 
  151  int mlTab = MMget(m, 0);
 
  152  if (mlTab == NIL || list == NIL)
 
  154    MMechostr(MSKDEBUG, 
"_MlPredict : failed to fetch neural network");
 
  159  NeuralNetwork* nn = MMgetPointer<NeuralNetwork*>(m, MTOP(mlTab));
 
  162    MMechostr(MSKDEBUG, 
"_MlPredict : failed");
 
  168  std::vector<cv::Point3d> input;
 
  173    int tuple = MTOP(MMfetch(m, list, 0));
 
  175    vec.x       = MTOF(MMfetch(m, tuple, 0));
 
  176    vec.y       = MTOF(MMfetch(m, tuple, 1));
 
  177    vec.z       = MTOF(MMfetch(m, tuple, 2));
 
  179    input.push_back(vec);
 
  180    list = MTOP(MMfetch(m, list, 1));
 
  184  MMset(m, 0, ITOM(0));
 
 
  199  int name = MMpull(m);
 
  200  int list = MMpull(m);
 
  201  int mlTab = MMget(m, 0);
 
  203  if (mlTab == NIL || list == NIL || name == NIL)
 
  205    MMechostr(MSKDEBUG, 
"_MlAddTrainingData : received nil parameter");
 
  210  std::string label = MMstartstr(m, MTOP(name));
 
  211  NeuralNetwork* nn = MMgetPointer<NeuralNetwork*>(m, MTOP(mlTab));
 
  214    MMechostr(MSKDEBUG, 
"_MlAddTrainingData : failed");
 
  220  std::vector<cv::Point3d> input;
 
  225    int tuple = MTOP(MMfetch(m, list, 0));
 
  227    vec.x       = MTOF(MMfetch(m, tuple, 0));
 
  228    vec.y       = MTOF(MMfetch(m, tuple, 1));
 
  229    vec.z       = MTOF(MMfetch(m, tuple, 2));
 
  231    input.push_back(vec);
 
  232    list = MTOP(MMfetch(m, list, 1));
 
  237  MMset(m, 0, ITOM(0));
 
 
  249  int mlTab = MMget(m, 0);
 
  256  NeuralNetwork* nn = MMgetPointer<NeuralNetwork*>(m, MTOP(mlTab));
 
  259    MMechostr(MSKDEBUG, 
"_MlTrain : failed");
 
  266  MMset(m, 0, ITOM(0));
 
 
  280  int ifile = MMpull(m);
 
  281  int mlTab = MMget(m, 0);
 
  282  if (mlTab == NIL || ifile == NIL)
 
  284    MMechostr(MSKDEBUG, 
"_MlSaveData : failed");
 
  289  NeuralNetwork* nn = MMgetPointer<NeuralNetwork*>(m, MTOP(mlTab));
 
  292    MMechostr(MSKDEBUG, 
"_MlSaveData : failed");
 
  297        std::string nameFile = MMstartstr(m, MTOP(ifile));
 
  302  catch(
const cv::Exception&)
 
  304    MMechostr(MSKDEBUG, 
"_MlSaveData : failed");
 
  309  MMset(m, 0, ITOM(0));
 
 
  322  int ifile = MMpull(m);
 
  323  int mlTab = MMget(m, 0);
 
  324  if (mlTab == NIL || ifile == NIL)
 
  326    MMechostr(MSKDEBUG, 
"_MlLoadData : failed");
 
  331  NeuralNetwork* nn = MMgetPointer<NeuralNetwork*>(m, MTOP(mlTab));
 
  334    MMechostr(MSKDEBUG, 
"_MlLoadData : failed");
 
  339        std::string nameFile = MMstartstr(m, MTOP(ifile));
 
  342  MMset(m, 0, ITOM(0));
 
 
  355  int mlTab = MMget(m, 0);
 
  358    MMechostr(MSKDEBUG, 
"_MlGetCategories : failed");
 
  363  NeuralNetwork* nn = MMgetPointer<NeuralNetwork*>(m, MTOP(mlTab));
 
  366    MMechostr(MSKDEBUG, 
"_MlGetCategories : failed");
 
  378  for(
unsigned int i = 0; i < names.size(); i++)
 
  380    if ((k = Mpushstrbloc(m, (
char*)names[i].c_str())))
 
  387        for(
unsigned int j = 0; j < names.size(); j++)
 
  391                if ((k = MBdeftab(m)))
 
 
  406        MMechostr(MSKDEBUG, 
"_CBMlTrainingFinished training finished\n");
 
 
  414    MMechostr(MSKDEBUG, 
"getMlTrainingFinished ...MlTraining error\n");
 
  417  return OBJcallreflex(m, 0);
 
 
  427        MMechostr(MSKDEBUG, 
"_CBMlDetect training finished\n");
 
 
  433  std::string* category = (std::string*)msg_ptr;
 
  436    MMechostr(MSKDEBUG, 
"getMlDetectionCb ...MlDetection error\n");
 
  442  Mpushstrbloc(m, (
char*)category->c_str());
 
  443  int p = OBJcallreflex(m, 1);
 
 
  461  "_MlAddTrainingData",
 
  462  "_MlAddDetectionData",
 
  463  "_CBMlTrainingFinished",
 
 
  504  "fun [Chn I I F] ObjMl",               
 
  506  "fun [ObjMl [[F F F] r1] S] I",        
 
  507  "fun [ObjMl [[F F F] r1]] I",          
 
  508  "fun [ObjMl fun [ObjMl u0] u1 u0] ObjMl",  
 
  511  "fun [ObjMl] [S r1]",                  
 
  513  "fun [ObjMl fun [ObjMl u0 S] u1 u0] ObjMl"  
 
  534  MMechostr(MSKDEBUG,
" > Loading MlToolkit\n");
 
  546        MMechostr(MSKDEBUG,
" > Successfully Loaded\n");
 
#define SCOL_ML_DETECTION_CB
 
#define SCOL_ML_TRAINING_FINISHED_CB
 
int LoadMlToolkit(mmachine m)
 
void Save(std::string saveFile)
 
std::vector< std::string > GetCategories()
 
void Load(std::string filename)
 
void AddTrainingData(std::vector< cv::Point3d > input, std::string label)
 
void AddDetectionData(std::vector< cv::Point3d >)
 
int _MlGetCategories(mmachine m)
Get the ML loaded categories Prototype: fun [ObjMl] [S r1].
 
int _MlTrain(mmachine m)
Launch the training of the nn Prototype: fun [ObjMl] I.
 
int _DSml(mmachine m)
destroy a neural network Prototype: fun [ObjMl] I
 
int _MlAddTrainingData(mmachine m)
Add data to learn to the format <input, label> Prototype: fun [ObjMl [[F F F] r1] S] I.
 
int _MlSaveData(mmachine m)
Save the settings of a trained neural network Prototype: fun [ObjMl W] I.
 
int _CRml(mmachine m)
Create a new neural network Prototype: fun [Chn I F] ObjMl.
 
int _CBMlDetect(mmachine m)
Set a CB function linked to detection signal Prototype: fun [ObjMl fun [ObjMl u0 S] u1 u0] ObjMl.
 
int _MlLoadData(mmachine m)
Load an already trained file neural network AND the used parameters (high level) Prototype: fun [ObjM...
 
int _MlAddDetectionData(mmachine m)
Get a label for the input Prototype: fun [ObjMl [[F F F] r1]] I.
 
int _CBMlTrainingFinished(mmachine m)
Set a CB function linked to the finished training signal Prototype: fun [ObjMl fun [ObjMl u0] u1 u0] ...