Skip to content

Commit

Permalink
fix detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mzakharocsc committed Feb 17, 2021
1 parent d6f9211 commit dc32f3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
EVENT_THRESH = 45 #when to detect an event
STD_MAX = 20 #stdev above which we skip the event

POLL_RATE = 0.2 #latency on detection vs cpu/usage
POLL_RATE = 0.1 #latency on detection vs cpu/usage

GRAPH_DRAW_EVERY_FRAMES = 1 # skip frames, increase on older/slower devices
GRAPH_FREEZE = 4 #how many seconds to freeze graphs after shot is detected:w
Expand Down
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def get_value(self):
acc_time = acc_points_t[self.event_time_idx]
debug = None
if acc_time > points_t[-1]:
debug = 'accelerometer in future'
debug = 'accelerometer in the future'
event_time_idx = len(points_t) - 1
else:
event_time_idx = np.argmax(points_t >= acc_time)
Expand All @@ -229,7 +229,7 @@ def get_value(self):
log.warning(f"detect: '{debug}' ori: idx={event_time_idx}/{len(points_t)-1} buf={points_t[-6:]}\nacc_time: {acc_time} acc_idx={self.event_time_idx}/{len(acc_points_t)-1}")

# remove a few samples that may have been contaminated with the event TODO: use mcmc or some other method to remove contaminated samples?
event_time_idx -= 5
event_time_idx -= 7

orig_points = points
orig_points_t = points_t
Expand Down Expand Up @@ -258,8 +258,8 @@ def get_value(self):

if detected:
self.update_cnt = -int(GRAPH_FREEZE / POLL_RATE) #freeze graph after event
return True, points, std
return False, points, std
return True, acc_points, points, std
return False, acc_points, points, std


class AccelerometerScreen(CommonScreen):
Expand All @@ -286,7 +286,7 @@ def start(self):
self.update_cnt = 0

def get_value(self, dt):
draw, points, _ = super().get_value()
draw, points, _, _ = super().get_value()
if draw:
gr = self.ids.graph
gr.ymax = min(ACCELEROMETER_Y_LIMIT, max(1, int(points.max() + 1)))
Expand Down Expand Up @@ -323,7 +323,7 @@ def start(self):
self.update_cnt = 0

def get_value(self, dt):
draw, points, std = super().get_value()
draw, _, points, std = super().get_value()

if draw:
for i, plot in enumerate(self.plots):
Expand Down

0 comments on commit dc32f3d

Please sign in to comment.