| 81 | } |
| 82 | |
| 83 | int predict (double *data, int data_len, double *output, int *output_len, const char *json_params) |
| 84 | { |
| 85 | std::lock_guard<std::mutex> lock (models_mutex); |
| 86 | struct BrainFlowModelParams key ( |
| 87 | (int)BrainFlowMetrics::MINDFULNESS, (int)BrainFlowClassifiers::DEFAULT_CLASSIFIER); |
| 88 | BaseClassifier::ml_logger->trace ("(Predict)Incoming json: {}", json_params); |
| 89 | int res = string_to_brainflow_model_params (json_params, &key); |
| 90 | if (res != (int)BrainFlowExitCodes::STATUS_OK) |
| 91 | { |
| 92 | return res; |
| 93 | } |
| 94 | auto model = ml_models.find (key); |
| 95 | if (model == ml_models.end ()) |
| 96 | { |
| 97 | BaseClassifier::ml_logger->error ("Must prepare model before using it for prediction."); |
| 98 | return (int)BrainFlowExitCodes::CLASSIFIER_IS_NOT_PREPARED_ERROR; |
| 99 | } |
| 100 | return model->second->predict (data, data_len, output, output_len); |
| 101 | } |
| 102 | |
| 103 | int release (const char *json_params) |
| 104 | { |
no test coverage detected