diff options
| author | adamhrv <adam@ahprojects.com> | 2019-04-10 23:04:29 +0200 |
|---|---|---|
| committer | adamhrv <adam@ahprojects.com> | 2019-04-10 23:04:29 +0200 |
| commit | 8032dc798287b0ae26342063c3016858f2b44974 (patch) | |
| tree | c47bb7dc13b2dbba550fb627152f0089191f904b /megapixels/app/utils | |
| parent | 05d96677b8f58780248e45e28510b3ef8ed1e1b9 (diff) | |
add body detector, mod pull sheet
Diffstat (limited to 'megapixels/app/utils')
| -rw-r--r-- | megapixels/app/utils/display_utils.py | 7 | ||||
| -rw-r--r-- | megapixels/app/utils/identity_utils.py | 19 |
2 files changed, 23 insertions, 3 deletions
diff --git a/megapixels/app/utils/display_utils.py b/megapixels/app/utils/display_utils.py index 43328ae9..8e265ae7 100644 --- a/megapixels/app/utils/display_utils.py +++ b/megapixels/app/utils/display_utils.py @@ -19,3 +19,10 @@ def handle_keyboard(delay_amt=1): break elif k != 255: log.debug(f'k: {k}') + +def handle_keyboard_video(delay_amt=1): + key = cv.waitKey(1) & 0xFF + # if the `q` key was pressed, break from the loop + if key == ord("q"): + cv.destroyAllWindows() + sys.exit() diff --git a/megapixels/app/utils/identity_utils.py b/megapixels/app/utils/identity_utils.py index 775652dc..5855fbbd 100644 --- a/megapixels/app/utils/identity_utils.py +++ b/megapixels/app/utils/identity_utils.py @@ -29,6 +29,13 @@ def names_match_strict(a, b): return len(clean_a) == len(clean_b) and letter_match(clean_a, clean_b) and letter_match(clean_b, clean_a) +def sanitize_name(name, as_str=False): + splits = [unidecode.unidecode(x.strip().lower()) for x in name.strip().split(' ')] + if as_str: + return ' '.join(splits) + else: + return splits + ''' class Dataset(Enum): LFW, VGG_FACE, VGG_FACE2, MSCELEB, UCCS, UMD_FACES, SCUT_FBP, UCF_SELFIE, UTK, \ @@ -106,12 +113,18 @@ def get_names(opt_dataset, opt_data_store=types.DataStore.HDD): def similarity(a, b): return difflib.SequenceMatcher(a=a.lower(), b=b.lower()).ratio() -def names_match(name_a, name_b, threshold=0.9, as_float=False, compound_score=False): +def names_match(name_a, name_b, threshold=0.9, as_float=False, compound_score=False, name_a_pre=False, name_b_pre=False): '''Returns boolean if names are similar enough ''' # strip spaces and split names into list of plain text words - name_a_clean = [unidecode.unidecode(x.strip().lower()) for x in name_a.strip().split(' ')] - name_b_clean = [unidecode.unidecode(x.strip().lower()) for x in name_b.strip().split(' ')] + if name_a_pre: + name_a_clean = name_a + else: + name_a_clean = [unidecode.unidecode(x.strip().lower()) for x in name_a.strip().split(' ')] + if name_b_pre: + name_b_clean = name_b + else: + name_b_clean = [unidecode.unidecode(x.strip().lower()) for x in name_b.strip().split(' ')] # assign short long vars len_a = len(name_a_clean) |
