bakeup
This commit is contained in:
@ -11,13 +11,10 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from move_detect import MoveDetect
|
||||
|
||||
|
||||
import sys
|
||||
sys.path.append(r"D:\DetectTracking")
|
||||
|
||||
# from tracking.utils.read_data import extract_data, read_deletedBarcode_file, read_tracking_output, read_weight_timeConsuming
|
||||
|
||||
|
||||
from tracking.utils.read_data import read_weight_timeConsuming
|
||||
|
||||
def str_to_float_arr(s):
|
||||
@ -118,7 +115,14 @@ def extract_data_1(datapath):
|
||||
|
||||
|
||||
def devide_motion_state(tboxes, width):
|
||||
'''frameTstamp: 用于标记当前相机视野内用购物车运动状态变化'''
|
||||
'''frameTstamp: 用于标记当前相机视野内用购物车运动状态变化
|
||||
|
||||
Hand状态:
|
||||
0: 不存在
|
||||
1: 手部存在
|
||||
2: 手部存在且处于某种状态(静止)
|
||||
|
||||
'''
|
||||
|
||||
periods = []
|
||||
if len(tboxes) < width:
|
||||
@ -131,28 +135,22 @@ def devide_motion_state(tboxes, width):
|
||||
|
||||
state = np.zeros((fnum, 2), dtype=np.int64)
|
||||
frameState = np.concatenate((frameTstamp, state), axis = 1).astype(np.int64)
|
||||
handState = np.concatenate((frameTstamp, state), axis = 1).astype(np.int64)
|
||||
|
||||
mtrackFid = {}
|
||||
handFid = {}
|
||||
'''frameState 标记由图像判断的购物车状态:0: 静止,1: 运动'''
|
||||
for idx in range(width, fnum+1):
|
||||
lboxes = np.concatenate(fboxes[idx-width:idx], axis = 0)
|
||||
|
||||
idx0 = idx-width
|
||||
|
||||
lboxes = np.concatenate(fboxes[idx0:idx], axis = 0)
|
||||
md = MoveDetect(lboxes)
|
||||
md.classify()
|
||||
|
||||
# if idx==60:
|
||||
# print('a')
|
||||
|
||||
## track.during 二元素组, 表征在该时间片段内,轨迹 track 的起止时间,数值用 boxes[:, 7]
|
||||
for track in md.track_motion:
|
||||
if track.cls == 0: continue
|
||||
|
||||
|
||||
|
||||
f1, f2 = track.during
|
||||
|
||||
|
||||
|
||||
# if track.cls == 0: continue
|
||||
idx1 = set(np.where(frameState[:,0] >= f1)[0])
|
||||
idx2 = set(np.where(frameState[:,0] <= f2)[0])
|
||||
idx3 = list(idx1.intersection(idx2))
|
||||
@ -164,7 +162,25 @@ def devide_motion_state(tboxes, width):
|
||||
|
||||
frameState[idx-1, 3] = 1
|
||||
frameState[idx3, 2] = 1
|
||||
|
||||
for track in md.hand_tracks:
|
||||
f11, f22 = track.during
|
||||
idx11 = set(np.where(handState[:,0] >= f11)[0])
|
||||
idx22 = set(np.where(handState[:,0] <= f22)[0])
|
||||
idx33 = list(idx11.intersection(idx22))
|
||||
|
||||
'''手部存在标记'''
|
||||
handState[idx33, 2] = 1
|
||||
'''未来改进方向:is_static 可以用手部状态判断的函数代替'''
|
||||
if track.is_static(70) and len(idx33)>1:
|
||||
idx11 = set(np.where(handState[:,0] >= f11)[0])
|
||||
idx22 = set(np.where(handState[:,0] <= f22)[0])
|
||||
idx33 = list(idx11.intersection(idx22))
|
||||
|
||||
'''手部静止标记'''
|
||||
handState[idx33, 2] = 2
|
||||
|
||||
|
||||
'''状态变化输出'''
|
||||
|
||||
for tid, fid in mtrackFid.items():
|
||||
@ -172,16 +188,11 @@ def devide_motion_state(tboxes, width):
|
||||
fstate[list(fid), 0] = tid
|
||||
|
||||
frameState = np.concatenate((frameState, fstate), axis = 1).astype(np.int64)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return frameState
|
||||
|
||||
return frameState, handState
|
||||
|
||||
|
||||
def state_measure(periods, weights, spath=None):
|
||||
def state_measure(periods, weights, hands, spath=None):
|
||||
'''两种状态:static、motion,
|
||||
(t0, t1)
|
||||
t0: static ----> motion
|
||||
@ -269,15 +280,16 @@ def main():
|
||||
|
||||
'''====================图像运动分析===================='''
|
||||
win_width = 12
|
||||
periods = []
|
||||
periods, hands = [], []
|
||||
for ctype, tboxes, _ in tracker_boxes:
|
||||
period = devide_motion_state(tboxes, win_width)
|
||||
period, handState = devide_motion_state(tboxes, win_width)
|
||||
|
||||
periods.append((ctype, period))
|
||||
hands.append((ctype, handState))
|
||||
print('done!')
|
||||
|
||||
'''===============重力、图像信息融合==================='''
|
||||
state_measure(periods, weights)
|
||||
state_measure(periods, weights, hands)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user