Obtaining live landmarks for live feed

parent 6f538380
......@@ -78,11 +78,43 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2dd22017",
"id": "d27b1da2",
"metadata": {},
"outputs": [],
"source": [
"#testblock"
"#Video Feed\n",
"\n",
"#setting up video feed device\n",
"#number in VideoCapture = number of device\n",
"cap = cv2.VideoCapture(0) \n",
"#set up media pipe instance\n",
"with mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5) as pose:\n",
" while cap.isOpened():\n",
" ret, frame = cap.read() #get current feed from device\n",
"\n",
" #detect stuff and render\n",
" image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) #recolouring image\n",
" image.flags.writeable = False\n",
"\n",
" #make detection\n",
" results = pose.process(image)\n",
"\n",
" #recolouring image to format required by openCV\n",
" image.flags.writeable = True\n",
" image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)\n",
"\n",
" #render image\n",
" #draw landmarks\n",
" mp_drawing.draw_landmarks(image, results.pose_landmarks, mp_pose.POSE_CONNECTIONS,\n",
" mp_drawing.DrawingSpec(color=(245,117,66), thickness=2, circle_radius=2), #changing the colours of the dots, default is green\n",
" mp_drawing.DrawingSpec(color=(245,117,66), thickness=2, circle_radius=2)) #changing the colours of the connecting lines\n",
" cv2.imshow('Mediapipe Feed', image) #pop-up to visualize the feed\n",
"\n",
" if cv2.waitKey(10) & 0xFF == ord('q'): #to close the feed\n",
" break\n",
"\n",
" cap.release() \n",
" cv2.destroyAllWindows()"
]
}
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment