Skip to content

Commit

Permalink
action recoginzation
Browse files Browse the repository at this point in the history
  • Loading branch information
hluo76 committed Nov 17, 2020
1 parent 516bd83 commit e73cc5e
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 20 deletions.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions src/VoiceRecog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def recognize_speech_from_mic(recognizer, microphone):
return response


'''

response = recognize_speech_from_mic(r, mic)
print(response)
'''
72 changes: 72 additions & 0 deletions src/action_recognization.py
Original file line number Diff line number Diff line change
@@ -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




File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions src/test.py

This file was deleted.

0 comments on commit e73cc5e

Please sign in to comment.