From e73cc5ebbe7faeeb58f4fbe41bf1c5bf09f582bb Mon Sep 17 00:00:00 2001 From: hluo76 Date: Mon, 16 Nov 2020 22:49:27 -0500 Subject: [PATCH] action recoginzation --- labels.json => data/labels.json | 0 localize.json => data/localize.json | 0 src/VoiceRecog.py | 3 +- src/action_recognization.py | 72 +++++++++++++++++++ .../get_action_labels.py | 0 .../interpret_lables.py | 0 .../interpret_localize.py | 0 pick-picture.py => src/pick-picture.py | 0 src/test.py | 18 ----- 9 files changed, 73 insertions(+), 20 deletions(-) rename labels.json => data/labels.json (100%) rename localize.json => data/localize.json (100%) create mode 100644 src/action_recognization.py rename get_action_labels.py => src/get_action_labels.py (100%) rename interpret_lables.py => src/interpret_lables.py (100%) rename interpret_localize.py => src/interpret_localize.py (100%) rename pick-picture.py => src/pick-picture.py (100%) delete mode 100644 src/test.py diff --git a/labels.json b/data/labels.json similarity index 100% rename from labels.json rename to data/labels.json diff --git a/localize.json b/data/localize.json similarity index 100% rename from localize.json rename to data/localize.json diff --git a/src/VoiceRecog.py b/src/VoiceRecog.py index ee2ea78..4069857 100644 --- a/src/VoiceRecog.py +++ b/src/VoiceRecog.py @@ -51,7 +51,6 @@ def recognize_speech_from_mic(recognizer, microphone): return response -''' + response = recognize_speech_from_mic(r, mic) print(response) -''' \ No newline at end of file diff --git a/src/action_recognization.py b/src/action_recognization.py new file mode 100644 index 0000000..096aff9 --- /dev/null +++ b/src/action_recognization.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Sat Nov 14 18:54:20 2020 + +@author: robin +""" + +import json +import os + +file = '/Users/robin/Downloads/video/src/output/lists/actions_present/' + +with open(file + 'train_labeled.json') as json_file: + datas = json.load(json_file) + + + +result = dict() +for key in datas: + data = dict() + val = datas[key] + move = 0 + rotate = 0 + contains = [] + movement = [] + for i in val: + if i[1] == ['before']: + if i[0][1][1] != '_rotate': + move += 1 + else: + rotate += 1 + if (len(movement) >0 and movement[-1] != i[0][0]) and (len(movement) >1 and movement[-2] != i[0][0]): + if i[0][0][1] != '_rotate': + move += 1 + else: + rotate += 1 + movement.append(i[0][0]) + movement.append(i[0][1]) + if i[1] == ['during']: + if (len(movement) >0 and movement[-1] != i[0][0]) and (len(movement) >1 and movement[-2] != i[0][0]): + movement.append(i[0][0]) + if i[0][0][1] != '_rotate': + move += 1 + else: + rotate += 1 + if (len(movement) >0 and movement[-1] != i[0][1]) and (len(movement) >1 and movement[-2] != i[0][1]) and (len(movement) >2 and movement[-3] != i[0][1]): + movement.append(i[0][1]) + if i[0][1][1] != '_rotate': + move += 1 + else: + rotate += 1 + elif i[1] == ['after']: + if i[0][0][1] != '_rotate': + move += 1 + else: + rotate += 1 + if (len(movement) >0 and movement[-1] != i[0][1]) and(len(movement) >1 and movement[-2] != i[0][1]): + if i[0][1][1] != '_rotate': + move += 1 + else: + rotate += 1 + movement.append(i[0][1]) + movement.append(i[0][0]) + data['rotate_no'] = rotate + data['item_move'] = movement + data['item_move_no'] = move + result[key] = data + + + + \ No newline at end of file diff --git a/get_action_labels.py b/src/get_action_labels.py similarity index 100% rename from get_action_labels.py rename to src/get_action_labels.py diff --git a/interpret_lables.py b/src/interpret_lables.py similarity index 100% rename from interpret_lables.py rename to src/interpret_lables.py diff --git a/interpret_localize.py b/src/interpret_localize.py similarity index 100% rename from interpret_localize.py rename to src/interpret_localize.py diff --git a/pick-picture.py b/src/pick-picture.py similarity index 100% rename from pick-picture.py rename to src/pick-picture.py diff --git a/src/test.py b/src/test.py deleted file mode 100644 index 2b2bca5..0000000 --- a/src/test.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Created on Sat Nov 14 18:54:20 2020 - -@author: robin -""" - -import json - -file = '/Users/robin/Downloads/video/src/output/lists/actions_present/' - -with open(file + 'train_labeled.json') as json_file: - data = json.load(json_file) - - -for key, val in data: - \ No newline at end of file