[Solved] How to Modify Example Sketch for Custom Actions [Arduino IDE]

Hey, I’m using EDGE Impulse Object Detection as a part of a model autonomous car for a project. There are 2 objects that are representing a STOP and SLOW sign. I have deployed on the ESP32 CAM using Arduino IDE. Using the example I can see the correct objects being detected. The issue I am facing is that how to extract the label, store them in a variable or directly compare that to a string in some IF-ELSE statement. I tried the following

String myLabel;
myLabel = result.classification[0].label;

But when I print the myLabel on serial monitor nothing shows up. Is there a specific method I need to use to get these values?

For more info on the project heres the link: road_sign_detection_V2 - Dashboard - Edge Impulse

UPDATE
So I managed to resolve my issue which was my fault for not properly going through the code. In case anyone else gets a similar problem I guess you can follow a few of these steps to make get stuff running I suppose.

1- Make sure you are trying to access the labels and values in the correct if-else statement. In the example file it caters for both detection and other problems and it does that using the flag EI_CLASSIFIER_OBJECT_DETECTION. If your problem is of object detection make sure to access labels and values from that if block.

2- You cant directly print on terminal in those if-else blocks. I’m not entirely sure why that is but if you want to use that data you can define a string for labels and a double for values above your void setup(). Then assign the label string and double variable the result.classification[i].label, result.classification[i].value respectively. Then you can use your variables in the void loop() below the free(snapshot_buf) statement.

I hope this helps anyone who might be using this for the first time on arduino IDE with ESP32-CAM.

1 Like

Great!

UPDATE
So I managed to resolve my issue which was my fault for not properly going through the code. In case anyone else gets a similar problem I guess you can follow a few of these steps to make get stuff running I suppose.

1- Make sure you are trying to access the labels and values in the correct if-else statement. In the example file it caters for both detection and other problems and it does that using the flag EI_CLASSIFIER_OBJECT_DETECTION. If your problem is of object detection make sure to access labels and values from that if block.

2- You cant directly print on terminal in those if-else blocks. I’m not entirely sure why that is but if you want to use that data you can define a string for labels and a double for values above your void setup(). Then assign the label string and double variable the result.classification[i].label, result.classification[i].value respectively. Then you can use your variables in the void loop() below the free(snapshot_buf) statement.

I hope this helps anyone who might be using this for the first time on arduino IDE with ESP32-CAM.