Skip to content

Commit

Permalink
fix: clean up fall detections logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelin committed Jan 23, 2021
1 parent f7dba13 commit 88a4352
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ simplegeneric>=0.8.1
simplejson>=3.16.0
webencodings>=0.5.1
Werkzeug>=0.15.3
concurrent-log-handler>=0.9
concurrent-log-handler>=0.9.19
watchdog>=0.10
dynaconf>=3.1
apprise>=0.8.9pip
19 changes: 11 additions & 8 deletions src/ambianic/pipeline/ai/fall_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def find_keypoints(self, image):
else:
# we could not detect a pose with sufficient confidence
pose = None

if pose_dix:
log.debug(f"Pose detected with confidence {pose_score} and keypoints: {pose_dix}")

return pose, thumbnail, pose_score, pose_dix


Expand Down Expand Up @@ -305,17 +309,16 @@ def fall_detect(self, image=None):
now = time.monotonic()
lapse = now - self._prev_time
if self._prev_vals and lapse < self.min_time_between_frames:
log.debug("Received an image frame is too soone after the previous frame. Only %.2f ms apart. Minimum %.2f ms distance required for fall detection.", lapse, self.min_time_between_frames)
return None, self._prev_thumbnail
log.debug("Received an image frame too soon after the previous frame. Only %.2f ms apart. Minimum %.2f ms distance required for fall detection.", lapse, self.min_time_between_frames)
inference_result = None
thumbnail = self._prev_thumbnail
else:
# Detection using tensorflow posenet module
pose, thumbnail, pose_score, pose_dix = self.find_keypoints(image)
log.info("Pose detected : %r", pose_dix)

inference_result = None
if not pose:
log.debug("No pose with key-points found.")
return inference_result, thumbnail
log.debug("No pose detected or detection score does not meet confidence threshold.")
else:
inference_result = []

Expand Down Expand Up @@ -349,7 +352,7 @@ def fall_detect(self, image=None):
self.assign_prev_records(pose_dix, left_angle_with_yaxis, rigth_angle_with_yaxis, now, thumbnail, current_body_vector_score)

# log.debug("Logging stats")
self.log_stats(start_time=start_time)

log.info("thumbnail: %r", thumbnail)
return inference_result, thumbnail
self.log_stats(start_time=start_time)
log.debug("thumbnail: %r", thumbnail)
return inference_result, thumbnail

0 comments on commit 88a4352

Please sign in to comment.