!7 cmodule2 FindLineInCenter > DynWebCamAnalyzer { transient BWIntegralImage ii; transient OCRCompass c; switchable bool lineIsBright = true; switchable int angles = 6; switchable int radius = 50; afterVisualize { containerAddFirst(buttons, dm_checkBox lineIsBright(), dm_spinnerWithLabel angles(2, 24), dm_spinnerWithLabel radius(1, 80)); } void analyzeImage() { ii = new BWIntegralImage(inputImage); c = new OCRCompass; c.steps = angles*2; c.brightForeground = lineIsBright; c.image = ii; c.center = pt(w/2, h/2); c.radius = min(w, h)/2.0*radius/100; //c.sensorFootprint = iceil(c.radius); //printStruct("values", c.values); //print("angle", angle); } void drawOverlays(BufferedImage img) { double angle = c.mostLikelyAngle(); renderRenderables(img, zipAndMap(c.sensors(), repeatList(2, asList(c.values)), (r, value) -> BoxWithColor(r, 0, 0, iround(value)))); double radius2 = c.radius*0.75; drawRoundEdgeLine(img, pointOnCircle(c.center, radius2, angle), pointOnCircle(c.center, radius2, angle+pi()), Color.green, c.radius/3f); } }