diff --git a/bob/rppg/chrom/extract_utils.py b/bob/rppg/chrom/extract_utils.py index 5f245f2bb4a0bb3d6cd42f286ef6a2297ad0778d..612fedc667a1807254f030c8605825ed991c3f3e 100644 --- a/bob/rppg/chrom/extract_utils.py +++ b/bob/rppg/chrom/extract_utils.py @@ -12,9 +12,9 @@ def compute_mean_rgb(image, mask=None): Parameters ---------- - image: 3d numpy array + image: numpy.ndarray The image to process - mask: 2d boolen numpy array + mask: numpy.ndarray Mask of the size of the image, telling which pixels should be considered @@ -40,9 +40,9 @@ def compute_gray_diff(previous, current): Parameters ---------- - previous: 3d numpy array + previous: numpy.ndarray The previous frame. - current: 3d numpy array + current: numpy.ndarray The current frame. Returns @@ -65,7 +65,7 @@ def select_stable_frames(diff, n): Parameters ---------- - diff: 1d numpy array + diff: numpy.ndarray The sum of absolute pixel intensity differences between consecutive frames, across the whole sequence. n: int diff --git a/bob/rppg/chrom/script/extract_pulse.py b/bob/rppg/chrom/script/extract_pulse.py index ae4d8ea0ab75a4a096ea61d0bce7815281d49762..ee1f2d26583c71904de0bb4cc40af5e017fd7d58 100644 --- a/bob/rppg/chrom/script/extract_pulse.py +++ b/bob/rppg/chrom/script/extract_pulse.py @@ -1,23 +1,6 @@ #!/usr/bin/env python # encoding: utf-8 -# Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ -# Written by Guillaume Heusch <guillaume.heusch@idiap.ch>, -# -# This file is part of bob.rpgg.base. -# -# bob.rppg.base is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# bob.rppg.base is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with bob.rppg.base. If not, see <http://www.gnu.org/licenses/>. - """Pulse extraction for database videos (%(version)s) Usage: diff --git a/bob/rppg/cvpr14/script/video2skin.py b/bob/rppg/cvpr14/script/video2skin.py index f196686b7a1e32ab2a7964bd6c02c39eced44db4..6b8037512c992276981363cf2a24bd63b9b0f2c9 100644 --- a/bob/rppg/cvpr14/script/video2skin.py +++ b/bob/rppg/cvpr14/script/video2skin.py @@ -1,29 +1,12 @@ #!/usr/bin/env python # encoding: utf-8 -# Copyright (c) 2017 Idiap Research Institute, http://www.idiap.ch/ -# Written by Guillaume Heusch <guillaume.heusch@idiap.ch>, -# -# This file is part of bob.rpgg.base. -# -# bob.rppg.base is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# bob.rppg.base is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with bob.rppg.base. If not, see <http://www.gnu.org/licenses/>. - -'''Skin color extraction for database videos (%(version)s) +"""Skin color extraction for database videos (%(version)s) Usage: %(prog)s (cohface | hci) [--protocol=<string>] [--subset=<string> ...] [--verbose ...] [--plot] - [--dbdir=<path>] [--outdir=<path>] [--limit=<int>] + [--dbdir=<path>] [--outdir=<path>] [--overwrite] [--threshold=<float>] [--skininit] [--gridcount] @@ -43,7 +26,6 @@ Options: -D, --dbdir=<path> The path to the database on your disk. If not set, defaults to Idiap standard locations. -o, --outdir=<path> Where the skin color will be stored [default: skin]. - -l, --limit=<int> Limits the processing to the first N videos of the database (for testing purposes) -O, --overwrite By default, we don't overwrite existing files. The processing will skip those so as to go faster. If you @@ -54,7 +36,6 @@ Options: - Examples: To run the skin color extraction on the hci database @@ -72,16 +53,16 @@ Examples: See '%(prog)s --help' for more information. -''' +""" +from __future__ import print_function import os import sys import pkg_resources -import logging -__logging_format__='[%(levelname)s] %(message)s' -logging.basicConfig(format=__logging_format__) -logger = logging.getLogger("extract_log") +from bob.core.log import set_verbosity_level +from bob.core.log import setup +logger = setup("bob.rppg.base") from docopt import docopt @@ -103,19 +84,11 @@ def main(user_input=None): arguments = sys.argv[1:] prog = os.path.basename(sys.argv[0]) - completions = dict( - prog=prog, - version=version, - ) - args = docopt( - __doc__ % completions, - argv=arguments, - version='Skin color extraction for videos (%s)' % version, - ) + completions = dict(prog=prog, version=version,) + args = docopt(__doc__ % completions, argv=arguments, version='Signal extractor for videos (%s)' % version,) # if the user wants more verbosity, lowers the logging level - if args['--verbose'] == 1: logging.getLogger().setLevel(logging.INFO) - elif args['--verbose'] >= 2: logging.getLogger().setLevel(logging.DEBUG) + set_verbosity_level(logger, args['--verbose']) # chooses the database driver to use if args['cohface']: @@ -153,21 +126,22 @@ def main(user_input=None): sys.exit() objects = db.objects(args['--protocol'], args['--subset']) - # tells the number of grid objects, and exit - if args['--gridcount']: - print len(objects) - sys.exit() - # if we are on a grid environment, just find what I have to process. - if os.environ.has_key('SGE_TASK_ID'): + sge = False + try: + sge = os.environ.has_key('SGE_TASK_ID') # python2 + except AttributeError: + sge = 'SGE_TASK_ID' in os.environ # python3 + + if sge: pos = int(os.environ['SGE_TASK_ID']) - 1 if pos >= len(objects): - raise RuntimeError, "Grid request for job %d on a setup with %d jobs" % \ - (pos, len(objects)) + raise RuntimeError("Grid request for job {} on a setup with {} jobs".format(pos, len(objects))) objects = [objects[pos]] - else: #maybe the user wants to limit the total amount of videos for testing - if args['--limit']: objects = objects[:int(args['--limit'])] + if args['--gridcount']: + print(len(objects)) + sys.exit() # does the actual work - for every video in the available dataset, # extract the average color in both the mask area and in the backround, diff --git a/setup.py b/setup.py index a2ffd5e8fc08380e1542bbe027d3abfffaf1fe74..9615800068d88cbd8103f87d939c579113188266 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,6 @@ setup( entry_points={ 'console_scripts': [ - 'rppg_bbox.py = bob.rppg.base.script.extract_boundingboxes:main', 'cvpr14_extract_signals.py = bob.rppg.cvpr14.script.extract_signals:main', 'cvpr14_video2skin.py = bob.rppg.cvpr14.script.video2skin:main', 'cvpr14_illumination.py = bob.rppg.cvpr14.script.illumination_rectification:main',