Created
December 22, 2019 08:06
-
-
Save boochow/39cde52de7f5af0fdfbb058755949e20 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop() { | |
// Attempt to read new data from the accelerometer | |
bool got_data = ReadAccelerometer(error_reporter, model_input->data.f, | |
input_length, should_clear_buffer); | |
// Don't try to clear the buffer again | |
should_clear_buffer = false; | |
// If there was no new data, wait until next time | |
if (!got_data) return; | |
// Run inference, and report any error | |
TfLiteStatus invoke_status = interpreter->Invoke(); | |
if (invoke_status != kTfLiteOk) { | |
error_reporter->Report("Invoke failed on index: %d\n", begin_index); | |
return; | |
} | |
char s[64]; | |
float *f = model_input->data.f; | |
float *p = interpreter->output(0)->data.f; | |
sprintf(s, "%+6.0f : %+6.0f : %+6.0f || W %3.2f : R %3.2f : S %3.2f", \ | |
f[381], f[382], f[383], p[0], p[1], p[2]); | |
error_reporter->Report(s); | |
// Analyze the results to obtain a prediction | |
int gesture_index = PredictGesture(interpreter->output(0)->data.f); | |
// Clear the buffer next time we read data | |
should_clear_buffer = gesture_index < 3; | |
// Produce an output | |
HandleOutput(error_reporter, gesture_index); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment