We copy from Edge Impulse and paste raw image data into our Arduino programs to test if the static_buffer is working, The raw data is in the form RGB888 which is in 3 byte (float) format.
Example image raw data from Edge Impulse:
0xddddd1, 0xddded1, 0xdbdcce, 0xdbdcce, 0xd8d8cc, 0xdcdcd0, 0xddddd1, 0xdbdbcf, ...
but to serial print that same data on the Arduino for debugging purposes seems a bit confusing. I know that I could eventually write the code using some clunky convert to byte,print “0x” then 3 bytes in HEX format, correcting for non-printing zeros etc, but does anyone have a function or example of how to do it efficiently?
In the static_buffer the features array is already defined, so printing it once data has been copied to it would be a good starting point:
static const float features[] = {
// copy raw features here (for example from the 'Live classification' page)
// see https://docs.edgeimpulse.com/docs/running-your-impulse-arduino
};
@Rocksetta just pass in true
as the last argument to run_classifier
. It will print the features for you.
1 Like
Thanks @janjongboom but that has 2 problems:
-
I want to test that my sensor data is correct before connecting an Impulse library.
-
The output is similar to what I am getting showing floating point numbers and not 3 byte HEX format shown on EdgeImpulse…
Here is my printout using a Nano33BLESense
Edge Impulse standalone inferencing (Arduino)
Features (4 ms.): 0.866667 0.866667 0.819608 0.866667 0.870588 ........(lots more).....
Predictions (time: 714 ms.):
is-microcontroller: 0.964844
unknown: 0.035156
run_classifier returned: 0
Predictions (DSP: 4 ms., Classification: 714 ms., Anomaly: 0 ms.):
[0.96484, 0.03516]
is-microcontroller: 0.96484
unknown: 0.03516
@Rocksetta try this:
for (size_t ix = 0; ix < signal.total_length; ix++) {
float value[1];
signal.get_data(ix, 1, value);
ei_printf("0x%06x", (int)value[0]);
if (ix != signal.total_length - 1) {
ei_printf(", ");
}
}
1 Like