diff --git a/scripts/thumbnails.py b/scripts/thumbnails.py index 81ec135..c9bcece 100644 --- a/scripts/thumbnails.py +++ b/scripts/thumbnails.py @@ -15,7 +15,8 @@ The frame centre (px) is written under each thumbnail: when the x, y of the expo by as much. --fixed keeps, on each row, the frame centred on the position at the first requested time, and marks the x, y of the export at each time with a red cross: a spot that enters or leaves the frame is not confused with a spot that appears. A frame cut by the edge of the image is flagged (image size): on some -exports, x, y are not pixels (values close to 0), and the frame falls in the corner of the image. +exports, x, y are not pixels (values close to 0), and the frame falls in the corner of the image. A sensor without +any x, y in the export is left out, and said so. --zone X,Y,W,H: the same zone of the image (pixels of the original image: top left corner, width, height, as gif.py) at each time, side by side (up to 4 per row, fewer when the zone is wide), same stretch with --contrast; --sensors becomes optional: those given are marked with a red cross and their name at their x, y at each time. For the scene around @@ -61,7 +62,12 @@ def main(): if not names and not zone: sys.exit("Give --sensors, or --zone X,Y,W,H.") check("sensors", names, by) - known = sorted(h for h in images if h) + if without := [s for s in names if not any(m["x"] is not None and m["y"] is not None for m in by[s])]: + print(f"No x, y for {', '.join(without)} in the export: not placed (--zone X,Y,W,H looks at the scene around them).") + names = [s for s in names if s not in without] + if not names and not zone: + sys.exit("No sensor left to centre a thumbnail on.") + known =sorted(h for h in images if h) if not known: sys.exit(f"No image in {o.folder}.") nearest = {h: min(known, key=lambda i: abs(i - h)) for h in times} # image at the requested time, otherwise the nearest @@ -74,7 +80,7 @@ def main(): return grey * 255 if grey.max() <= 1 and c.dtype.kind == "f" else grey def measurement(s, t): - return min((m for m in by[s] if m["x"] is not None), key=lambda m: abs(m["t"] - t)) + return min((m for m in by[s] if m["x"] is not None and m["y"] is not None), key=lambda m: abs(m["t"] - t)) r = o.radius crops, centres, crosses = {}, {}, {}