diff --git a/firmware/lib/cv/cv.cpp b/firmware/lib/cv/cv.cpp index 552b84d..ca4186c 100644 --- a/firmware/lib/cv/cv.cpp +++ b/firmware/lib/cv/cv.cpp @@ -17,6 +17,8 @@ void cv_reset_counts(CVState& state) { struct Point { int x, y; }; +// Note: queue may grow to CV_PIXELS entries (~72KB) on large blobs. +// Requires PSRAM (enabled via -DBOARD_HAS_PSRAM in platformio.ini). // BFS flood fill. Marks visited pixels (sets fg to 0). Returns {-1,-1} if blob < CV_MIN_BLOB_PX. static std::pair extract_blob(uint8_t* fg, int start_x, int start_y) { std::vector queue; @@ -49,7 +51,7 @@ static std::pair extract_blob(uint8_t* fg, int start_x, int start_y static std::vector> find_centroids(const uint8_t* fg) { std::vector> result; - uint8_t fg_copy[CV_PIXELS]; + static uint8_t fg_copy[CV_PIXELS]; // static to avoid 9KB stack allocation memcpy(fg_copy, fg, CV_PIXELS); for (int y = 0; y < CV_H; y++) {