Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : Lou-Ka iOS8# File : Scripts/door-video.sh9# Description : enregistre le simulateur pendant qu'un test d'interface10# ouvre un logement par la porte, puis extrait une planche11# d'images du mouvement (build/shots/porte-mouvement.jpg).12# ffmpeg requis.13# Module : Scripts14# Repository : https://git.spboucher.ai/lou-ka-ios-v315# Project Website : https://www.lou-ka.com16# Created : 2026-11-2517# Last Modified : 2026-11-2818#19# Author : Simon-Pierre Boucher20# Position : Professor of Finance21# Institution : Université du Québec en Outaouais (UQO)22# Organization : SP Boucher23# Website : https://spboucher.ai24# Git : https://git.spboucher.ai25#26# Preferred Contact: support@spboucher.ai27# Technical Contact: dev@spboucher.ai28# Security/Admin : admin@spboucher.ai29#30# Copyright (c) 202631# Simon-Pierre Boucher32# All rights reserved where applicable. This file is governed by the33# applicable project license, copyright notices and relevant law.34# Existing third-party rights and notices remain unaffected.35#36# License : None specified (no license file in this repository)37#38# Do not embed credentials, private keys, access tokens,39# certificates or confidential personal information.40#41# =============================================================================42# END OF SP BOUCHER SOURCE HEADER43# =============================================================================4445set -uo pipefail46cd "$(dirname "$0")/.."47SIM="${LOUKA_SIM:-LouKa v2 iPhone}"48U="$(xcrun simctl list devices | grep -F "$SIM (" | head -1 | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/')"49mkdir -p build/video build/shots; rm -rf build/video/door.mp4 build/video/fr50xcrun simctl boot "$U" 2>/dev/null; xcrun simctl bootstatus "$U" >/dev/null 2>&151(xcrun simctl io "$U" recordVideo --codec h264 --force build/video/door.mp4 > build/logs/record.log 2>&1 &)52sleep 353LINES_MAX=20 Scripts/build.sh uitest -only-testing:LouKaUITests/MainFlowUITests/testDoorOpensListingFromCard 2>&1 | grep -E "passed|failed|error:|\*\* TEST" | sort -u54sleep 1; pkill -INT -f "simctl io $U recordVideo"; sleep 355mkdir -p build/video/fr && ffmpeg -loglevel error -i build/video/door.mp4 -vf "scale=402:-1" -r 60 build/video/fr/f%05d.png56python3 - <<'PY'57import os58import numpy as np59from PIL import Image, ImageDraw60d = "build/video/fr"; fs = sorted(os.listdir(d))61def orange(f):62 a = np.asarray(Image.open(f"{d}/{f}").convert("RGB")).astype(int)63 return int(((abs(a[..., 0] - 233) < 28) & (abs(a[..., 1] - 107) < 30) & (abs(a[..., 2] - 50) < 35)).sum())64vals = [orange(f) for f in fs]65# la porte : nettement plus d'orange que l'accueil (dont le bouton et le logo sont déjà orange)66hit = [i for i, v in enumerate(vals) if v > 0.2 * max(vals) and v > 2000]67if not hit: raise SystemExit("aucune image de la porte dans la vidéo")68a, b = hit[0] - 14, hit[-1] + 1669print(f"porte visible pendant {(hit[-1] - hit[0] + 1) * 1000 // 60} ms (images {hit[0]} à {hit[-1]})")70idx = sorted(set(int(round(a + (b - a) * k / 11)) for k in range(12)))71ims = [Image.open(f"{d}/{fs[i]}").convert("RGB") for i in idx]72w, h = ims[0].size; cols = 6; rows = (len(ims) + cols - 1) // cols73sheet = Image.new("RGB", (cols * (w + 8), rows * (h + 8)), (60, 60, 60))74for k, im in enumerate(ims):75 x, y = (k % cols) * (w + 8), (k // cols) * (h + 8)76 sheet.paste(im, (x, y)); ImageDraw.Draw(sheet).text((x + 6, y + 6), f"{(idx[k] - hit[0]) * 1000 // 60} ms", fill=(255, 0, 0))77sheet.save("build/shots/porte-mouvement.jpg", quality=85); print("build/shots/porte-mouvement.jpg")78PY79