#!/usr/bin/env python3 """ Create a demo smart comic to show the feature working """ import os import numpy as np import cv2 def create_demo_frames(): """Create demo frames with different expressions""" os.makedirs('frames/final', exist_ok=True) os.makedirs('output', exist_ok=True) # Create simple demo frames with text expressions = [ ('happy', 'š', (100, 255, 100)), ('sad', 'š¢', (255, 100, 100)), ('surprised', 'š®', (100, 100, 255)), ('angry', 'š ', (100, 100, 200)), ('neutral', 'š', (200, 200, 200)), ('happy', 'š', (150, 255, 150)), ('scared', 'šØ', (255, 150, 100)), ('happy', 'š', (100, 255, 150)), ('sad', 'š', (255, 150, 150)), ('excited', 'š¤©', (255, 255, 100)), ('neutral', 'š', (180, 180, 180)), ('happy', 'š', (120, 255, 120)) ] for i, (emotion, emoji, color) in enumerate(expressions): # Create a simple frame img = np.ones((400, 400, 3), dtype=np.uint8) * 255 # Add colored border cv2.rectangle(img, (10, 10), (390, 390), color, 10) # Add text cv2.putText(img, f"Frame {i+1}", (150, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2) cv2.putText(img, emotion.upper(), (140, 250), cv2.FONT_HERSHEY_SIMPLEX, 0.8, color, 2) # Save frame cv2.imwrite(f'frames/final/frame{i:03d}.png', img) print(f"ā Created {len(expressions)} demo frames") return expressions def create_demo_smart_comic(expressions): """Create the smart comic HTML""" dialogues = [ ("Hello! I'm so happy to see you!", 'happy'), ("Oh no, I lost my favorite toy...", 'sad'), ("What?! Is that a surprise party?", 'surprised'), ("I can't believe you did that!", 'angry'), ("Okay, let's continue with our day.", 'neutral'), ("This is the best day ever!", 'happy'), ("I'm scared of the dark...", 'scared'), ("We did it! We won!", 'happy'), ("I miss my old friends...", 'sad'), ("This is so exciting!", 'excited'), ("Sure, that works for me.", 'neutral'), ("Thank you for everything!", 'happy') ] html = '''
AI-powered emotion detection matches dialogue sentiment with facial expressions
⨠Features: Eye state detection ⢠Emotion analysis ⢠Smart frame selection
This smart comic uses AI to match dialogue emotions with facial expressions,
ensuring characters' faces match what they're saying while avoiding frames with closed eyes.