fix: CV find_centroids — static fg_copy to prevent 9KB stack allocation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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<float,float> extract_blob(uint8_t* fg, int start_x, int start_y) {
|
||||
std::vector<Point> queue;
|
||||
@@ -49,7 +51,7 @@ static std::pair<float,float> extract_blob(uint8_t* fg, int start_x, int start_y
|
||||
|
||||
static std::vector<std::pair<float,float>> find_centroids(const uint8_t* fg) {
|
||||
std::vector<std::pair<float,float>> 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++) {
|
||||
|
||||
Reference in New Issue
Block a user