phuselab / pyVHR

Python framework for Virtual Heart Rate
http://phuselab.di.unimi.it/
GNU General Public License v3.0
461 stars 128 forks source link

Get bpm from a random video #75

Open RA-DM opened 1 year ago

RA-DM commented 1 year ago

It seems that the code in https://github.com/phuselab/pyVHR/issues/13 can't work now, is there any other way to get bpm from a random video? Does the run_on_video function in readme.md take effect in a random video?

from pyVHR.signals.video import Video Traceback (most recent call last): File "\<stdin>", line 1, in ModuleNotFoundError: No module named 'pyVHR.signals'

wang-tf commented 1 year ago

You can using pipeline like pyVHR_run_on_video.ipynb

#### TEST holistic approach
from pyVHR.analysis.pipeline import Pipeline

# params
videoFileName = "video.avi"  # your video path
roi_approach = 'holistic'   # 'holistic' or 'patches'
bpm_est = 'median'         # BPM final estimate, if patches choose 'medians' or 'clustering'
method = 'cpu_CHROM'       # one of the methods implemented in pyVHR
pipe = Pipeline()          # object to execute the pipeline

# run
bvps, timesES, bpmES = pipe.run_on_video(videoFileName,
                                        winsize=8, 
                                        roi_method='convexhull',
                                        roi_approach=roi_approach,
                                        method=method,
                                        estimate=bpm_est,
                                        patch_size=40, 
                                        RGB_LOW_HIGH_TH=(5,230),
                                        Skin_LOW_HIGH_TH=(5,230),
                                        pre_filt=True,
                                        post_filt=True,
                                        cuda=False, 
                                        verb=True
)