Hi Dylan,
Yes, this is certainly related to memory; it is the linker saying "I haven't got any room left in RAM to put your data structures". The main culprits are:
// Image Arrays
char imageArray1[62][64]; // [resizedHeight][resizedWidth];
char imageArray2[62][64]; // [resizedHeight][resizedWidth];
char blobArray1a[62][64];
char blobArray1b[62][64];
char blobArray1c[62][64];
char blobArray1d[62][64];
char blobArray1e[62][64];
char blobArray1f[62][64];
char blobArray2a[62][64];
char blobArray2b[62][64];
char blobArray2c[62][64];
char blobArray2d[62][64];
char blobArray2e[62][64];
char blobArray2f[62][64];
In total, this is 62*64*14 = ~56k. On the LPC1768 the main RAM section is 32k; this is where the R/W data, Stack and Heap live. So that doesn't go. There are 2 additional 16k blocks for the USB and Ethernet which should also be usable. If you look at our
scatter file, you can see we've given these sections a name, so you can tell the linker where to try and allocate these blocks using the section attribute. In this case, i'll allocate 4 of your arrays to each of the sections:
// Image Arrays
char imageArray1[62][64]; // [resizedHeight][resizedWidth];
char imageArray2[62][64]; // [resizedHeight][resizedWidth];
char blobArray1a[62][64];
char blobArray1b[62][64];
char blobArray1c[62][64];
char blobArray1d[62][64];
char blobArray1e[62][64] __attribute__((section("AHBSRAM1")));
char blobArray1f[62][64] __attribute__((section("AHBSRAM1")));
char blobArray2a[62][64] __attribute__((section("AHBSRAM1")));
char blobArray2b[62][64] __attribute__((section("AHBSRAM1")));
char blobArray2c[62][64] __attribute__((section("AHBSRAM0")));
char blobArray2d[62][64] __attribute__((section("AHBSRAM0")));
char blobArray2e[62][64] __attribute__((section("AHBSRAM0")));
char blobArray2f[62][64] __attribute__((section("AHBSRAM0")));
This obviously is specific to the LPC1768 so is not ideal. It may be you can optimise your algorithm to use less RAM (perhaps by reusing buffers, or tiling somehow).
btw. you can also avoid the use-before-initialisation warning by initialising your struct as you define it, so:
point startPosition;
startPosition.x = NULL;
startPosition.y = NULL;
becomes:
point startPosition = {NULL, NULL};
With these changes, your program compiles without error (that is not to say it will work! but hopefully a step closer)
Simon
For my Science Fair, I'm using the mbed NXP LPC1768 to receive images from two cameras (the Nintendo Game Boy Cameras from the 90s; the Mitsubishi M64282FP Artificial Retina) to determine the blobs in both images using the MSER Algorithm (Maximally Stable Extremal Regions). The program can be found here. So far, I've been able to receive images at ~7fps and determine pixel brightness using a dynamic threshold. The only problem now, is getting the MSER Algorithm working. Even though I've developed it seemingly good enough, I'm having trouble compiling. The bugs I'm getting are as follows:
Of course, I not quite worried about the first one and the last, but the "No space..." and "Sections of aggregate size..." is kind of worrying me. At first, I assumed it was the part of my code meant for dynamic RAM allocation that included "realloc()", but just taking that part out didn't satisfy this bug's thirst. Only after taking out practically all of my latest work did I finally make the problem go away. Even Google didn't come up with much that helped (mostly KeilVision stuff). Though this might help, I really don't want to go back to the less memory and processing consuming Edge Tracing Algorithm.
Sincerely,
Dylan Dalrymple
2010 Intel ISEF Entrant