The Mirror Demo, located in ExampleScripts - Mirror_Demo, allows you to view your reflection in a virtual mirror in VR. It includes features such as:
Avatar swapping
Facial expression tracking
Body and hand tracking
Customizable environments
Adding a reflective mirror object
Additionally, facial expression data can be saved and analyzed later. The demo is part of SightLab, accessible under ExampleScripts - Mirror_Demo.
Configure Settings
Edit the MirrorConfig.py file to customize the following parameters:
swapAvatarKey: Key to advance media (default: 'c').
UseExternalPath: Set to True to use a custom path for avatars (head and hands). The full body uses the local folder resources/full_body.
AvatarFolderPath: Path to your avatars.
environment: Path to the environment file.
starting_position: Starting point coordinates.
reset_starting_position: Coordinates for resetting the starting position ('r' key).
Avatar Library Adjustments Can add names to the various avatar libraries if needing to move the position or change facial morph values.
Mixamo Avatars:
MIXAMO: Add Mixamo avatar names here.
MIXAMO_POSITION_POSITION:[0, -1.1, -0.09]`
ReadyPlayerMe Avatars:
Add names in READY_PLAYER_ME.
READY_PLAYER_ME_POSITION: [0, -0.7, -0.09]
RocketBox Avatars:
Add names in ROCKET_BOX.
ROCKET_BOX_POSITION: [0, -0.07, -0.09]
Other Options:
MORPH: Set to True to enable facial morphs.
BIOPAC_ON: Toggle Biopac AcqKnowledge signal sending.
videoRecording: Set to 1 to enable video recording (saved in the recordings folder).
Adding New Avatars
To add new avatars:
Place them in the resources folder.
They will automatically be included in the scene.
Support for most avatar libraries (Reallusion, Metaperson, Mixamo, ReadyPlayerMe, RocketBox and more. See this page for more details). Can also download more avatars with the additional assets pack.
Run the Demo
Follow these steps to run the demo:
Execute virtual_mirror.py.
Choose your hardware.
Use the 'c' key to cycle through avatars.
Use sessionReplay to replay the scene (only shows the first selected avatar).
Features such as:
Facial expressions, hand, and body tracking (Meta Quest Pro).
Body and hand tracking only (Meta Quest 3).
Save facial expression data in the data folder as date_time+expressions.csv.
To visualize facial expressions over time, use facial_expressions_over_time with Matplotlib and Pandas.
Alternate Version
The virtual_mirror_w_slider version displays a panel showing data from all face tracking parameters.
Adding a Mirror to Your Scene
To add a mirror to your own scene:
Import the mirror module using from sightlab_utils.mirror import placeMirror
Use Inspector
(Tools > Inspector) to:
Add a 2D plane (any image works) to your scene.
Position it where desired.
Rename it 'mirror' (right-click to rename).
If the mirror isn't visible, adjust its rotation via "Euler" values.
# Import the mirror modulefromsightlab_utils.mirrorimportplaceMirror#Name of environment and mirror objectplaceMirror(env,'mirror')#Optional add to view avatar head (not needed for the full body avatars)sightlab.setAvatarHead(head=vizfx.addChild(AVATAR_HEAD_RESOURCE_PATH+"/Male1.osgb"))
Avatar Modification
Included avatars are in resources\full_body and referenced to C:\Program Files\Sightlab2\sightlab_resources\avatar\full_body. To modify: