Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Test calibration of LED positions by overlaying the detected coordinates onto an image
<html>
<head>
<meta charset="UTF-8">
<script>
// Paste in the non-normalised values returned by calib.py here
data = [[201.1764705882353, 796.08823529411768], [154.34146341463415, 838.92682926829264], [195.52338129496403, 803.62050359712225], [162.18309859154928, 885.72769953051647], [249.05550883095037, 908.5063078216989], [259.26624068157616, 903.87539936102235], [270.16627634660421, 898.05386416861825], [357.83127317676144, 854.56736711990106], [366.65263157894736, 835.80902255639103], [360.58999999999997, 878.75], [417.25539257981018, 896.20793787748062], [430.98823529411766, 849.07486631016047], [456.93965517241378, 859.64224137931035], [497.92769230769233, 833.42769230769227], [553.3029576338929, 797.28137490007998], [628.92672919109032, 826.33645955451345], [519.38479809976252, 753.271971496437], [469.18218623481783, 744.14574898785429], [476.93782929399367, 743.97365648050584], [468.42764227642277, 737.34905149051485], [396.6270783847981, 786.3990498812351], [388.17771084337352, 803.02108433734941], [362.79513888888891, 780.48784722222217], [331.28925619834712, 747.82314049586773], [300.08530805687207, 762.19905213270147], [257.89099526066349, 754.33175355450237], [231.93469387755101, 724.57959183673472], [169.90720221606648, 717.09279778393352], [143.1840490797546, 706.16564417177915], [208.1884236453202, 667.12192118226596], [228.375, 674.52499999999998], [222.09999999999999, 648.20000000000005], [251.27648796960742, 627.40692275221613], [285.0051724137931, 644.42758620689654], [331.12048192771084, 643.61445783132535], [381.00162866449512, 631.15309446254071], [353.71179039301308, 691.60698689956337], [382.90925589836661, 704.39927404718696], [413.96794871794873, 682.32051282051282], [465.96662830840046, 690.06098964326816], [446.4689265536723, 677.18644067796606], [506.34301270417421, 665.31941923774957], [479.10110584518168, 634.58767772511851], [492.9929328621908, 602.98233215547702], [475.94999999999999, 589.95833333333337], [468.58328530259365, 549.40749279538909], [455.84504657070278, 589.45554614733283], [398.04216867469881, 582.5], [414.35708435708437, 592.37346437346434], [406.27325890483786, 553.8048910154173], [319.59499609069587, 559.9378420641126], [267.93633540372673, 590.72826086956525], [238.74246987951807, 564.61219879518069], [200.04404332129963, 523.60577617328522], [203.6425120772947, 568.02898550724638], [198.58799999999999, 560.13999999999999], [239.98080279232113, 512.80453752181506], [195.3221476510067, 486.94630872483219], [227.96153846153845, 484.69526627218937], [271.89724497393894, 453.9583023082651], [303.36907020872866, 502.00379506641366], [314.96477392218719, 508.0488958990536], [317.58105263157893, 513.3621052631579], [385.68421052631578, 482.98245614035091], [396.86607142857144, 512.55357142857144], [423.06451612903226, 474.83870967741933], [454.76488095238096, 490.92261904761904], [419.05381165919283, 478.34529147982062], [424.46153846153845, 452.15384615384613], [498.22727272727275, 410.04545454545456], [460.47169811320754, 405.8679245283019], [439.48354935194419, 387.17347956131607], [398.27620967741933, 419.86290322580646], [370.13457943925232, 438.27601246105917], [335.8150684931507, 467.55479452054794], [349.67459932005829, 409.13016027197671], [335.61310782241014, 414.58350951374206], [292.14269788182833, 372.63433667781493], [245.25, 459.0], [225.80963572267919, 390.73913043478262], [289.0, 372.0], [293.74244604316544, 373.46474820143885], [247.86636971046769, 335.728285077951], [298.99328859060404, 319.34395973154363], [304.82024597918638, 321.92809839167455], [328.88235294117646, 327.86241276171484], [396.95145631067959, 311.95873786407765], [417.50176678445229, 312.37809187279152], [419.25222551928783, 260.78041543026706], [356.87364130434781, 228.19293478260869], [354.22460658082974, 258.52265140677156], [301.42054380664655, 224.91903323262841], [281.95833333333331, 236.52604166666666], [336.50280898876406, 177.02106741573033], [324.95201238390092, 172.02321981424149], [335.97687326549493, 134.82516188714155], [348.72625698324021, 125.6685288640596], [399.08039906103284, 139.38732394366198], [397.4858695652174, 86.134782608695659], [345.28426395939084, 102.04568527918782]];
var svgNS = "http://www.w3.org/2000/svg";
function go() {
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var img = document.getElementById("tree");
ctx.drawImage(img, 0, 0);
ctx.strokeStyle = "#FF0000";
for (i=0; i < data.length; i++) {
if (i > 0) {
ctx.moveTo(data[i-1][0],data[i-1][1]);
ctx.lineTo(data[i][0],data[i][1]);
ctx.stroke();
}
}
ctx.strokeStyle = "#0000FF";
ctx.fillStyle = "#0000FF";
for (i=0; i < data.length; i++) {
if (i > 0) {
ctx.beginPath();
ctx.moveTo(data[i][0],data[i][1]);
ctx.arc(data[i][0],data[i][1],5,0,2*Math.PI);
ctx.fill();
}
}
}
</script>
</head>
<body bgcolor="black" onload="go()">
<canvas id="myCanvas" width="720" height="960">
Your browser does not support the HTML5 canvas tag.
</canvas>
<!-- Take a static picture of the tree with all LEDs on -->
<img id="tree" src="tree.jpg">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment