{"id":326381,"date":"2021-07-13T15:00:25","date_gmt":"2021-07-13T15:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326381"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326381","title":{"rendered":"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u044b \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0441 Mediapipe"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440! \u0414\u0430\u0432\u043d\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u043b! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0437\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0441 Mediapipe. <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u043e\u0437\u044b, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a&nbsp;<a href=\"https:\/\/github.com\/CMU-Perceptual-Computing-Lab\/openpose\" rel=\"noopener noreferrer nofollow\"><u>OpenPose<\/u><\/a>&nbsp;,&nbsp;<a href=\"https:\/\/google.github.io\/mediapipe\/solutions\/pose.html\" rel=\"noopener noreferrer nofollow\"><u>MediaPipe<\/u><\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.tensorflow.org\/lite\/examples\/pose_estimation\/overview\" rel=\"noopener noreferrer nofollow\"><u>PoseNet<\/u><\/a>&nbsp;\u0438 \u0442. \u0414. \u0425\u043e\u0442\u044f OpenPose \u0438 PoseNet \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0437\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, Mediapipe \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0437\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430.  <\/p>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u043e\u0449\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043c\u0435\u0442\u043e\u0434 Mediapipe \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432, \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432 \u0438 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435(javascript).<\/p>\n<h2>\u041a\u043e\u0435-\u0447\u0442\u043e \u043e\u0431 \u043e\u0446\u0435\u043d\u043a\u0435 \u043f\u043e\u0437\u044b Mediapipe<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ada\/094\/1fa\/ada0941fafa067979176fef3aa277c73.png\" width=\"700\" height=\"397\"><figcaption><\/figcaption><\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f MediaPipe Pose Landmark \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c 33 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0430, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435.&nbsp;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432 \u043f\u043e\u0437\u044b, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0430 x \u0438 y, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445&nbsp;<code>[0.0, 1.0]<\/code>\u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435 \u0438 \u0432\u044b\u0441\u043e\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<h2>\u041e\u0431\u0440\u0430\u0437\u0435\u0446 \u043a\u043e\u0434\u0430<\/h2>\n<pre><code class=\"python\">import cv2 import mediapipe as mp mp_drawing = mp.solutions.drawing_utils mp_holistic = mp.solutions.holistic  # For static images: IMAGE_FILES = [] with mp_holistic.Holistic(     static_image_mode=True,     model_complexity=2) as holistic:   for idx, file in enumerate(IMAGE_FILES):     image = cv2.imread(file)     image_height, image_width, _ = image.shape     # Convert the BGR image to RGB before processing.     results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))      if results.pose_landmarks:       print(           f'Nose coordinates: ('           f'{results.pose_landmarks.landmark[mp_holistic.PoseLandmark.NOSE].x * image_width}, '           f'{results.pose_landmarks.landmark[mp_holistic.PoseLandmark.NOSE].y * image_height})'       )     # Draw pose, left and right hands, and face landmarks on the image.     annotated_image = image.copy()     mp_drawing.draw_landmarks(         annotated_image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)     mp_drawing.draw_landmarks(         annotated_image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         annotated_image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         annotated_image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)     cv2.imwrite('\/tmp\/annotated_image' + str(idx) + '.png', annotated_image)     # Plot pose world landmarks.     mp_drawing.plot_landmarks(         results.pose_world_landmarks, mp_holistic.POSE_CONNECTIONS)  # For webcam input: cap = cv2.VideoCapture(0) with mp_holistic.Holistic(     min_detection_confidence=0.5,     min_tracking_confidence=0.5) as holistic:   while cap.isOpened():     success, image = cap.read()     if not success:       print(\"Ignoring empty camera frame.\")       # If loading a video, use 'break' instead of 'continue'.       continue      # Flip the image horizontally for a later selfie-view display, and convert     # the BGR image to RGB.     image = cv2.cvtColor(cv2.flip(image, 1), cv2.COLOR_BGR2RGB)     # To improve performance, optionally mark the image as not writeable to     # pass by reference.     image.flags.writeable = False     results = holistic.process(image)      # Draw landmark annotation on the image.     image.flags.writeable = True     image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)     mp_drawing.draw_landmarks(         image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)     mp_drawing.draw_landmarks(         image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)     cv2.imshow('MediaPipe Holistic', image)     if cv2.waitKey(5) &amp; 0xFF == 27:       break cap.release()<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043c\u0435\u0440\u0435\u0432\u0430\u0435\u043c\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0437\u044b \u0434\u0432\u0443\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043d\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438\u043b\u0438 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e, \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0431\u044b\u043b\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u0440\u0430\u043c\u043a\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043c\u0430\u0441\u043a\u0443 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443(\u043a\u0430\u043a \u043d\u0430 \u043d\u0438\u0436\u043d\u0435\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0435), \u043a\u0440\u043e\u043c\u0435 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u0440\u0430\u043c\u043a\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043b\u044e\u0434\u0435\u0439, \u0438 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 mediapipe.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7dd\/a81\/4b6\/7dda814b60a5ffab2abb84b72979ef6d.jpg\" width=\"638\" height=\"450\"><figcaption><\/figcaption><\/figure>\n<h2>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043b\u044e\u0434\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 YOLO v4<\/h2>\n<p>&nbsp;<a href=\"https:\/\/pjreddie.com\/darknet\/yolo\/\" rel=\"noopener noreferrer nofollow\"><u>YOLO<\/u><\/a>&nbsp; &#8212; \u044d\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.  <strong><s>\u0427\u0442\u043e \u0442\u043e \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c.<\/s><\/strong> \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 YOLO \u0434\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0432\u043e\u044e \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e YOLOv4 \u0432\u0437\u044f\u043b \u043e\u0442 <a href=\"https:\/\/github.com\/LeonLok\/Deep-SORT-YOLOv4\" rel=\"noopener noreferrer nofollow\">\u0441\u044e\u0434\u0430<\/a>. \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\"># MediaPipe init. import mediapipe as mp mp_drawing = mp.solutions.drawing_utils mp_holistic = mp.solutions.holistic holistic = mp_holistic.Holistic(static_image_mode=True)    def mdp_holistic(original_image, image):     ''' MediaPipe Pose recognition. '''       results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))     # cv2.imwrite('holistic_input.jpg', image)          if results.pose_landmarks:         # Draw pose, left and right hands, and face landmarks on the image.         mp_drawing.draw_landmarks(             original_image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)         mp_drawing.draw_landmarks(             original_image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         mp_drawing.draw_landmarks(             original_image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         mp_drawing.draw_landmarks(             original_image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)      return original_image<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/451\/339\/3c7\/4513393c71606a59dffa99275ec8bace.png\" width=\"645\" height=\"483\"><figcaption><\/figcaption><\/figure>\n<h2>\u0414\u0440\u0443\u0433\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0412\u044b\u0448\u0435, \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043b\u044e\u0434\u0435\u0439, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c YOLO v4, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043b\u0435\u0433\u043a\u0430\u044f. \u041c\u044b \u0435\u0449\u0435 \u043f\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441 mediapipe, \u0438 \u043d\u0430\u0448\u043b\u0438 \u0432\u044b\u0445\u043e\u0434 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437 \u043b\u044e\u0434\u0435\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e mediapipe. \u041e\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043d\u0430 \u043b\u0435\u0433\u043a\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u044f.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0430\u044f, \u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043f\u0438\u044e \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0437\u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0438 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0442\u043e\u0447\u043a\u0438 \u0438 \u0437\u0430\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0449\u0435\u043c \u043f\u043e\u0437\u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u0442.\u0434. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0440\u0438\u0441\u0443\u0435\u043c \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435.<\/p>\n<pre><code class=\"python\">import cv2 import time import mediapipe as mp import datetime   mp_holistic = mp.solutions.holistic holistic = mp_holistic.Holistic(static_image_mode=True) mp_draw = mp.solutions.drawing_utils  def holistic_recursive(origin_image, image, padding = 20, recursion_depth = 20):     results = holistic.process(image)     X , Y = [], []     h, w = image.shape[:2]     person_detected = False     if results.pose_landmarks:         mp_draw.draw_landmarks(origin_image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)         for i in range(len(results.pose_landmarks.landmark)):             X.append(results.pose_landmarks.landmark[i].x)             Y.append(results.pose_landmarks.landmark[i].y)         person_detected = True     if results.face_landmarks:             mp_draw.draw_landmarks(origin_image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)         for i in range(len(results.face_landmarks.landmark)):             X.append(results.face_landmarks.landmark[i].x)             Y.append(results.face_landmarks.landmark[i].y)         person_detected = True     if results.left_hand_landmarks:         mp_draw.draw_landmarks(origin_image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         for i in range(len(results.left_hand_landmarks.landmark)):             X.append(results.left_hand_landmarks.landmark[i].x)             Y.append(results.left_hand_landmarks.landmark[i].y)         person_detected = True     if results.right_hand_landmarks:         mp_draw.draw_landmarks(origin_image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         for i in range(len(results.right_hand_landmarks.landmark)):             X.append(results.right_hand_landmarks.landmark[i].x)             Y.append(results.right_hand_landmarks.landmark[i].y)         person_detected = True     if person_detected and recursion_depth &gt; 0:         # create bbox         x1 = int(min(X) * w)         y1 = int(min(Y) * h)         x2 = int(max(X) * w)         y2 = int(max(Y) * h)         # Add padding         x1 = x1 - padding if x1 - padding &gt; 0 else 0         y1 = y1 - padding if y1 - padding &gt; 0 else 0         x2 = x2 + padding if x2 + padding &lt; w else w         y2 = y2 + padding if y2 + padding &lt; h else h         # zero bbox         image[y1:y2, x1:x2] = 0         # cv2.imwrite('crop.jpg', image)         holistic_recursive(origin_image, image, recursion_depth - 1)  cap = cv2.VideoCapture(0) # cap = cv2.VideoCapture('smeny-etsn-brigadoy-tkrs_Pxv28bmL_N5en.mp4')  # Write video # w = int(cap.get(3)) # h = int(cap.get(4)) # fourcc = cv2.VideoWriter_fourcc(*'MP4V') # out = cv2.VideoWriter('output_recursive.mp4', fourcc, 10.0, (w, h))  start_time = time.time() frame_count = 0 fps = 0 while True:     _, img = cap.read()     img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)     # Recursive run detection     image = img_rgb.copy()     holistic_recursive(img, image)     frame_count += 1     if frame_count &gt; 20:         fps = frame_count \/ (time.time() - start_time)           start_time = time.time()         frame_count = 0     cv2.putText(img, f'FPS: {int(fps)}', (10, 30), cv2.FONT_HERSHEY_PLAIN, 2, (255, 0, 0), 2)     cv2.imshow(\"cam\", img)     # out.write(img)     k = cv2.waitKey(1)     if k == 27:  # close on ESC key         break  # cap.release() # out.release() cv2.destroyAllWindows()<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ce6\/083\/b09\/ce6083b09221d9f2656644b081f75576.png\" width=\"640\" height=\"480\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc5\/9d8\/6a8\/cc59d86a8fa588e3714dd99382f8efb7.png\" width=\"640\" height=\"480\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/303\/18a\/d6c\/30318ad6cb135435f798fb7c358e3af5.jpg\" width=\"640\" height=\"480\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Mediapipe \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043f\u043e\u0437\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043b\u044e\u0434\u044c\u043c\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u044d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043b\u0438 \u0443\u0447\u0435\u0431\u044b.   <\/p>\n<p>\u041e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u0437\u044b \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438\u0437 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u0436\u0435\u0441\u0442\u043e\u0432 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430\u043c\u0438 \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043b\u0430.&nbsp;\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a \u0439\u043e\u0433\u0430, \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f \u0438 \u0442\u0430\u043d\u0446\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432 \u043d\u0430 \u0442\u0435\u043b\u0435.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/567534\/\"> https:\/\/habr.com\/ru\/post\/567534\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0425\u0430\u0431\u0440! \u0414\u0430\u0432\u043d\u043e \u043d\u0435 \u043f\u0438\u0441\u0430\u043b! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0437\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u0441 Mediapipe. <\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u043e\u0437\u044b, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a&nbsp;<a href=\"https:\/\/github.com\/CMU-Perceptual-Computing-Lab\/openpose\" rel=\"noopener noreferrer nofollow\"><u>OpenPose<\/u><\/a>&nbsp;,&nbsp;<a href=\"https:\/\/google.github.io\/mediapipe\/solutions\/pose.html\" rel=\"noopener noreferrer nofollow\"><u>MediaPipe<\/u><\/a>&nbsp;,&nbsp;<a href=\"https:\/\/www.tensorflow.org\/lite\/examples\/pose_estimation\/overview\" rel=\"noopener noreferrer nofollow\"><u>PoseNet<\/u><\/a>&nbsp;\u0438 \u0442. \u0414. \u0425\u043e\u0442\u044f OpenPose \u0438 PoseNet \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0437\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, Mediapipe \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0437\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430.  <\/p>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043e\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u043e\u0449\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0430 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043c\u0435\u0442\u043e\u0434 Mediapipe \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432, \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043e\u0432 \u0438 \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435(javascript).<\/p>\n<h2>\u041a\u043e\u0435-\u0447\u0442\u043e \u043e\u0431 \u043e\u0446\u0435\u043d\u043a\u0435 \u043f\u043e\u0437\u044b Mediapipe<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f MediaPipe Pose Landmark \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c 33 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0430, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435.&nbsp;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432 \u043f\u043e\u0437\u044b, \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u0430 x \u0438 y, \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445&nbsp;<code>[0.0, 1.0]<\/code>\u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435 \u0438 \u0432\u044b\u0441\u043e\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<h2>\u041e\u0431\u0440\u0430\u0437\u0435\u0446 \u043a\u043e\u0434\u0430<\/h2>\n<pre><code class=\"python\">import cv2 import mediapipe as mp mp_drawing = mp.solutions.drawing_utils mp_holistic = mp.solutions.holistic  # For static images: IMAGE_FILES = [] with mp_holistic.Holistic(     static_image_mode=True,     model_complexity=2) as holistic:   for idx, file in enumerate(IMAGE_FILES):     image = cv2.imread(file)     image_height, image_width, _ = image.shape     # Convert the BGR image to RGB before processing.     results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))      if results.pose_landmarks:       print(           f'Nose coordinates: ('           f'{results.pose_landmarks.landmark[mp_holistic.PoseLandmark.NOSE].x * image_width}, '           f'{results.pose_landmarks.landmark[mp_holistic.PoseLandmark.NOSE].y * image_height})'       )     # Draw pose, left and right hands, and face landmarks on the image.     annotated_image = image.copy()     mp_drawing.draw_landmarks(         annotated_image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)     mp_drawing.draw_landmarks(         annotated_image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         annotated_image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         annotated_image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)     cv2.imwrite('\/tmp\/annotated_image' + str(idx) + '.png', annotated_image)     # Plot pose world landmarks.     mp_drawing.plot_landmarks(         results.pose_world_landmarks, mp_holistic.POSE_CONNECTIONS)  # For webcam input: cap = cv2.VideoCapture(0) with mp_holistic.Holistic(     min_detection_confidence=0.5,     min_tracking_confidence=0.5) as holistic:   while cap.isOpened():     success, image = cap.read()     if not success:       print(\"Ignoring empty camera frame.\")       # If loading a video, use 'break' instead of 'continue'.       continue      # Flip the image horizontally for a later selfie-view display, and convert     # the BGR image to RGB.     image = cv2.cvtColor(cv2.flip(image, 1), cv2.COLOR_BGR2RGB)     # To improve performance, optionally mark the image as not writeable to     # pass by reference.     image.flags.writeable = False     results = holistic.process(image)      # Draw landmark annotation on the image.     image.flags.writeable = True     image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)     mp_drawing.draw_landmarks(         image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)     mp_drawing.draw_landmarks(         image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)     mp_drawing.draw_landmarks(         image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)     cv2.imshow('MediaPipe Holistic', image)     if cv2.waitKey(5) &amp; 0xFF == 27:       break cap.release()<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0430\u043c\u0435\u0440\u0435\u0432\u0430\u0435\u043c\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0437\u044b \u0434\u0432\u0443\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043d\u0430 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0438\u043b\u0438 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e, \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0431\u044b\u043b\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u0440\u0430\u043c\u043a\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u043c\u0430\u0441\u043a\u0443 \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443(\u043a\u0430\u043a \u043d\u0430 \u043d\u0438\u0436\u043d\u0435\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0435), \u043a\u0440\u043e\u043c\u0435 \u0433\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u0440\u0430\u043c\u043a\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043b\u044e\u0434\u0435\u0439, \u0438 \u043f\u043e \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0434\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 mediapipe.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043b\u044e\u0434\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 YOLO v4<\/h2>\n<p>&nbsp;<a href=\"https:\/\/pjreddie.com\/darknet\/yolo\/\" rel=\"noopener noreferrer nofollow\"><u>YOLO<\/u><\/a>&nbsp; &#8212; \u044d\u0442\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438.  <strong><s>\u0427\u0442\u043e \u0442\u043e \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c.<\/s><\/strong> \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 YOLO \u0434\u043e\u043a\u0430\u0437\u0430\u043b \u0441\u0432\u043e\u044e \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e YOLOv4 \u0432\u0437\u044f\u043b \u043e\u0442 <a href=\"https:\/\/github.com\/LeonLok\/Deep-SORT-YOLOv4\" rel=\"noopener noreferrer nofollow\">\u0441\u044e\u0434\u0430<\/a>. \u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u043b \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0441\u043b\u0435 \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<pre><code class=\"python\"># MediaPipe init. import mediapipe as mp mp_drawing = mp.solutions.drawing_utils mp_holistic = mp.solutions.holistic holistic = mp_holistic.Holistic(static_image_mode=True)    def mdp_holistic(original_image, image):     ''' MediaPipe Pose recognition. '''       results = holistic.process(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))     # cv2.imwrite('holistic_input.jpg', image)          if results.pose_landmarks:         # Draw pose, left and right hands, and face landmarks on the image.         mp_drawing.draw_landmarks(             original_image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)         mp_drawing.draw_landmarks(             original_image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         mp_drawing.draw_landmarks(             original_image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         mp_drawing.draw_landmarks(             original_image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)      return original_image<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0414\u0440\u0443\u0433\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0412\u044b\u0448\u0435, \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043b\u044e\u0434\u0435\u0439, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0443\u044e \u0441\u0435\u0442\u044c YOLO v4, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0441\u0430\u043c\u0430\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043b\u0435\u0433\u043a\u0430\u044f. \u041c\u044b \u0435\u0449\u0435 \u043f\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441 mediapipe, \u0438 \u043d\u0430\u0448\u043b\u0438 \u0432\u044b\u0445\u043e\u0434 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437 \u043b\u044e\u0434\u0435\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e mediapipe. \u041e\u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u043d\u0430 \u043b\u0435\u0433\u043a\u0430\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u0430\u044f.<\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0430\u044f, \u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043f\u0438\u044e \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0437\u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0438 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0442\u043e\u0447\u043a\u0438 \u0438 \u0437\u0430\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0449\u0435\u043c \u043f\u043e\u0437\u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438 \u0442.\u0434. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0440\u0438\u0441\u0443\u0435\u043c \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435.<\/p>\n<pre><code class=\"python\">import cv2 import time import mediapipe as mp import datetime   mp_holistic = mp.solutions.holistic holistic = mp_holistic.Holistic(static_image_mode=True) mp_draw = mp.solutions.drawing_utils  def holistic_recursive(origin_image, image, padding = 20, recursion_depth = 20):     results = holistic.process(image)     X , Y = [], []     h, w = image.shape[:2]     person_detected = False     if results.pose_landmarks:         mp_draw.draw_landmarks(origin_image, results.pose_landmarks, mp_holistic.POSE_CONNECTIONS)         for i in range(len(results.pose_landmarks.landmark)):             X.append(results.pose_landmarks.landmark[i].x)             Y.append(results.pose_landmarks.landmark[i].y)         person_detected = True     if results.face_landmarks:             mp_draw.draw_landmarks(origin_image, results.face_landmarks, mp_holistic.FACE_CONNECTIONS)         for i in range(len(results.face_landmarks.landmark)):             X.append(results.face_landmarks.landmark[i].x)             Y.append(results.face_landmarks.landmark[i].y)         person_detected = True     if results.left_hand_landmarks:         mp_draw.draw_landmarks(origin_image, results.left_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         for i in range(len(results.left_hand_landmarks.landmark)):             X.append(results.left_hand_landmarks.landmark[i].x)             Y.append(results.left_hand_landmarks.landmark[i].y)         person_detected = True     if results.right_hand_landmarks:         mp_draw.draw_landmarks(origin_image, results.right_hand_landmarks, mp_holistic.HAND_CONNECTIONS)         for i in range(len(results.right_hand_landmarks.landmark)):             X.append(results.right_hand_landmarks.landmark[i].x)             Y.append(results.right_hand_landmarks.landmark[i].y)         person_detected = True     if person_detected and recursion_depth &gt; 0:         # create bbox         x1 = int(min(X) * w)         y1 = int(min(Y) * h)         x2 = int(max(X) * w)         y2 = int(max(Y) * h)         # Add padding         x1 = x1 - padding if x1 - padding &gt; 0 else 0         y1 = y1 - padding if y1 - padding &gt; 0 else 0         x2 = x2 + padding if x2 + padding &lt; w else w         y2 = y2 + padding if y2 + padding &lt; h else h         # zero bbox         image[y1:y2, x1:x2] = 0         # cv2.imwrite('crop.jpg', image)         holistic_recursive(origin_image, image, recursion_depth - 1)  cap = cv2.VideoCapture(0) # cap = cv2.VideoCapture('smeny-etsn-brigadoy-tkrs_Pxv28bmL_N5en.mp4')  # Write video # w = int(cap.get(3)) # h = int(cap.get(4)) # fourcc = cv2.VideoWriter_fourcc(*'MP4V') # out = cv2.VideoWriter('output_recursive.mp4', fourcc, 10.0, (w, h))  start_time = time.time() frame_count = 0 fps = 0 while True:     _, img = cap.read()     img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)     # Recursive run detection     image = img_rgb.copy()     holistic_recursive(img, image)     frame_count += 1     if frame_count &gt; 20:         fps = frame_count \/ (time.time() - start_time)           start_time = time.time()         frame_count = 0     cv2.putText(img, f'FPS: {int(fps)}', (10, 30), cv2.FONT_HERSHEY_PLAIN, 2, (255, 0, 0), 2)     cv2.imshow(\"cam\", img)     # out.write(img)     k = cv2.waitKey(1)     if k == 27:  # close on ESC key         break  # cap.release() # out.release() cv2.destroyAllWindows()<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Mediapipe \u043c\u044b \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u043f\u043e\u0437\u044b \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043b\u044e\u0434\u044c\u043c\u0438. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u044d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043b\u0438 \u0443\u0447\u0435\u0431\u044b.   <\/p>\n<p>\u041e\u0446\u0435\u043d\u043a\u0430 \u043f\u043e\u0437\u044b \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0438\u0437 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u0436\u0435\u0441\u0442\u043e\u0432 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430\u043c\u0438 \u0432\u0441\u0435\u0433\u043e \u0442\u0435\u043b\u0430.&nbsp;\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u043a \u0439\u043e\u0433\u0430, \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f \u0438 \u0442\u0430\u043d\u0446\u044b, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432 \u043d\u0430 \u0442\u0435\u043b\u0435.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/567534\/\"> https:\/\/habr.com\/ru\/post\/567534\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-326381","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=326381"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326381\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}