CodePhys: Robust Video-based Remote Physiological Measurement through Latent Codebook Querying

Shuyang Chu, Menghan Xia, Mengyao Yuan, Xin Liu, Tapio Seppänen, Guoying Zhao, Jingang Shi · DOI

Abstract

Remote photoplethysmography (rPPG) enables non-contact physiological monitoring by detecting subtle skin color changes in facial videos. However, real-world applications are often hindered by environmental noise, motion blur, and varying illumination. We present CodePhys, a novel framework that reformulates rPPG as a "code query" task. By leveraging a discrete codebook of noise-free ground-truth PPG features, CodePhys maps interference-laden video features to clean physiological signals. Our approach demonstrates superior robustness and state-of-the-art performance across multiple benchmark datasets.

Introduction

Measuring physiological signals like heart rate through standard camera sensors is a significant challenge due to the microscopic nature of the target signal. Traditional deep learning methods attempt to map video frames directly to heart rate signals, often leading to overfitting on visual artifacts such as head movements, camera noise, and lighting fluctuations. While some methods employ hand-crafted modules to mitigate specific noise types, they lack the flexibility to handle diverse, unexpected interferences.

Conceptual comparison: (a) standard end-to-end mapping, (b) hand-crafted modules, and (c) the proposed CodePhys approach using codebook querying.

CodePhys addresses these limitations by introducing a strong prior of what a "clean" signal should look like. Instead of direct estimation, it uses noisy video features to query a pre-learned dictionary of fundamental, noise-free heartbeat patterns, effectively filtering out visual noise at the representation level.

Methodology

The CodePhys framework operates in two distinct stages, utilizing discrete representation learning to bridge the gap between noisy video data and clean physiological signals.

Stage I: Codebook Learning

In the first stage, an autoencoder is trained exclusively on clean, ground-truth (GT) PPG signals obtained from contact sensors. The encoder compresses these signals into a discrete codebook—a dictionary of 64 noise-free feature vectors representing fundamental heartbeat characteristics. This ensures the model has a robust internal representation of valid physiological signals.

Stage II: rPPG Measurement

During inference, a spatial-aware video encoder extracts features from the input facial video. Rather than decoding these features directly, CodePhys uses them to query the learned codebook for the closest matching clean features. A frozen decoder then reconstructs the final rPPG signal from these retrieved codes.

The complete CodePhys architecture, showing Stage I (Codebook Learning) and Stage II (rPPG Measurement with Auxiliary Prior Branch and Spatio-temporal Encoder).

To optimize feature extraction, the authors introduced two key components:

  • Spatial Attention Mechanism (SAM): This module dynamically focuses on physiologically informative regions, such as the forehead and cheeks, while suppressing irrelevant background noise.
  • Soft Feature Distillation (SFD): During training, GT-PPG features guide the video encoder to maintain a strict periodic rhythm, enhancing resistance to non-periodic visual interference.

Experimental Evaluation

CodePhys was evaluated on four benchmark datasets: VIPL-HR, UBFC-rPPG, PURE, and COHFACE. These datasets encompass challenges ranging from severe head motion to high video compression.

  • State-of-the-Art Performance: On the VIPL-HR dataset, CodePhys achieved a Mean Absolute Error (MAE) of 4.27 bpm, outperforming 32 baseline methods. On UBFC-rPPG, it reached a near-perfect MAE of 0.21 bpm.
  • Generalization and Robustness: The model demonstrated exceptional cross-dataset generalization (MAE of 4.03 bpm when trained on VIPL-HR and tested on PURE). Furthermore, under simulated degradations like blur and occlusion, CodePhys maintained stable performance while baseline models saw significant error spikes.
  • Efficiency: With only 5.73M parameters and an inference speed of 0.12 ms/frame, the model is suitable for real-time applications.

Conclusion

CodePhys introduces a paradigm shift in remote physiological measurement by treating signal extraction as a discrete codebook query task. By enforcing a clean signal prior, the model inherently filters out diverse visual noise that plagues traditional methods. Future work will explore further optimization for resource-constrained edge devices and the integration of additional physiological cues to further enhance signal fidelity in-the-wild.

Summary updated

BibTeX
@article{chu2025codephys,
  author = {Shuyang Chu and Menghan Xia and Mengyao Yuan and Xin Liu and Tapio Seppänen and Guoying Zhao and Jingang Shi},
  title = {{CodePhys: Robust Video-based Remote Physiological Measurement through Latent Codebook Querying}},
  journal = {IEEE J. Biomed. Health Informatics},
  year = {2025},
  doi = {10.1109/jbhi.2025.3540134},
}
Figure