Skip to content

Commit

Permalink
feat: runing cool
Browse files Browse the repository at this point in the history
  • Loading branch information
Love4yzp committed Feb 21, 2024
1 parent 293588a commit 8880687
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 2 deletions.
113 changes: 113 additions & 0 deletions examples/vision_v2_display/XIAO_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#include <Seeed_Arduino_SSCMA.h>
#include <ArduinoJson.h>
#ifdef ESP32
#include <HardwareSerial.h>

// Define two Serial devices mapped to the two internal UARTs
HardwareSerial atSerial(0);

#else
#define atSerial Serial1
#endif

SSCMA AI;
void setup()
{
Serial.begin(9600);
AI.begin(&atSerial);
// Serial.println("Start!");
}

void loop() {
JsonDocument doc; // Adjust size as needed
if (!AI.invoke(1,false,true)) {
// Performance metrics
// doc["preprocess"] = AI.perf().prepocess;
// doc["inference"]= AI.perf().inference;
// doc["postprocess"]= AI.perf().postprocess;

// // Boxes
// JsonArray boxes = doc.createNestedArray("boxes");
for (int i = 0; i < AI.boxes().size(); i++) {
// JsonObject box = boxes.createNestedObject();
doc["boxes"]["target"] = AI.boxes()[i].target;
// box["score"] =
doc["boxes"]["score"] = AI.boxes()[i].score;
// box["x"] =
doc["boxes"]["x"] = AI.boxes()[i].x;
// box["y"] =
doc["boxes"]["y"] = AI.boxes()[i].y;
// box["w"] =
doc["boxes"]["w"] = AI.boxes()[i].w;
// box["h"] =
doc["boxes"]["h"] = AI.boxes()[i].h;
}

// // Classes
// JsonArray classes = doc.createNestedArray("classes");
// for (int i = 0; i < AI.classes().size(); i++) {
// classObj["target"] = AI.classes()[i].target;
// classObj["score"] = AI.classes()[i].score;
// }

// Points
// JsonArray points = doc.createNestedArray("points");
// for (int i = 0; i < AI.points().size(); i++) {
// point["target"] = AI.points()[i].target;
// point["score"] = AI.points()[i].score;
// point["x"] = AI.points()[i].x;
// point["y"] = AI.points()[i].y;
// }

// // Keypoints
// JsonArray keypoints = doc.createNestedArray("keypoints");
// for (int i = 0; i < AI.keypoints().size(); i++) {
// JsonObject keypoint = keypoints.createNestedObject();
// keypoint["target"] = AI.keypoints()[i].box.target;
// keypoint["score"] = AI.keypoints()[i].box.score;
// JsonObject box = keypoint.createNestedObject("box");
// box["x"] = AI.keypoints()[i].box.x;
// box["y"] = AI.keypoints()[i].box.y;
// box["w"] = AI.keypoints()[i].box.w;
// box["h"] = AI.keypoints()[i].box.h;
// JsonArray pointsArray = keypoint.createNestedArray("points");
// for (int j = 0; j < AI.keypoints()[i].points.size(); j++) {
// pointsArray.add(AI.keypoints()[i].points[j].x);
// pointsArray.add(AI.keypoints()[i].points[j].y);
// }

// Serial.print("keypoint[");
// Serial.print(i);
// Serial.print("] target=");
// Serial.print(AI.keypoints()[i].box.target);
// Serial.print(", score=");
// Serial.print(AI.keypoints()[i].box.score);
// Serial.print(", box:[x=");
// Serial.print(AI.keypoints()[i].box.x);
// Serial.print(", y=");
// Serial.print(AI.keypoints()[i].box.y);
// Serial.print(", w=");
// Serial.print(AI.keypoints()[i].box.w);
// Serial.print(", h=");
// Serial.print(AI.keypoints()[i].box.h);
// Serial.print("], points:[");
// for (int j = 0; j < AI.keypoints()[i].points.size(); j++) {
// Serial.print("[");
// Serial.print(AI.keypoints()[i].points[j].x);
// Serial.print(",");
// Serial.print(AI.keypoints()[i].points[j].y);
// Serial.print("],");
// }
// Serial.println("]");
// }

// Last image
if (!AI.last_image().isEmpty()) {
doc["img"] = AI.last_image().c_str();
}

serializeJsonPretty(doc, Serial); // Serialize and print the JSON document
Serial.println(); // Ensure there's a newline at the end
}
delay(1000);
}
3 changes: 1 addition & 2 deletions examples/vision_v2_display/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static void __indicator_image_task(void *p_arg)
unsigned char *decoded_str =NULL;



// 计算解码后的长度
int ret = mbedtls_base64_decode(NULL, 0, &output_len, (const unsigned char *)base64_jpeg, str_len);
if (1)
Expand Down Expand Up @@ -132,7 +131,7 @@ void app_main(void)

ESP_LOGI(TAG, "Out of ui_init()");

xTaskCreate(&__indicator_image_task, "__indicator_image_task", 1024 * 10, NULL, 50, NULL);
// xTaskCreate(&__indicator_image_task, "__indicator_image_task", 1024 * 10, NULL, 50, NULL);

while (1)
{
Expand Down

0 comments on commit 8880687

Please sign in to comment.