sclass OCRCompass { IBWIntegralImage image; int px, py; // point we're looking at double radius = 16; // radius of circle int sensorFootprint = 4; // size of each "pixel" (rectangle) to grab int steps = 12; // how many segments of circle (=steps/2 line orientations). should be even int blur; // blur width double[] values; // brightnesses at each point (low=foreground) void compute { values = new double[steps/2]; squaresAroundCircle(); } void ensureComputed { if (values == null) compute(); } double mostLikelyAngle() { ensureComputed(); indexOfMaxEntryInDoubleArray(values); ret twoPi()/steps; } }