diff --git a/Prototype_2_Electric_Boogalooo.ipynb b/Prototype_2_Electric_Boogalooo.ipynb
index c0f0303..e4b8ac0 100644
--- a/Prototype_2_Electric_Boogalooo.ipynb
+++ b/Prototype_2_Electric_Boogalooo.ipynb
@@ -5,7 +5,7 @@
"colab": {
"provenance": [],
"mount_file_id": "1YJfEK8zha4PfUk2yP9y-XbO4vtmn83gE",
- "authorship_tag": "ABX9TyPqC8aZOBxrn5vwvNxHoub4",
+ "authorship_tag": "ABX9TyMolquwKNCOGgcRjrGvvv83",
"include_colab_link": true
},
"kernelspec": {
@@ -24,7 +24,7 @@
"colab_type": "text"
},
"source": [
- "
"
+ "
"
]
},
{
@@ -40,7 +40,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
- "id": "gmwahO7oITMz"
+ "id": "gmwahO7oITMz",
+ "collapsed": true
},
"outputs": [],
"source": [
@@ -69,10 +70,24 @@
" root_path = input(\"Enter path to the Fit Form AI Resources folder:\\n\")"
],
"metadata": {
- "id": "8xGt3oqXze3o"
+ "id": "8xGt3oqXze3o",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "9ae10864-4455-4ab5-e5f1-2b519aade848"
},
- "execution_count": null,
- "outputs": []
+ "execution_count": 1,
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n",
+ "Are you using your local drive without any subfolders? (Y / N)\n",
+ "Y\n"
+ ]
+ }
+ ]
},
{
"cell_type": "markdown",
@@ -107,12 +122,13 @@
"import os\n",
"import glob\n",
"import csv\n",
- "import warnings"
+ "import warnings\n",
+ "from statistics import mode"
],
"metadata": {
"id": "whZwvEdKIksm"
},
- "execution_count": null,
+ "execution_count": 2,
"outputs": []
},
{
@@ -278,7 +294,7 @@
"metadata": {
"id": "RHyJwan8acCz"
},
- "execution_count": null,
+ "execution_count": 3,
"outputs": []
},
{
@@ -297,18 +313,18 @@
],
"metadata": {
"id": "Zng2DvUJcJjc",
- "outputId": "5e773745-adb7-45d0-fbf6-dc47ad96e633",
+ "outputId": "7df33e6f-f54b-429d-e24b-51eecbf3bf4d",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
- "execution_count": null,
+ "execution_count": 4,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "What model to use? heavy\n"
+ "What model to use? (lite/heavy)heavy\n"
]
}
]
@@ -332,10 +348,23 @@
" vid_path = root_path + '/Fit Form AI Resources/Videos/'"
],
"metadata": {
- "id": "brFyKQV5aEuK"
+ "id": "brFyKQV5aEuK",
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "outputId": "866ffdac-10f0-4c4d-de33-75bd99e42524"
},
- "execution_count": null,
- "outputs": []
+ "execution_count": 5,
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Would you like to record and save the video you create below? (Y / N)\n",
+ "Y\n"
+ ]
+ }
+ ]
},
{
"cell_type": "code",
@@ -349,7 +378,7 @@
"if record:\n",
" out_video = cv.VideoWriter(vid_path + time.asctime(time.localtime()) + '.mp4',cv.VideoWriter_fourcc(*'DIVX'), 24, (640, 480))\n",
"landmarks_list = []\n",
- "feedback_list = [\"\"]\n",
+ "feedback_list = []\n",
"selected_exercise = input(\"What exercise are you tracking?\\n\")\n",
"\n",
"\n",
@@ -357,6 +386,12 @@
"def print_result(result: PoseLandmarkerResult, output_image: mp.Image, timestamp_ms: int):\n",
" if result.pose_landmarks:\n",
" annotated_image = np.copy(output_image.numpy_view())\n",
+ "\n",
+ " # TODO: Delete\n",
+ " blank = np.zeros((480, 640, 3), dtype=np.uint8)\n",
+ " annotated_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=blank)\n",
+ " annotated_image = np.copy(annotated_image.numpy_view())\n",
+ "\n",
" landmarks_list.append(result.pose_landmarks[0]) # Adds landmark data for pic to list\n",
" for landmark in result.pose_landmarks[0]:\n",
" pose_landmarks_proto = landmark_pb2.NormalizedLandmarkList()\n",
@@ -371,9 +406,8 @@
" # print(\"Frame\", timestamp_ms)\n",
" working_dstruct = lm_dstruct(landmarks_list[-1])\n",
" feedback_temp = working_dstruct.feedback(selected_exercise)\n",
- " if feedback_list[-1] != feedback_temp:\n",
- " print(feedback_temp)\n",
" feedback_list.append(feedback_temp)\n",
+ " print(mode(feedback_list[-3:]) if len(feedback_list) > 2 else feedback_temp)\n",
" if record:\n",
" out_video.write(annotated_image)\n",
"\n",
@@ -529,10 +563,335 @@
" out_video.release()"
],
"metadata": {
- "id": "GHzmhoO6Jc50"
+ "id": "GHzmhoO6Jc50",
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1000
+ },
+ "outputId": "6e04c043-dc90-48b7-b6c1-f453a267f8e2"
},
- "execution_count": null,
- "outputs": []
+ "execution_count": 7,
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "What exercise are you tracking?\n",
+ "Squat\n"
+ ]
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ ""
+ ],
+ "application/javascript": [
+ "\n",
+ " var video;\n",
+ " var div = null;\n",
+ " var stream;\n",
+ " var captureCanvas;\n",
+ " var imgElement;\n",
+ " var labelElement;\n",
+ "\n",
+ " var pendingResolve = null;\n",
+ " var shutdown = false;\n",
+ "\n",
+ " function removeDom() {\n",
+ " stream.getVideoTracks()[0].stop();\n",
+ " video.remove();\n",
+ " div.remove();\n",
+ " video = null;\n",
+ " div = null;\n",
+ " stream = null;\n",
+ " imgElement = null;\n",
+ " captureCanvas = null;\n",
+ " labelElement = null;\n",
+ " }\n",
+ "\n",
+ " function onAnimationFrame() {\n",
+ " if (!shutdown) {\n",
+ " window.requestAnimationFrame(onAnimationFrame);\n",
+ " }\n",
+ " if (pendingResolve) {\n",
+ " var result = \"\";\n",
+ " if (!shutdown) {\n",
+ " captureCanvas.getContext('2d').drawImage(video, 0, 0, 640, 480);\n",
+ " result = captureCanvas.toDataURL('image/jpeg', 0.8)\n",
+ " }\n",
+ " var lp = pendingResolve;\n",
+ " pendingResolve = null;\n",
+ " lp(result);\n",
+ " }\n",
+ " }\n",
+ "\n",
+ " async function createDom() {\n",
+ " if (div !== null) {\n",
+ " return stream;\n",
+ " }\n",
+ " div = document.createElement('div');\n",
+ " div.style.border = '2px solid black';\n",
+ " div.style.padding = '3px';\n",
+ " div.style.width = '100%';\n",
+ " div.style.maxWidth = '600px';\n",
+ " document.body.appendChild(div);\n",
+ "\n",
+ "\n",
+ " video = document.createElement('video');\n",
+ " video.style.display = 'block';\n",
+ " video.width = div.clientWidth - 6;\n",
+ " video.setAttribute('playsinline', '');\n",
+ " video.onclick = () => { shutdown = true; };\n",
+ " stream = await navigator.mediaDevices.getUserMedia(\n",
+ " {video: { facingMode: \"environment\"}});\n",
+ " div.appendChild(video);\n",
+ " imgElement = document.createElement('img');\n",
+ " imgElement.style.position = 'absolute';\n",
+ " imgElement.style.zIndex = 1;\n",
+ " imgElement.onclick = () => { shutdown = true; };\n",
+ " div.appendChild(imgElement);\n",
+ "\n",
+ " const instruction = document.createElement('div');\n",
+ " instruction.innerHTML =\n",
+ " '' +\n",
+ " 'click here to stop the video';\n",
+ " div.appendChild(instruction);\n",
+ " instruction.onclick = () => { shutdown = true; };\n",
+ "\n",
+ " video.srcObject = stream;\n",
+ " await video.play();\n",
+ " captureCanvas = document.createElement('canvas');\n",
+ " captureCanvas.width = 640;\n",
+ " captureCanvas.height = 480;\n",
+ " window.requestAnimationFrame(onAnimationFrame);\n",
+ "\n",
+ " return stream;\n",
+ " }\n",
+ " async function stream_frame() {\n",
+ " if (shutdown) {\n",
+ " removeDom();\n",
+ " shutdown = false;\n",
+ " return '';\n",
+ " }\n",
+ " var preCreate = Date.now();\n",
+ " stream = await createDom();\n",
+ "\n",
+ " var preShow = Date.now();\n",
+ "\n",
+ "\n",
+ "\n",
+ " var preCapture = Date.now();\n",
+ " var result = await new Promise(function(resolve, reject) {\n",
+ " pendingResolve = resolve;\n",
+ " });\n",
+ " shutdown = false;\n",
+ "\n",
+ " return {'create': preShow - preCreate,\n",
+ " 'show': preCapture - preShow,\n",
+ " 'capture': Date.now() - preCapture,\n",
+ " 'img': result};\n",
+ " }\n",
+ " "
+ ]
+ },
+ "metadata": {}
+ },
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Right Side of Body Isn't Visible\n",
+ "Left Side of Body Isn't Visible\n",
+ "Left Side of Body Isn't Visible\n",
+ "Left Side of Body Isn't Visible\n",
+ "Right Leg Isn't Visible\n",
+ "Right Leg Isn't Visible\n",
+ "Right Leg Isn't Visible\n",
+ "Left Leg Isn't Visible\n",
+ "Try Straightening Your Hip Somewhat\n",
+ "Good Form\n",
+ "Right Side of Body Isn't Visible\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Your Legs More\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Right Foot Isn't Visible\n",
+ "Good Form\n",
+ "Right Foot Isn't Visible\n",
+ "Good Form\n",
+ "Try Bending Your Legs More\n",
+ "Right Foot Isn't Visible\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Good Form\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Over More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Try Bending Your Legs More\n",
+ "Right Side of Body Isn't Visible\n"
+ ]
+ }
+ ]
}
]
-}
+}
\ No newline at end of file