evoneural/evoneuralIn3D-app
0
1"""2Seamless check for 2:1 equirectangular skybox: compare left vs right edge.3Returns MSE and a simple pass/fail (low MSE = more seamless).4"""5 6from pathlib import Path7 8import numpy as np9from PIL import Image10 11 12def check_seamless(image_path: str, column_width: int = 5) -> dict:13 """14 Load image, compare left and right edge columns. Equirectangular wraps,15 so left and right should match for a seamless skybox.16 Returns dict with mse, passed (bool), and message.17 """18 path = Path(image_path)19 if not path.is_file():20 return {21 "mse": float("inf"),22 "passed": False,23 "message": f"Image file not found: {path.name}",24 }25 img = np.array(Image.open(image_path).convert("RGB"))26 h, w = img.shape[:2]27 28 if w < 2 * column_width:29 return {30 "mse": float("inf"),31 "passed": False,32 "message": f"Image width {w} too small for column width {column_width}",33 }34 35 left = img[:, :column_width].astype(np.float32)36 right = img[:, -column_width:].astype(np.float32)37 mse = float(np.mean((left - right) ** 2))38 39 # Heuristic: MSE < 100 often looks reasonably seamless40 passed = mse < 10041 message = (42 f"Left/right edge MSE = {mse:.2f}. "43 + ("Seamless (edges match)." if passed else "Edges differ (consider 360° model).")44 )45 return {"mse": mse, "passed": passed, "message": message}46 