Files
rowing_stats/extract_data.ipynb
T
adamfandClaude Opus 5.5 9b1f7e5898 Add single-script OCR prototype
Find the square LCD by contour detection, perspective-warp it, binarise
it and run Tesseract over the result, then pull the stats out of the
text with regular expressions. A scratch notebook plots the stages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 11:46:19 +01:00

162 KiB

In [1]:
import os
import math

import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np


from datetime import datetime
from matplotlib.figure import Figure
In [2]:

def plot_images(imgs: list[np.ndarray]):
    """
    Plot a list of images in a single matplotlib figure.

    Parameters
    ----------
    imgs : list[np.ndarray]
        List of images (H×W or H×W×C arrays).
    """
    if not imgs:
        return

    n = len(imgs)
    cols = math.ceil(math.sqrt(n))
    rows = math.ceil(n / cols)

    fig, axes = plt.subplots(rows, cols, figsize=(cols * 3, rows * 3))
    axes = np.atleast_1d(axes).ravel()

    for ax, img in zip(axes, imgs):
        if img.ndim == 2:
            ax.imshow(img, cmap="gray")
        else:
            ax.imshow(img)
        ax.axis("off")

    # Hide any unused subplots
    for ax in axes[len(imgs):]:
        ax.axis("off")

    plt.tight_layout()
    plt.show()


In [2]:
import extract_data as lib
import matplotlib.pyplot as plt

photos_path = "./photos/"
debug_path = "./debug/"
img_path = "IMG_5431.JPEG"
img = lib.load_pil(photos_path + img_path)
arr = lib.pil_to_cv(img)
fig = lib.cv_to_figure(arr)
plt.show(fig)