facial tremor testing

This commit is contained in:
Vidya Koesmahargyo
2020-11-30 09:43:09 -05:00
parent f9f5b4ec5f
commit 517e54bf81
4 changed files with 29 additions and 18 deletions

View File

@@ -7,7 +7,7 @@ created: 2020-20-07
from dbm_lib.dbm_features.raw_features.audio import intensity, pitch_freq, hnr, gne, voice_frame_score, formant_freq from dbm_lib.dbm_features.raw_features.audio import intensity, pitch_freq, hnr, gne, voice_frame_score, formant_freq
from dbm_lib.dbm_features.raw_features.audio import pause_segment, jitter, shimmer, mfcc from dbm_lib.dbm_features.raw_features.audio import pause_segment, jitter, shimmer, mfcc
from dbm_lib.dbm_features.raw_features.video import face_asymmetry, face_au, face_emotion_expressivity, face_landmark from dbm_lib.dbm_features.raw_features.video import face_asymmetry, face_au, face_emotion_expressivity, face_landmark
from dbm_lib.dbm_features.raw_features.movement import head_motion, eye_blink, voice_tremor from dbm_lib.dbm_features.raw_features.movement import head_motion, eye_blink, voice_tremor, facial_tremor
import subprocess import subprocess
import logging import logging
@@ -120,6 +120,7 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model):
return return
logger.info('Processing movement variables from data in {}'.format(video_uri)) logger.info('Processing movement variables from data in {}'.format(video_uri))
logger.info('processing head movement....') logger.info('processing head movement....')
head_motion.run_head_movement(video_uri, out_dir, r_config) head_motion.run_head_movement(video_uri, out_dir, r_config)
@@ -129,6 +130,9 @@ def process_movement(video_uri, out_dir, dbm_group, r_config, dlib_model):
logger.info('processing voice tremor....') logger.info('processing voice tremor....')
voice_tremor.run_vtremor(video_uri, out_dir, r_config) voice_tremor.run_vtremor(video_uri, out_dir, r_config)
logger.info('processing facial tremor....')
face_tremor.fac_tremor_process(video_uri, out_dir, r_config, model_output=True)
def remove_file(file_path): def remove_file(file_path):
""" """
removing wav file removing wav file

View File

@@ -13,3 +13,4 @@ import os
DBMLIB_PATH = os.path.dirname(__file__) DBMLIB_PATH = os.path.dirname(__file__)
DBMLIB_VTREMOR_LIB = os.path.abspath(os.path.join(DBMLIB_PATH, DBMLIB_VTREMOR_LIB = os.path.abspath(os.path.join(DBMLIB_PATH,
'../../../../resources/libraries/voice_tremor.praat')) '../../../../resources/libraries/voice_tremor.praat'))
DBMLIB_FTREMOR_CONFIG = os.path.abspath(os.path.join(DBMLIB_PATH, '../resources/features/facial/config.json'))

View File

@@ -15,9 +15,9 @@ from dbm_lib.dbm_features.raw_features.util import util as ut
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
logger=logging.getLogger() logger=logging.getLogger()
def batch_open_face(filepaths,video_url, input_dir, out_dir, of_path): def batch_open_face(filepaths,video_url, input_dir, out_dir, of_path,video_tracking=False):
""" Computes open_face features for the files in filepaths """ Computes open_face features for the files in filepaths
Args: Args:
----- -----
filepaths: (itreable[str]) filepaths: (itreable[str])
@@ -27,46 +27,49 @@ def batch_open_face(filepaths,video_url, input_dir, out_dir, of_path):
input_dir: Path to the input videos input_dir: Path to the input videos
out_dir: Path to the processed output out_dir: Path to the processed output
of_path: OpenFace source code path of_path: OpenFace source code path
Returns: Returns:
-------- --------
(itreable[str]) list of .csv files (itreable[str]) list of .csv files
""" """
if video_tracking:
suffix = '_OF_features' suffix = '_OF_video_features/'
else:
suffix = '_OF_features'
csv_files = [] csv_files = []
for fp in filepaths: for fp in filepaths:
try: try:
_, out_loc, fl_name = ut.filter_path(video_url, out_dir) _, out_loc, fl_name = ut.filter_path(video_url, out_dir)
full_f_name = fl_name + suffix full_f_name = fl_name + suffix
output_directory = os.path.join(out_loc, full_f_name) output_directory = os.path.join(out_loc, full_f_name)
csv_files.append(ut.compute_open_face_features(fp,output_directory,of_path)) csv_files.append(ut.compute_open_face_features(fp,output_directory,of_path))
except Exception as e: except Exception as e:
logger.error('Failed to run OpenFace on {}\n{}'.format(fp, e)) logger.error('Failed to run OpenFace on {}\n{}'.format(fp, e))
return csv_files return csv_files
def process_open_face(video_uri, input_dir, out_dir, of_path, dbm_group): def process_open_face(video_uri, input_dir, out_dir, of_path, dbm_group,video_tracking):
""" """
Processing all patient's for fetching emotion expressivity Processing all patient's for fetching emotion expressivity
------------------- -------------------
------------------- -------------------
Args: Args:
video_uri: video path; input_dir : input directory for video's; dbm_group: feature group video_uri: video path; input_dir : input directory for video's; dbm_group: feature group
out_dir: (str) Output directory for processed output; of_path: OpenFace source code path out_dir: (str) Output directory for processed output; of_path: OpenFace source code path
""" """
try: try:
if dbm_group != None and len(dbm_group) == 1 and 'acoustic' in dbm_group: if dbm_group != None and len(dbm_group) == 1 and 'acoustic' in dbm_group:
return return
filepaths = [video_uri] filepaths = [video_uri]
csv_filepaths = batch_open_face(filepaths, video_uri, input_dir, out_dir, of_path) csv_filepaths = batch_open_face(filepaths, video_uri, input_dir, out_dir, of_path,video_tracking)
except Exception as e: except Exception as e:
logger.error('Failed to process video file') logger.error('Failed to process video file')

View File

@@ -19,6 +19,8 @@ import time
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
logger=logging.getLogger() logger=logging.getLogger()
#for ftremor
OPENFACE_PATH_VIDEO = '/pkg/OpenFace/build/bin/FaceLandmarkVid'
OPENFACE_PATH = 'pkg/OpenFace/build/bin/FeatureExtraction' OPENFACE_PATH = 'pkg/OpenFace/build/bin/FeatureExtraction'
DLIB_SHAPE_MODEL = 'pkg/shape_detector/shape_predictor_68_face_landmarks.dat' DLIB_SHAPE_MODEL = 'pkg/shape_detector/shape_predictor_68_face_landmarks.dat'
@@ -35,6 +37,7 @@ def common_video(video_file, args, r_config):
of.process_open_face(video_file, os.path.dirname(video_file), out_path, OPENFACE_PATH, args.dbm_group) of.process_open_face(video_file, os.path.dirname(video_file), out_path, OPENFACE_PATH, args.dbm_group)
pf.process_facial(video_file, out_path, args.dbm_group, r_config) pf.process_facial(video_file, out_path, args.dbm_group, r_config)
pf.process_acoustic(video_file, out_path, args.dbm_group, r_config) pf.process_acoustic(video_file, out_path, args.dbm_group, r_config)
of.process_open_face(video_file, os.path.dirname(video_file), out_path, OPENFACE_PATH_VIDEO, args.dbm_group,video_tracking=True)
pf.process_movement(video_file, out_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL) pf.process_movement(video_file, out_path, args.dbm_group, r_config, DLIB_SHAPE_MODEL)
pf.remove_file(video_file) pf.remove_file(video_file)