sidrefresh's picture
Add files using upload-large-folder tool
92f480e verified
Raw History Blame Contribute Delete
3.65 kB
<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Shot tracer verifier</title>
<style>body{background:#111827;color:#eef2ff;font:15px system-ui;margin:24px}main{display:flex;gap:28px;flex-wrap:wrap}.stage{position:relative;width:min(43vh,440px);aspect-ratio:9/16;background:#000}video,svg{position:absolute;width:100%;height:100%;inset:0}svg{pointer-events:none}section{max-width:650px}button,input{margin:8px 4px 8px 0}button,a{color:inherit}button{background:#334155;border:1px solid #64748b;padding:9px;border-radius:6px}input[type=range]{width:95%}pre{white-space:pre-wrap;background:#1e293b;padding:16px;border-radius:8px}a{display:inline-block;margin:8px}</style>
<h1 id="title"></h1><main><div class="stage"><video id="v" playsinline preload="auto" src="source.mp4"></video><svg viewBox="0 0 720 1280"><path id="p" fill="none" stroke="#ff0000" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" vector-effect="non-scaling-stroke"/></svg></div><section>
<button id="play">Play / pause</button><button id="prev">Previous frame</button><button id="next">Next frame</button><label><input id="overlay" type="checkbox" checked>Tracer</label><br><label>Speed <select id="speed"><option value="0.25">0.25×</option><option value="0.5">0.5×</option><option value="1" selected>1×</option></select></label><input id="seek" type="range" min="0" value="0" step="1"><pre id="info"></pre>
<p>Frame numbers are zero based. The trace grows with saved ball-position estimates, then holds at the last retained point. Estimated points are not verified ground truth.</p>
<a href="reference.mp4">Rendered reference</a><a href="tracer_animated.svg">Animated SVG</a><a href="trajectory.json">JSON</a><a href="frames.csv">CSV</a><a href="README.md">Details</a></section></main><script src="data.js"></script><script>
const D=window.TRACER, F=D.frames,v=document.querySelector('#v'),p=document.querySelector('#p'),seek=document.querySelector('#seek');let idx=0;
document.querySelector('#title').textContent=D.clip;seek.max=F.length-1;p.setAttribute('d',D.path.d);p.setAttribute('stroke-dasharray',D.path.length_px+' '+D.path.length_px);
// Scale native 6px width with the video while counteracting camera scale.
function draw(i){idx=Math.max(0,Math.min(F.length-1,i));let f=F[idx];seek.value=idx;p.setAttribute('transform',f.svg_matrix);p.setAttribute('stroke-dashoffset',f.dashoffset_px);p.setAttribute('vector-effect','none');p.setAttribute('stroke-width',6/f.camera_scale);p.style.opacity=f.visible&&document.querySelector('#overlay').checked?1:0;document.querySelector('#info').textContent=JSON.stringify({frame:idx,time_seconds:f.time_seconds,phase:f.phase,trim_percent:f.trim_percent,tip_xy:f.tip_xy,confidence:f.confidence},null,2)}
function at(t){let lo=0,hi=F.length-1;while(lo<hi){let m=Math.ceil((lo+hi)/2);if(F[m].time_seconds<=t+1e-6)lo=m;else hi=m-1}return lo}
function jump(i){v.pause();draw(i);v.currentTime=F[idx].time_seconds+Math.min(F[idx].duration_seconds/4,0.002)}
document.querySelector('#play').onclick=()=>v.paused?v.play():v.pause();document.querySelector('#prev').onclick=()=>jump(idx-1);document.querySelector('#next').onclick=()=>jump(idx+1);seek.oninput=()=>jump(+seek.value);document.querySelector('#overlay').onchange=()=>draw(idx);document.querySelector('#speed').onchange=e=>v.playbackRate=+e.target.value;
v.addEventListener('seeked',()=>draw(at(v.currentTime)));if(v.requestVideoFrameCallback){function tick(now,m){draw(at(m.mediaTime));v.requestVideoFrameCallback(tick)}v.requestVideoFrameCallback(tick)}else{v.ontimeupdate=()=>draw(at(v.currentTime))}draw(0);
</script>