Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
483 changes: 483 additions & 0 deletions Untitled.ipynb

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions bard_code.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'mediapipe.framework.packet_pb2'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[3], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mmediapipe\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mmp\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mmediapipe\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mframework\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mformats\u001b[39;00m \u001b[39mimport\u001b[39;00m landmark_pb2\n\u001b[1;32m----> 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mmediapipe\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mframework\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpacket_pb2\u001b[39;00m \u001b[39mimport\u001b[39;00m Packet\n\u001b[0;32m 5\u001b[0m \u001b[39m# Define list of values\u001b[39;00m\n\u001b[0;32m 6\u001b[0m values \u001b[39m=\u001b[39m [\u001b[39m0.1\u001b[39m, \u001b[39m0.2\u001b[39m, \u001b[39m0.3\u001b[39m, \u001b[39m0.4\u001b[39m, \u001b[39m0.5\u001b[39m, \u001b[39m0.6\u001b[39m]\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'mediapipe.framework.packet_pb2'"
]
}
],
"source": [
"import mediapipe as mp\n",
"from mediapipe.framework.formats import landmark_pb2\n",
"from mediapipe.framework.packet_pb2 import Packet\n",
"\n",
"# Define list of values\n",
"values = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]\n",
"\n",
"# Create NormalizedLandmarkList proto object\n",
"landmark_list = landmark_pb2.NormalizedLandmarkList()\n",
"for i in range(len(values)//2):\n",
" landmark = landmark_list.landmark.add()\n",
" landmark.x = values[2*i]\n",
" landmark.y = values[2*i+1]\n",
"\n",
"# Create Packet object with NormalizedLandmarkList proto\n",
"packet = Packet()\n",
"packet.Set(landmark_list.SerializeToString())\n",
"\n",
"# Create MediaPipe result object\n",
"result = mp.Results()\n",
"result.multi_hand_landmarks.append(packet)\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'mediapipe.python.solutions' has no attribute 'holistic_avatar'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[2], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mcv2\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[39m# Import the MediaPipe Holistic Avatar model.\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m holistic_avatar \u001b[39m=\u001b[39m mp\u001b[39m.\u001b[39;49msolutions\u001b[39m.\u001b[39;49mholistic_avatar\u001b[39m.\u001b[39mHolisticAvatar()\n\u001b[0;32m 5\u001b[0m \u001b[39m# Create a video capture object.\u001b[39;00m\n\u001b[0;32m 6\u001b[0m cap \u001b[39m=\u001b[39m cv2\u001b[39m.\u001b[39mVideoCapture(\u001b[39m0\u001b[39m)\n",
"\u001b[1;31mAttributeError\u001b[0m: module 'mediapipe.python.solutions' has no attribute 'holistic_avatar'"
]
}
],
"source": [
"import cv2\n",
"# Import the MediaPipe Holistic Avatar model.\n",
"holistic_avatar = mp.solutions.holistic_avatar.HolisticAvatar()\n",
"\n",
"# Create a video capture object.\n",
"cap = cv2.VideoCapture(0)\n",
"\n",
"# Start the MediaPipe Holistic Avatar model.\n",
"holistic_avatar.start()\n",
"\n",
"# Get the pose estimates from the model.\n",
"while True:\n",
" # Get a frame from the video capture object.\n",
" ret, frame = cap.read()\n",
"\n",
" # Get the pose estimates from the MediaPipe Holistic Avatar model.\n",
" pose = holistic_avatar.process(frame)\n",
"\n",
" # Pose the avatar using the pose estimates.\n",
" holistic_avatar.pose(pose)\n",
"\n",
" # Render the avatar.\n",
" holistic_avatar.render()\n",
"\n",
" # Display the frame.\n",
" cv2.imshow(\"MediaPipe Holistic Avatar\", frame)\n",
"\n",
" # If the user presses the \"q\" key, stop the program.\n",
" if cv2.waitKey(1) & 0xFF == ord(\"q\"):\n",
" break\n",
"\n",
"# Stop the MediaPipe Holistic Avatar model.\n",
"holistic_avatar.stop()\n",
"\n",
"# Close the video capture object.\n",
"cap.release()\n",
"\n",
"# Destroy all windows.\n",
"cv2.destroyAllWindows()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading