"""Build a client-shareable report from saved benchmark measurements and images. Optional report dependency: pip install reportlab Run from any directory: python scripts/create_benchmark_pdf.py """ import json from pathlib import Path from reportlab.pdfgen import canvas from reportlab.lib import colors from reportlab.lib.utils import ImageReader from reportlab.platypus import Paragraph, Table, TableStyle from reportlab.lib.styles import ParagraphStyle ROOT = Path(__file__).resolve().parents[1] REPORTS = ROOT / 'reports' OUTPUT = REPORTS / 'Iris_Registration_Benchmark.pdf' ROWS = json.loads((REPORTS / 'metrics.json').read_text()) BY_NAME = {row['case']: row for row in ROWS} W, H = 595.28, 841.89 M = 43 INK = colors.HexColor('#172D37') MUTED = colors.HexColor('#536873') TEAL = colors.HexColor('#087E80') PALE = colors.HexColor('#EAF5F3') LINE = colors.HexColor('#D8E4E8') c = canvas.Canvas(str(OUTPUT), pagesize=(W,H), pageCompression=1) c.setTitle('Iris Registration | Synthetic Benchmark') c.setAuthor('Iris Registration POC') c.setSubject('Controlled synthetic evaluation; real-client validation pending') style = ParagraphStyle('body', fontName='Helvetica', fontSize=10, leading=15, textColor=MUTED) def para(text,x,y,width=W-2*M,size=10,color=MUTED): st = ParagraphStyle('custom', parent=style, fontSize=size, leading=size*1.45,textColor=color) p = Paragraph(text, st) _, height = p.wrap(width,H) p.drawOn(c,x,y-height) return y-height def label(text,x,y,size=10,color=INK,bold=False): c.setFillColor(color) c.setFont('Helvetica-Bold' if bold else 'Helvetica',size) c.drawString(x,y,text) def page(title,sub,page_no): c.setFillColor(TEAL);c.rect(0,H-8,W,8,fill=1,stroke=0) label('IRIS REGISTRATION / PROOF OF CONCEPT',M,H-43,9,TEAL,True) label('22 SEPTEMBER 2026',W-155,H-43,8,MUTED) label(title,M,H-87,25,INK,True) para(sub,M,H-105,size=10) c.setStrokeColor(LINE);c.line(M,47,W-M,47) label('SYNTHETIC BENCHMARK - REAL-PHOTO VALIDATION PENDING',M,31,7,MUTED) label(f'{page_no} / 3',W-M-22,31,8,MUTED) def picture(path,x,top,size,caption): c.drawImage(ImageReader(str(REPORTS/path)),x,top-size,width=size,height=size,mask='auto') para(caption,x,top-size-9,width=size,size=9) page('Registration benchmark','Alignment results and visual comparisons from controlled synthetic tests.',1) y=H-157 c.setFillColor(PALE);c.roundRect(M,y-81,W-2*M,81,8,fill=1,stroke=0) label('7 / 7 synthetic cases passed',M+16,y-27,19,TEAL,True) para('Every case achieved a 95th-percentile correspondence error below 1 pixel at 1000 x 1000 resolution.',M+16,y-41,W-2*M-32,10,INK) y-=106 names={'identity':'Identity / JPEG roundtrip','rotation_scale':'Rotation + scale','perspective_dark':'Perspective + darker exposure','reflection':'Rotation + scale + reflection','local_warp':'Local distortion','local_dark':'Local distortion + darker exposure','local_perspective':'Local distortion + perspective + darker exposure'} head=['Test case','Median (px)','95th pct. (px)','Result'] data=[head] for row in ROWS: data.append([Paragraph(names[row['case']],ParagraphStyle('cell',parent=style,fontSize=9,leading=12,textColor=INK)),f"{row['median_error_px']:.3f}",f"{row['p95_error_px']:.3f}",row['status']]) t=Table(data,colWidths=[266,79,88,76],rowHeights=[29]+[37]*7) t.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),INK),('TEXTCOLOR',(0,0),(-1,0),colors.white),('FONTNAME',(0,0),(-1,0),'Helvetica-Bold'),('FONTNAME',(0,1),(-1,-1),'Helvetica'),('FONTSIZE',(0,0),(-1,-1),9),('VALIGN',(0,0),(-1,-1),'MIDDLE'),('LEFTPADDING',(0,0),(-1,-1),9),('ROWBACKGROUNDS',(0,1),(-1,-1),[colors.white,colors.HexColor('#F3F7F8')]),('TEXTCOLOR',(1,1),(-1,-1),INK),('TEXTCOLOR',(-1,1),(-1,-1),TEAL),('LINEBELOW',(0,-1),(-1,-1),.5,LINE)])) _,th=t.wrap(W-2*M,H);t.drawOn(c,M,y-th);y-=th+24 label('What this demonstrates',M,y,12,INK,True) y=para('The prototype achieved subpixel alignment across all seven controlled test cases. The 95th-percentile error means that 95% of evaluated points had an error at or below the reported value. Lower values indicate closer alignment; this is not a percentage-accuracy score.',M,y-12) y-=21 label('What is still unverified',M,y,12,INK,True) para('These seven cases are variations of one synthetic iris, not seven real eyes. They do not establish accuracy on customer photographs, anatomical fidelity, or a production success rate. The next milestone is review of 3-5 real image pairs at native resolution.',M,y-12) c.showPage() def case_page(name,title,sub,num): row=BY_NAME[name] page(title,sub,num) y=H-159 label(f"Median {row['median_error_px']:.3f} px | 95th percentile {row['p95_error_px']:.3f} px | PASS",M,y,11,TEAL,True) size=235;gap=39;top=y-22 picture('reference.png',M,top,size,'01 / Reference - synthetic test fixture') picture(f'{name}-moving.jpg',M+size+gap,top,size,'02 / Input with known simulated changes') top-=size+58 picture(f'{name}-overlay.png',M,top,size,'03 / Alignment overlay') picture(f'{name}-composite.png',M+size+gap,top,size,'04 / Processed output using source-image detail') bottom=top-size-45 para("The processed output uses information from the supplied test images; no new iris texture is generated during processing. Differences at the overlay borders include areas outside the shared image coverage.",M,bottom,size=9) c.showPage() case_page('local_warp','Local distortion recovered','Alignment results for an input with simulated local geometric differences.',2) case_page('local_perspective','Combined changes recovered','Local distortion, rotation, scale, perspective and reduced exposure in one test.',3) c.save() print(OUTPUT)