Skip to content

Commit c263d32

Browse files
authored
Merge pull request #15 from Abandon-ht/dev
update YOLO demo.
2 parents bcd2321 + 0c340c1 commit c263d32

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

examples/KWS_ASR/KWS_ASR.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <Arduino.h>
77
#include <M5Unified.h>
88
#include <M5ModuleLLM.h>
9-
#include <ArduinoJson.h>
109

1110
M5ModuleLLM module_llm;
1211

examples/YOLO/YOLO.ino

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@
66
#include <Arduino.h>
77
#include <M5Unified.h>
88
#include <M5ModuleLLM.h>
9-
#include <ArduinoJson.h>
109

1110
M5ModuleLLM module_llm;
1211
String camera_work_id;
1312
String yolo_work_id;
1413

14+
void clearDisplay()
15+
{
16+
M5.Display.fillRect(40, 50, 270, 20, BLACK);
17+
M5.Display.fillRect(150, 80, 60, 20, BLACK);
18+
M5.Display.fillRect(40, 110, 40, 20, BLACK);
19+
M5.Display.fillRect(40, 140, 40, 20, BLACK);
20+
M5.Display.fillRect(40, 170, 40, 20, BLACK);
21+
M5.Display.fillRect(40, 200, 40, 20, BLACK);
22+
}
23+
1524
void setup()
1625
{
1726
M5.begin();
@@ -27,29 +36,38 @@ void setup()
2736
module_llm.begin(&Serial2);
2837

2938
/* Make sure module is connected */
30-
M5.Display.printf(">> Check ModuleLLM connection..\n");
39+
M5.Display.setTextColor(ORANGE, BLACK);
40+
M5.Display.setTextSize(2);
41+
M5.Display.setTextDatum(middle_center);
42+
M5.Display.drawString("Check ModuleLLM connection..", M5.Display.width() / 2, M5.Display.height() / 2);
3143
while (1) {
3244
if (module_llm.checkConnection()) {
3345
break;
3446
}
3547
}
3648

3749
/* Reset ModuleLLM */
38-
M5.Display.printf(">> Reset ModuleLLM..\n");
50+
M5.Display.fillRect(0, (M5.Display.height() / 2) - 10, 320, 25, BLACK);
51+
M5.Display.drawString("Reset ModuleLLM..", M5.Display.width() / 2, M5.Display.height() / 2);
3952
module_llm.sys.reset();
4053

4154
/* Setup Camera module */
42-
M5.Display.printf(">> Setup camera..\n");
55+
M5.Display.fillRect(0, (M5.Display.height() / 2) - 10, 320, 25, BLACK);
56+
M5.Display.drawString("Setup camera..", M5.Display.width() / 2, M5.Display.height() / 2);
4357
camera_work_id = module_llm.camera.setup();
4458

4559
/* Setup YOLO module and save returned work id */
46-
M5.Display.printf(">> Setup yolo..\n");
60+
M5.Display.fillRect(0, (M5.Display.height() / 2) - 10, 320, 25, BLACK);
61+
M5.Display.drawString("Setup yolo..", M5.Display.width() / 2, M5.Display.height() / 2);
4762
m5_module_llm::ApiYoloSetupConfig_t yolo_config;
4863
yolo_config.input = {camera_work_id};
4964
yolo_work_id = module_llm.yolo.setup(yolo_config, "yolo_setup");
50-
// M5.Display.printf(">> Yolo ready\n");
51-
M5.Display.drawString("class", 10, 80);
52-
M5.Display.drawString("confidence", 180, 80);
65+
66+
M5.Display.fillRect(0, (M5.Display.height() / 2) - 10, 320, 25, BLACK);
67+
68+
M5.Display.setTextDatum(top_left);
69+
M5.Display.drawString("class", 10, 20);
70+
M5.Display.drawString("confidence", 10, 80);
5371
M5.Display.drawString("x1", 10, 110);
5472
M5.Display.drawString("y1", 10, 140);
5573
M5.Display.drawString("x2", 10, 170);
@@ -83,20 +101,18 @@ void loop()
83101
int y1 = bboxArray[1].as<int>();
84102
int x2 = bboxArray[2].as<int>();
85103
int y2 = bboxArray[3].as<int>();
86-
M5.Display.drawString(class_name, 80, 80);
87-
M5.Display.drawFloat(confidence, 2, 200, 110);
104+
105+
clearDisplay();
106+
107+
M5.Display.drawString(class_name, 40, 50);
108+
M5.Display.drawFloat(confidence, 2, 150, 80);
88109
M5.Display.drawNumber(x1, 40, 110);
89110
M5.Display.drawNumber(y1, 40, 140);
90111
M5.Display.drawNumber(x2, 40, 170);
91112
M5.Display.drawNumber(y2, 40, 200);
92113
}
93114
} else {
94-
M5.Display.drawString("None", 80, 80);
95-
M5.Display.drawFloat(0, 2, 200, 110);
96-
M5.Display.drawNumber(0, 40, 110);
97-
M5.Display.drawNumber(0, 40, 140);
98-
M5.Display.drawNumber(0, 40, 170);
99-
M5.Display.drawNumber(0, 40, 200);
115+
clearDisplay();
100116
}
101117
}
102118
}

src/api/api_yolo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace m5_module_llm {
1111
struct ApiYoloSetupConfig_t {
1212
String model = "yolo11n";
13-
String response_format = "yolo.yolobox.stream";
13+
String response_format = "yolo.box.stream";
1414
std::vector<String> input = {"yolo.jpeg.base64"};
1515
bool enoutput = true;
1616
};

0 commit comments

Comments
 (0)