From 22135b4f4e18c5fba316ff7d6f80bdd9dc2cf5c2 Mon Sep 17 00:00:00 2001 From: "M.A." Date: Fri, 4 Jul 2025 23:05:40 +0200 Subject: [PATCH] Aktualisieren von MyPhotoCropper.html --- .../PhotoCropper/MyPhotoCropper.html | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/unsorted-stuff/PhotoCropper/MyPhotoCropper.html b/unsorted-stuff/PhotoCropper/MyPhotoCropper.html index 26ea555..5c5aa4e 100644 --- a/unsorted-stuff/PhotoCropper/MyPhotoCropper.html +++ b/unsorted-stuff/PhotoCropper/MyPhotoCropper.html @@ -599,20 +599,29 @@

🚀 Funktionen

try { // FaceDetector API verwenden (falls verfügbar) if ("FaceDetector" in window) { - const faceDetector = new FaceDetector(); - const faces = await faceDetector.detect(img); - this.detectedFaces = faces.map((face) => ({ - x: face.boundingBox.x, - y: face.boundingBox.y, - width: face.boundingBox.width, - height: face.boundingBox.height, - })); - } else { - // Fallback: Einfache Gesichtserkennung basierend auf Bildproportionen - // Diese Implementierung nimmt an, dass das Gesicht im oberen Drittel des Bildes ist - const estimatedFace = this.estimateFacePosition(img); - this.detectedFaces = [estimatedFace]; - } + alert("FaceDetector wird unterstützt."); + + try { + const faceDetector = new FaceDetector(); + const faces = await faceDetector.detect(img); + alert(`FaceDetector hat ${faces.length} Gesicht(er) erkannt.`); + + this.detectedFaces = faces.map((face) => ({ + x: face.boundingBox.x, + y: face.boundingBox.y, + width: face.boundingBox.width, + height: face.boundingBox.height, + })); + } catch (e) { + alert("FaceDetector existiert, aber detect() hat einen Fehler geworfen."); + console.error(e); + } +} else { + alert("FaceDetector wird nicht unterstützt. Nutze Fallback."); + + const estimatedFace = this.estimateFacePosition(img); + this.detectedFaces = [estimatedFace]; +} } catch (error) { console.log("Face detection failed, using estimation:", error); // Fallback auf geschätzte Position