first, what my project is supposed to do. it is supposed to do image tracking on a robot for a competition (the goals will have retro-reflective tape on them, and the camera on the robot has an LED ring around). it will recieve a 60x45 pixel image from the network, but since i dont have the ethernet shield yet, i am using a static test picture, the RGB values of which are stored in the flash space. it first checks if each pixel falls within the given RGB bounds, and stores the results in a 2d array called binaryImage (it used to store true/false values in it, but i later changed it to have numbers. the basic idea is unchanged tho). it then removes any isolated pixels, since those can't possibly be right, by calling removeSmallParticles(). it then calls blobifyBinaryImage2(), which assigns contiguous regions an ID, and stores the id in binaryImage (blobifyBinaryImage() was an earlier attempt, long since abandonned. note that blobifyBinaryImage() is different than blobifyBinaryImage2(). also, the IDs start at 2. an id of 0 means the pixel is off, aka not a viable target. 1 means that the pixel is viable, but is awaiting blobification. thus, blobs start at 2). then, small blobs are eliminated, then the blobs are re-ID'd by changing the pixels back to 1, then blobifyBinaryImage2() again. throught the process, statuses are printed to various leds, a 7 segment display, and even a portable DVD player (using the TVout library) which lets me see what the board sees live.
now, since it will operate VERY differently if i have a camera plugged in vs not, i have a couple of precompiler directives to modify its behavior by simply commenting out a #define line (i also included a few novelty precompiler directives, such as a dummy loading screen, and letting out team mascot, lyle, blink, at the risk of using pointless delay()s). one such constant is DISABLE_CAMERA. when the constant is present, i want it to read my test image from flash memory. if i comment out DISABLE_CAMERA, i want it to declare a 2d array called colorImage to prepare to recieve an RGB image over the network. whether the code looks at testimage or colorImage is also taken care of by these precompiler directives.
So whats the problem? a portion of my code looks like
(i know that is a huge array, and that it only leaves my mega with 92 bytes of ram. thats fine). now as any C/C++ programmer knows, i could easily replace that with
and still get a clean compile, since the compiler skips will skip that portion. now is where things start to get freaky. when i compile, i get errors about how i, in a nutshell, forgot my prototypes. including prototypes does indeed quiet the compiler. according to the troubleshooting guide, there are well known circumstances in which this can occur. none of those apply to me. BUT get this: if i change #ifndef to #ifdef or comment out #define DISABLE_CAMERA or move it to an #else clause under #ifndef, or otherwise use the precompiler directives to tell it to compile, it will compile. it doesnt matter what i declare in that line. int x; has the same effect. if the compiler is clearly instructed to ignore its declaration, it goes haywire and gives me irrelevent errors (colorImage is not used anywhere in the code yet). if i tell it to look at the line, then it will compile (or not, depending on what the line is. i.e. valid syntax, etc). while i know that the compiler has issues generating prototypes under certain circumstances, i believe the problem is in the precompiler, not the actual compiler itself.
NOTES: i have a mega 2560 by OSEPP. since i am very pressed for memory, i use bytes and chars for virtually everything. the image that im processing is 4 basketball goals with retro-reflective tape around them. finally, my code (sorry its so sloppy)