Alistair MacDonald
Published

Tell me my time

A gesture operated announcement system to allow someone who is visually impaired to check lap times in a swimming pool.

BeginnerFull instructions provided82

Things used in this project

Hardware components

Google Coral Dev Board Mini
×1
USB-C OTG Cable
×1
EyonMe W6 Webcam
×1

Story

Read more

Code

swiming.py

Python
import cv2

from pose_engine import PoseEngine, KeypointType
from PIL import Image
from PIL import ImageDraw

from espeak import espeak
from time import sleep
import datetime

import sys
import os

espeak.set_voice("en")


cap = cv2.VideoCapture()

cap.open(1, apiPreference=cv2.CAP_V4L2)

cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('Y', 'U', 'Y', '2'))
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1024)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 768)
cap.set(cv2.CAP_PROP_FPS, 10.0)

if not cap.isOpened():
        sys.exit('Could not open video device')

engine = PoseEngine('models/mobilenet/posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite')


while True:

        ret, frame = cap.read()

        if ret:

                pil_image = Image.fromarray(frame)
                poses, inference_time = engine.DetectPosesInImage(pil_image)

                for pose in poses:
                        if pose.score < 0.4:
                                continue


                        left_hand = pose.keypoints[KeypointType.LEFT_WRIST]
                        right_hand = pose.keypoints[KeypointType.RIGHT_WRIST]
                        left_shoulder = pose.keypoints[KeypointType.NOSE]
                        right_shoulder = pose.keypoints[KeypointType.NOSE]

                        if ( left_hand.point[1] < left_shoulder.point[1] ) and ( right_hand.point[1] < right_shoulder.point[1] ):


                                now = datetime.datetime.now()
                                espeak.synth("The time is " + now.strftime("%-I %M %p and %-S seconds"))

                                while espeak.is_playing():
                                        cap.grab()
                                        pass

Credits

Alistair MacDonald

Alistair MacDonald

5 projects • 2 followers

Comments