SPB Git

Repository Public

door-video.sh 4.2 KB 84 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : Immo-Ka iOS8# File             : Scripts/door-video.sh9# Description      : enregistre le simulateur pendant qu'un test d'interface10#                    ouvre une propriété par la porte de la maison, puis11#                    extrait une planche d'images du mouvement12#                    (build/shots/porte-mouvement.jpg). ffmpeg requis.13#                    L'enregistrement est arrêté par son identifiant de14#                    processus (jamais de pkill).15# Module           : Scripts16# Repository       : https://git.spboucher.ai/immo-ka-ios-v317# Project Website  : https://www.immo-ka.com18# Created          : 2026-11-2519# Last Modified    : 2026-11-2820#21# Author           : Simon-Pierre Boucher22# Position         : Professor of Finance23# Institution      : Université du Québec en Outaouais (UQO)24# Organization     : SP Boucher25# Website          : https://spboucher.ai26# Git              : https://git.spboucher.ai27#28# Preferred Contact: support@spboucher.ai29# Technical Contact: dev@spboucher.ai30# Security/Admin   : admin@spboucher.ai31#32# Copyright (c) 202633# Simon-Pierre Boucher34# All rights reserved where applicable. This file is governed by the35# applicable project license, copyright notices and relevant law.36# Existing third-party rights and notices remain unaffected.37#38# License          : None specified (no license file in this repository)39#40# Do not embed credentials, private keys, access tokens,41# certificates or confidential personal information.42#43# =============================================================================44# END OF SP BOUCHER SOURCE HEADER45# =============================================================================4647set -uo pipefail48cd "$(dirname "$0")/.."49SIM="${IMMOKA_SIM:-ImmoKa-v3}"50U="$(xcrun simctl list devices | grep -F "$SIM (" | head -1 | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/')"51mkdir -p build/video build/shots build/logs; rm -rf build/video/door.mp4 build/video/fr52xcrun simctl boot "$U" 2>/dev/null; xcrun simctl bootstatus "$U" >/dev/null 2>&153xcrun simctl ui "$U" appearance "${MODE:-light}"54xcrun simctl io "$U" recordVideo --codec h264 --force build/video/door.mp4 > build/logs/record.log 2>&1 &55REC=$!56sleep 357LINES_MAX=20 Scripts/build.sh uitest -only-testing:ImmoKaUITests/MainFlowUITests/testDoorOpensListingFromCard 2>&1 | grep -E "passed|failed|error:|\*\* TEST" | sort -u58sleep 1; kill -INT "$REC"; wait "$REC" 2>/dev/null59mkdir -p build/video/fr && ffmpeg -loglevel error -i build/video/door.mp4 -vf "scale=402:-1" -r 60 build/video/fr/f%05d.png60python3 - <<'PY'61import os62import numpy as np63from PIL import Image, ImageDraw64d = "build/video/fr"; fs = sorted(os.listdir(d))65def red(f):66    # le rouge de la porte (#D12C37 et ses nuances éclairées ou assombries)67    a = np.asarray(Image.open(f"{d}/{f}").convert("RGB")).astype(int)68    return int(((a[..., 0] > 120) & (a[..., 0] - a[..., 1] > 85) & (a[..., 0] - a[..., 2] > 70) & (a[..., 1] < 90)).sum())69vals = [red(f) for f in fs]70# la porte : nettement plus de rouge que l'accueil (dont le logo est déjà rouge)71hit = [i for i, v in enumerate(vals) if v > 0.12 * max(vals) and v > 1500]72if not hit: raise SystemExit("aucune image de la porte dans la vidéo")73a, b = hit[0] - 10, hit[-1] + 2274print(f"porte visible pendant {(hit[-1] - hit[0] + 1) * 1000 // 60} ms (images {hit[0]} à {hit[-1]})")75idx = sorted(set(max(0, min(len(fs) - 1, int(round(a + (b - a) * k / 13)))) for k in range(14)))76ims = [Image.open(f"{d}/{fs[i]}").convert("RGB") for i in idx]77w, h = ims[0].size; cols = 7; rows = (len(ims) + cols - 1) // cols78sheet = Image.new("RGB", (cols * (w + 8), rows * (h + 8)), (60, 60, 60))79for k, im in enumerate(ims):80    x, y = (k % cols) * (w + 8), (k // cols) * (h + 8)81    sheet.paste(im, (x, y)); ImageDraw.Draw(sheet).text((x + 6, y + 6), f"{(idx[k] - hit[0]) * 1000 // 60} ms", fill=(0, 90, 255))82sheet.save("build/shots/porte-mouvement.jpg", quality=85); print("build/shots/porte-mouvement.jpg")83PY84
Files main
Menu

Theme