Repository for extraction of reflectance curves of electrochromic materials reducing the effect of gamma correction using computer vision techniques and LEGO color calibration patches.
This project provides tools for analyzing electrochromic materials using video recordings and standardized LEGO color patches. The system includes:
# Clone the repository
git clone git@github.com:pgalantec/electrochromic_characterization.git
cd electrochromic_characterization
# Setup environment (installs uv if needed)
make init
# Activate environment
source .venv/bin/activate
# Clone the repository
git clone git@github.com:pgalantec/electrochromic_characterization.git
cd electrochromic_characterization
# Create virtual environment
make create_env
# Activate environment
source env/bin/activate
make help # Show all available commands
make init # Setup environment with uv (fast)
make create_env # Setup environment with standard venv
make clean # Remove all virtual environments
electrochromic_characterization/
βββ assets/ # Logo images
βββ dataset/ # Video files (.mp4, .avi)
βββ output/ # Experiment results
βββ src/ # Source code
β βββ lego_app_v4.py # Interactive configuration app
β βββ experiment.py # Analysis pipeline
β βββ opt_gamma.py # Gamma optimization
β βββ utils/ # Utility functions
βββ params.yaml # Experiment configuration
βββ Makefile # Development commands
βββ README.md
dataset/ directory.mp4, .avi, .movLaunch the interactive LEGO patch selector:
# Using uv environment
make run_config_app_uv
# Or using standard environment
make run_config_app
The application will open in your browser at http://localhost:8050 and provides:
params.yamlAlternatively, you can manually edit params.yaml:
videos:
- video_path: "dataset/your_video.mp4"
exp_name: "your_experiment_name"
calibration: false # Enable gamma correction
frame_dtype: Y # Color space: Y/gray/L
patches: [ # LEGO patch coordinates [x1,y1], [x2,y2]
[[20, 1200], [100, 1380]], # Black patch
[[20, 950], [100, 1150]], # Dark grey patch
[[20, 660], [100, 880]], # Clear grey patch
[[20, 400], [100, 600]] # White patch
]
lego_srgb: # Nominal LEGO sRGB values
black: [18, 18, 21]
dark_grey: [98, 101, 102]
clear_grey: [160, 163, 164]
white: [244, 238, 228]
Execute the experiment analysis:
# Using uv environment
make run_experiment_uv
# Or using standard environment
make run_experiment
The analysis pipeline will:
Results are stored in output/{video_name}/{experiment_name}/:
output/ExpCalY-OptGamma/
βββ config.json # Experiment configuration
βββ patches.png # Visualization of selected patches
βββ Mask.png # ROI binary mask
βββ gamma_linearization.jpg # Gamma correction plot
βββ r2_optimization.jpg # RΒ² optimization curve
βββ reflectance_curves.png # Main results visualization
βββ statistics.txt # Numerical analysis
βββ temporal_analysis/ # Frame-by-frame data
reflectance_curves.png: Main visualization showing temporal evolutionstatistics.txt: Numerical summary of the analysisconfig.json: Complete experiment configuration for reproducibilitygamma_linearization.jpg: Gamma correction validation plotsMask.png: ROI mask used for analysis# Code formatting
make format
# Code linting
make lint
# Clean all environments
make clean
# Show help
make help
The system uses 4 standardized LEGO color patches for calibration:
| Patch | Color | Nominal sRGB | Purpose |
|---|---|---|---|
| π€ | Black | [18, 18, 21] | Dark reference |
| β« | Dark Grey | [98, 101, 102] | Low-mid reference |
| βͺ | Clear Grey | [160, 163, 164] | Mid-high reference |
| β¬ | White | [244, 238, 228] | Bright reference |
Selection Order: Always select patches in this order for consistent results.
The LEGO patch selector application provides:
params.yaml automaticallydataset/ directory# Check environment
make help
# Verify installation
python -c "import dash; print('Dash installed successfully')"
# Check video files
ls dataset/
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this work in your research, please cite:
@software{electrochromic_characterization,
title={Electrochromic Characterization using Video Analysis},
author={GalΓ‘n, Pablo and PicΓ³n, Artzai and Velasco, Jon},
year={2024},
institution={Tecnalia Research \& Innovation, BCMaterials}
}
| Task | Command |
|---|---|
| Setup | make init |
| Configure | make run_config_app_uv |
| Analyze | make run_experiment_uv |
| Help | make help |
| Clean | make clean |
Happy analyzing! π¬β¨