{"id":341035,"date":"2022-11-09T15:01:31","date_gmt":"2022-11-09T15:01:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341035"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341035","title":{"rendered":"<span>JavaScript: \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0436\u0435\u0441\u0442\u043e\u0432<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tb\/2u\/fx\/tb2ufxookpot0mirap8x-dzoedg.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tb\/2u\/fx\/tb2ufxookpot0mirap8x-dzoedg.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0436\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0432 \u0444\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0438\u043b\u044c\u043c\u0430\u0445. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0441\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u2014 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u0430 \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 (\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0442 <code>Google<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 5 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0438\u0445 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 (canvas);<\/li>\n<li>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043a\u0438\u0441\u0442\u0438 \u0440\u0443\u043a\u0438;<\/li>\n<li>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c&#187; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430;<\/li>\n<li>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430 &#171;\u0449\u0438\u043f\u043e\u043a&#187; (pinch);<\/li>\n<li>\u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0449\u0438\u043f\u043a\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c <code>JavaScript<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u0430 <a href=\"https:\/\/www.smashingmagazine.com\/2022\/10\/motion-controls-browser\/\">\u044d\u0442\u0430 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0440\u0443\u043a\u0438 \u0438 \u0436\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/google.github.io\/mediapipe\/\">MediaPipe<\/a>. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u2014 <a href=\"https:\/\/yarnpkg.com\/\">Yarn<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/harryheman\/Blog-Posts\/tree\/master\/motion-controls\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2>\u276f \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c <code>JS<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/vitejs.dev\/\">Vite<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># motion-controls - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 # vanilla - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d yarn create vite motion-controls --template vanilla<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd motion-controls yarn yarn dev<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <code>body<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 <code>index.html<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;video>&lt;\/video> &lt;canvas>&lt;\/canvas>  &lt;script type=\"module\" src=\"\/js\/get-video-data.js\">&lt;\/script><\/code><\/pre>\n<p>  <\/p>\n<h2>\u276f \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u0445 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e <code>js<\/code> \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0444\u0430\u0439\u043b <code>get-video-data.js<\/code> \u0432 \u043d\u0435\u0439.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <code>video<\/code> \u0438 <code>canvas<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f 2D-\u0433\u0440\u0430\u0444\u0438\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const video$ = document.querySelector(\"video\"); const canvas$ = document.querySelector(\"canvas\"); const ctx = canvas$.getContext(\"2d\");<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0445\u043e\u043b\u0441\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f (<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaDevices\/getUserMedia#parameters\">constraints<\/a>) \u043a \u043f\u043e\u0442\u043e\u043a\u0443 \u0432\u0438\u0434\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const width = 320; const height = 480;  canvas$.width = width; canvas$.height = height;  const constraints = {   audio: false,   video: { width, height }, };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0432\u0432\u043e\u0434\u0430 \u0432\u0438\u0434\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaDevices\/getUserMedia\">getUserMedia<\/a>; \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043f\u043e\u0442\u043e\u043a \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>video<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLMediaElement\/srcObject\">srcObject<\/a>; \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432\u0438\u0434\u0435\u043e \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/window\/requestAnimationFrame\">requestAnimationFrame<\/a>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>drawVideoFrame<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">navigator.mediaDevices   \/\/ `getUserMedia` \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u043e\u043c\u0438\u0441   .getUserMedia(constraints)   .then((stream) => {     video$.srcObject = stream;      video$.onloadedmetadata = () => {       video$.play();        requestAnimationFrame(drawVideoFrame);     };   })   .catch(console.error);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0434\u0440\u0430 \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CanvasRenderingContext2D\/drawImage\">drawImage<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function drawVideoFrame() {   ctx.drawImage(video$, 0, 0, width, height);    requestAnimationFrame(drawVideoFrame); }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0434\u0432\u043e\u0439\u043d\u043e\u0439 \u0432\u044b\u0437\u043e\u0432 <code>requestAnimationFrame<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043a\u0430\u0434\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 60 \u043a\u0430\u0434\u0440\u043e\u0432 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443 (60 frames per second, FPS). \u0427\u0430\u0441\u0442\u043e\u0442\u0443 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a\u0430\u0434\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 <code>timestamp<\/code>, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u0443 <code>requestAnimationFrame<\/code> (<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/window\/requestAnimationFrame#examples\">\u043f\u0440\u0438\u043c\u0435\u0440<\/a>):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function drawVideoFrame(timestamp) {   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/p-\/w4\/j0\/p-w4j0ei0eg2cq7y1p2xdmmd0ni.png\" data-src=\"https:\/\/habrastorage.org\/webt\/p-\/w4\/j0\/p-w4j0ei0eg2cq7y1p2xdmmd0ni.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h2>\u276f \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043a\u0438\u0441\u0442\u0438 \u0440\u0443\u043a\u0438<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0440\u0443\u043a\u0438 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">yarn add @mediapipe\/camera_utils @mediapipe\/drawing_utils @mediapipe\/hands<\/code><\/pre>\n<p>  <\/p>\n<p><a href=\"https:\/\/google.github.io\/mediapipe\/solutions\/hands.html\">MediaPipe Hands<\/a> \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0438\u0441\u0442\u0438 \u0440\u0443\u043a, \u0437\u0430\u0442\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 21 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 (3D landmarks), \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0443\u0441\u0442\u0430\u0432\u044b, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u0438\u0441\u0442\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ip\/d0\/zp\/ipd0zpor4yaekpai7gylg9s-bx4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ip\/d0\/zp\/ipd0zpor4yaekpai7gylg9s-bx4.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>js<\/code> \u0444\u0430\u0439\u043b <code>track-hand-motions.js<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { Camera } from \"@mediapipe\/camera_utils\"; import { drawConnectors, drawLandmarks } from \"@mediapipe\/drawing_utils\"; import { Hands, HAND_CONNECTIONS } from \"@mediapipe\/hands\";<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Camera<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export declare class Camera implements CameraInterface {   constructor(video: HTMLVideoElement, options: CameraOptions);   start(): Promise&lt;void>;   \/\/ \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434   stop(): Promise&lt;void>; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>video<\/code> \u0438 \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export declare interface CameraOptions {   \/\/ \u043a\u043e\u043b\u043b\u0431\u044d\u043a, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u0437\u0430\u0445\u0432\u0430\u0442\u0435 \u043a\u0430\u0434\u0440\u0430   onFrame: () => Promise&lt;void>| null;   \/\/ \u043a\u0430\u043c\u0435\u0440\u0430   facingMode?: 'user'|'environment';   \/\/ \u0448\u0438\u0440\u0438\u043d\u0430 \u043a\u0430\u0434\u0440\u0430   width?: number;   \/\/ \u0432\u044b\u0441\u043e\u0442\u0430 \u043a\u0430\u0434\u0440\u0430   height?: number; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>start<\/code> \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u043a\u0430\u0434\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Hands<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0438\u0441\u0442\u0435\u0439 \u0440\u0443\u043a \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export declare class Hands implements HandsInterface {   constructor(config?: HandsConfig);   onResults(listener: ResultsListener): void;   send(inputs: InputMap): Promise&lt;void>;   setOptions(options: Options): void;   \/\/ \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export interface HandsConfig {   locateFile?: (path: string, prefix?: string) => string; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">hand_landmark_lite.tflite hands_solution_packed_assets_loader.js hands_solution_simd_wasm_bin.js hands.binarypb hands_solution_packed_assets.data hands_solution_simd_wasm_bin.wasm<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>setOptions<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export interface Options {   selfieMode?: boolean;   maxNumHands?: number;   modelComplexity?: 0|1;   minDetectionConfidence?: number;   minTrackingConfidence?: number; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431 \u044d\u0442\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/google.github.io\/mediapipe\/solutions\/hands.html#configuration-options\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <code>maxNumHands: 1<\/code> \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0439 \u043a\u0438\u0441\u0442\u0438 \u0438 <code>modelComplexity: 0<\/code> \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>send<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>onFrame<\/code> \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>Camera<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>onResults<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0438\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>drawLandmarks<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043a\u0438\u0441\u0442\u0438 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export declare function drawLandmarks(     ctx: CanvasRenderingContext2D, landmarks?: NormalizedLandmarkList,     style?: DrawingOptions): void;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0438\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export declare interface DrawingOptions {   color?: string|CanvasGradient|CanvasPattern|       Fn&lt;Data, string|CanvasGradient|CanvasPattern>;   fillColor?: string|CanvasGradient|CanvasPattern|       Fn&lt;Data, string|CanvasGradient|CanvasPattern>;   lineWidth?: number|Fn&lt;Data, number>;   radius?: number|Fn&lt;Data, number>;   visibilityMin?: number; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>drawConnectors<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u0438\u043d\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export declare function drawConnectors(     ctx: CanvasRenderingContext2D, landmarks?: NormalizedLandmarkList,     connections?: LandmarkConnectionArray, style?: DrawingOptions): void;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043f\u0430\u0440\u044b \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a (<code>HAND_CONNECTIONS<\/code>) \u0438 \u0441\u0442\u0438\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e <code>track-hand-motions.js<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const video$ = document.querySelector(\"video\"); const canvas$ = document.querySelector(\"canvas\"); const ctx = canvas$.getContext(\"2d\");  const width = 320; const height = 480; canvas$.width = width; canvas$.height = height;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0438\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function onResults(results) {   \/\/ \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e `multiHandLandmarks`,   \/\/ \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043a\u0438\u0441\u0442\u0435\u0439   if (!results.multiHandLandmarks.length) return;    \/\/ \u043f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 2 \u043a\u0438\u0441\u0442\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, `multiHandLandmarks` \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c 2 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a   console.log(\"@landmarks\", results.multiHandLandmarks[0]);    \/\/ \u0440\u0438\u0441\u0443\u0435\u043c \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0434\u0440   ctx.save();   ctx.clearRect(0, 0, width, height);   ctx.drawImage(results.image, 0, 0, width, height);    \/\/ \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a   \/\/ \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043e\u0434\u0438\u043d \u043c\u0430\u0441\u0441\u0438\u0432,   \/\/ \u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u043c   for (const landmarks of results.multiHandLandmarks) {     \/\/ \u0440\u0438\u0441\u0443\u0435\u043c \u0442\u043e\u0447\u043a\u0438     drawLandmarks(ctx, landmarks, { color: \"#FF0000\", lineWidth: 2 });     \/\/ \u0440\u0438\u0441\u0443\u0435\u043c \u043b\u0438\u043d\u0438\u0438     drawConnectors(ctx, landmarks, HAND_CONNECTIONS, {       color: \"#00FF00\",       lineWidth: 4,     });   }    ctx.restore(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0438\u0441\u0442\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const hands = new Hands({   locateFile: (file) => `..\/node_modules\/@mediapipe\/hands\/${file}`, }); hands.setOptions({   maxNumHands: 1,   modelComplexity: 0, }); hands.onResults(onResults);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u043e\u0439, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u043a\u0430\u0434\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const camera = new Camera(video$, {   onFrame: async () => {     await hands.send({ image: video$ });   },   facingMode: undefined,   width,   height, }); camera.start();<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <code>facingMode<\/code> \u0438\u043c\u0435\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>user<\/code> \u2014 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0432\u0438\u0434\u0435\u043e\u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0440\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u0430\u044f (\u043f\u0435\u0440\u0435\u0434\u043d\u044f\u044f) \u043a\u0430\u043c\u0435\u0440\u0430 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0430. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>USB-\u043a\u0430\u043c\u0435\u0440\u0430<\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c <code>undefined<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041c\u0430\u0441\u0441\u0438\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439 \u043a\u0438\u0441\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/b0\/kc\/qr\/b0kcqrzh2m_avg3cjvyeqv0brxc.png\" data-src=\"https:\/\/habrastorage.org\/webt\/b0\/kc\/qr\/b0kcqrzh2m_avg3cjvyeqv0brxc.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u0443\u0441\u0442\u0430\u0432\u0430\u043c \u043a\u0438\u0441\u0442\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c\u0443 \u0432\u044b\u0448\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0432\u0435\u0440\u0445\u0443 \u0441\u0443\u0441\u0442\u0430\u0432\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>7<\/code>. \u041a\u0430\u0436\u0434\u0430\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b <code>x<\/code>, <code>y<\/code> \u0438 <code>z<\/code> \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 0 \u0434\u043e 1.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/kl\/k8\/nr\/klk8nrdtlqrjol62i2-dj2ivsra.png\" data-src=\"https:\/\/habrastorage.org\/webt\/kl\/k8\/nr\/klk8nrdtlqrjol62i2-dj2ivsra.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/jj\/0q\/uc\/jj0quc_slasv_4jhoajse5wckea.png\" data-src=\"https:\/\/habrastorage.org\/webt\/jj\/0q\/uc\/jj0quc_slasv_4jhoajse5wckea.png\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/5y\/mw\/o-\/5ymwo-ysiio_iunn4t04ard9ba4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/5y\/mw\/o-\/5ymwo-ysiio_iunn4t04ard9ba4.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h2>\u276f \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u00ab\u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c\u00bb \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430<\/h2>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 <code>index.html<\/code> \u0442\u0430\u043a\u043e\u0439 <code>div<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;div class=\"cursor\">&lt;\/div><\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u0438\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>style.css<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">body {   margin: 0;   overflow: hidden; }  canvas {   display: none; }  video {   max-width: 100vw;   max-height: 100vh; }  .cursor {   height: 0;   left: 0;   position: absolute;   top: 0;   transition: transform 0.1s;   width: 0;   z-index: 10; }  .cursor::after {   background-color: #0275d8;   border-radius: 50%;   content: \"\";   display: block;   height: 40px;   left: 0;   position: absolute;   top: 0;   transform: translate(-50%, -50%);   width: 40px; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>js<\/code> \u0444\u0430\u0439\u043b <code>move-cursor-by-finger.js<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u0442\u0438\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { Camera } from \"@mediapipe\/camera_utils\"; import { Hands } from \"@mediapipe\/hands\"; import \"..\/style.css\";<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/code> \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0448\u0438\u0440\u0438\u043d\u0443 \u0438 \u0432\u044b\u0441\u043e\u0442\u0443 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0434\u0440\u0430, \u0440\u0430\u0432\u043d\u0443\u044e \u0448\u0438\u0440\u0438\u043d\u0435 \u0438 \u0432\u044b\u0441\u043e\u0442\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const video$ = document.querySelector(\"video\"); const cursor$ = document.querySelector(\".cursor\");  const width = window.innerWidth; const height = window.innerHeight;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const handParts = {   wrist: 0,   thumb: { base: 1, middle: 2, topKnuckle: 3, tip: 4 },   indexFinger: { base: 5, middle: 6, topKnuckle: 7, tip: 8 },   middleFinger: { base: 9, middle: 10, topKnuckle: 11, tip: 12 },   ringFinger: { base: 13, middle: 14, topKnuckle: 15, tip: 16 },   pinky: { base: 17, middle: 18, topKnuckle: 19, tip: 20 }, };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u043e\u0439 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0438\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const hands = new Hands({   locateFile: (file) => `..\/node_modules\/@mediapipe\/hands\/${file}`, }); hands.setOptions({   maxNumHands: 1,   modelComplexity: 0, }); hands.onResults(onResults);  const camera = new Camera(video$, {   onFrame: async () => {     await hands.send({ image: video$ });   },   facingMode: undefined,   width,   height, }); camera.start();<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u0430&#187; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0432\u0435\u0440\u0445\u0443 \u0441\u0443\u0441\u0442\u0430\u0432\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430 \u2014 <code>handParts.indexFinger.topKnuckle<\/code> + \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u2014 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, \u043a\u0430\u043a <code>vw<\/code> \u0438 <code>vh<\/code> (\u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430). \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const getCursorCoords = (landmarks) =>   landmarks[handParts.indexFinger.topKnuckle];  const convertCoordsToDomPosition = ({ x, y }) => ({   x: `${x * 100}vw`,   y: `${y * 100}vh`, });<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u0430&#187;:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function updateCursorPosition(landmarks) {   const cursorCoords = getCursorCoords(landmarks);   if (!cursorCoords) return;    const { x, y } = convertCoordsToDomPosition(cursorCoords);    cursor$.style.transform = `translate(${x}, ${y})`; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a\u0438\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function onResults(handData) {   if (!handData.multiHandLandmarks.length) return;    updateCursorPosition(handData.multiHandLandmarks[0]); }<\/code><\/pre>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b &#171;\u043e\u0442\u0437\u0435\u0440\u043a\u0430\u043b\u0438\u0442\u044c&#187; \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 <code>x<\/code> \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 (\u0435\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c) \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u2014 <code>x = -x + 1<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/1l\/ma\/vh\/1lmavhydcpgq0lerkw_wjq_8hp8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/1l\/ma\/vh\/1lmavhydcpgq0lerkw_wjq_8hp8.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h2>\u276f \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430 \u00ab\u0449\u0438\u043f\u043e\u043a\u00bb<\/h2>\n<p>  <\/p>\n<p>\u0429\u0438\u043f\u043e\u043a (pinch) \u043a\u0430\u043a \u0436\u0435\u0441\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 <em>\u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0447\u0438\u043a\u043e\u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0435\u0432 \u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/em>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/zd\/ik\/ha\/zdikhaa8aqpfopi9x6uvitntgfg.png\" data-src=\"https:\/\/habrastorage.org\/webt\/zd\/ik\/ha\/zdikhaa8aqpfopi9x6uvitntgfg.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>&#171;\u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e?&#187; \u2014 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b. \u0410\u0432\u0442\u043e\u0440 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u044d\u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u043a <code>0.8<\/code> \u0434\u043b\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 <code>x<\/code> \u0438 <code>y<\/code> \u0438 <code>0.11<\/code> \u0434\u043b\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b <code>z<\/code>. \u042f \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d \u0441 \u0435\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const distance = {     x: Math.abs(fingerTip.x - thumbTip.x),     y: Math.abs(fingerTip.y - thumbTip.y),     z: Math.abs(fingerTip.z - thumbTip.z),   }; const areFingersCloseEnough =   distance.x &lt; 0.08 &amp;&amp; distance.y &lt; 0.08 &amp;&amp; distance.z &lt; 0.11;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0449\u0438\u043f\u043a\u0430 (<code>pinch_start<\/code>, <code>pinch_move<\/code> \u0438 <code>pinch_stop<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e);<\/li>\n<li>\u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0449\u0438\u043f\u043a\u0430 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0435 (\u043d\u0430\u0447\u0430\u043b\u043e -> \u043a\u043e\u043d\u0435\u0446, \u0438\u043b\u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442), \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435;<\/li>\n<li>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>250 \u043c\u0441<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d &#171;\u043a\u0443\u0440\u0441\u043e\u0440&#187;. \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c <code>index.html<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;!-- &lt;div class=\"cursor\">&lt;\/div> --><\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>js<\/code> \u0444\u0430\u0439\u043b <code>detect-pinch-gesture.js<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u0430\u043b\u043e \u043a\u043e\u0434\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e \u043a\u043e\u0434\u0443 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c&#187;:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { Camera } from \"@mediapipe\/camera_utils\"; import { Hands } from \"@mediapipe\/hands\";  const video$ = document.querySelector(\"video\");  const width = window.innerWidth; const height = window.innerHeight;  const handParts = {   wrist: 0,   thumb: { base: 1, middle: 2, topKnuckle: 3, tip: 4 },   indexFinger: { base: 5, middle: 6, topKnuckle: 7, tip: 8 },   middleFinger: { base: 9, middle: 10, topKnuckle: 11, tip: 12 },   ringFinger: { base: 13, middle: 14, topKnuckle: 15, tip: 16 },   pinky: { base: 17, middle: 18, topKnuckle: 19, tip: 20 }, };  const hands = new Hands({   locateFile: (file) => `..\/node_modules\/@mediapipe\/hands\/${file}`, }); hands.setOptions({   maxNumHands: 1,   modelComplexity: 0, }); hands.onResults(onResults);  const camera = new Camera(video$, {   onFrame: async () => {     await hands.send({ image: video$ });   },   facingMode: undefined,   width,   height, }); camera.start();  \/\/ \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043d\u0435 \u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445 \u043a\u0443\u0440\u0441\u043e\u0440\u0430, \u0430 \u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445 \u0441\u0443\u0441\u0442\u0430\u0432\u0430 \u043f\u0430\u043b\u044c\u0446\u0430 const getFingerCoords = (landmarks) =>   landmarks[handParts.indexFinger.topKnuckle];  function onResults(handData) {   if (!handData.multiHandLandmarks.length) return;    updatePinchState(handData.multiHandLandmarks[0]); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f\u044b \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0449\u0438\u043f\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const PINCH_EVENTS = {   START: \"pinch_start\",   MOVE: \"pinch_move\",   STOP: \"pinch_stop\", };  const OPTIONS = {   PINCH_DELAY_MS: 250, };  const state = {   isPinched: false,   pinchChangeTimeout: null, };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0449\u0438\u043f\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function isPinched(landmarks) {   const fingerTip = landmarks[handParts.indexFinger.tip];   const thumbTip = landmarks[handParts.thumb.tip];   if (!fingerTip || !thumbTip) return;    const distance = {     x: Math.abs(fingerTip.x - thumbTip.x),     y: Math.abs(fingerTip.y - thumbTip.y),     z: Math.abs(fingerTip.z - thumbTip.z),   };    const areFingersCloseEnough =     distance.x &lt; 0.08 &amp;&amp; distance.y &lt; 0.08 &amp;&amp; distance.z &lt; 0.11;    return areFingersCloseEnough; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0443\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CustomEvent\/CustomEvent\">CustomEvent<\/a> \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/EventTarget\/dispatchEvent\">dispatchEvent<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 - \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u0430\u043b\u044c\u0446\u0430 function triggerEvent({ eventName, eventData }) {   const event = new CustomEvent(eventName, { detail: eventData });   document.dispatchEvent(event); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0449\u0438\u043f\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function updatePinchState(landmarks) {   \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435   const wasPinchedBefore = state.isPinched;   \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043b\u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0449\u0438\u043f\u043a\u0430   const isPinchedNow = isPinched(landmarks);   \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f   const hasPassedPinchThreshold = isPinchedNow !== wasPinchedBefore;   \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f   const hasWaitStarted = !!state.pinchChangeTimeout;    \/\/ \u0435\u0441\u043b\u0438 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043c\u044b \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f   if (hasPassedPinchThreshold &amp;&amp; !hasWaitStarted) {     \/\/ \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439     registerChangeAfterWait(landmarks, isPinchedNow);   }    \/\/ \u0435\u0441\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c   if (!hasPassedPinchThreshold) {     \/\/ \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u043c \u0440\u0435\u0436\u0438\u043c \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f     cancelWaitForChange();      \/\/ \u0435\u0441\u043b\u0438 \u0449\u0438\u043f\u043e\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442\u0441\u044f     if (isPinchedNow) {       \/\/ \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435       triggerEvent({         eventName: PINCH_EVENTS.MOVE,         eventData: getFingerCoords(landmarks),       });     }   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043e\u0442\u043c\u0435\u043d\u044b \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function registerChangeAfterWait(landmarks, isPinchedNow) {   state.pinchChangeTimeout = setTimeout(() => {     state.isPinched = isPinchedNow;      triggerEvent({       eventName: isPinchedNow ? PINCH_EVENTS.START : PINCH_EVENTS.STOP,       eventData: getFingerCoords(landmarks),     });   }, OPTIONS.PINCH_DELAY_MS); }  function cancelWaitForChange() {   clearTimeout(state.pinchChangeTimeout);   state.pinchChangeTimeout = null; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0449\u0438\u043f\u043a\u0430 (\u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0441\u0443\u0441\u0442\u0430\u0432\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function onPinchStart(eventInfo) {   const fingerCoords = eventInfo.detail;   console.log(\"Pinch started\", fingerCoords); }  function onPinchMove(eventInfo) {   const fingerCoords = eventInfo.detail;   console.log(\"Pinch moved\", fingerCoords); }  function onPinchStop(eventInfo) {   const fingerCoords = eventInfo.detail;   console.log(\"Pinch stopped\", fingerCoords); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0438\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">document.addEventListener(PINCH_EVENTS.START, onPinchStart); document.addEventListener(PINCH_EVENTS.MOVE, onPinchMove); document.addEventListener(PINCH_EVENTS.STOP, onPinchStop);<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import { Camera } from \"@mediapipe\/camera_utils\"; import { Hands } from \"@mediapipe\/hands\";  const video$ = document.querySelector(\"video\");  const width = window.innerWidth; const height = window.innerHeight;  const handParts = {   wrist: 0,   thumb: { base: 1, middle: 2, topKnuckle: 3, tip: 4 },   indexFinger: { base: 5, middle: 6, topKnuckle: 7, tip: 8 },   middleFinger: { base: 9, middle: 10, topKnuckle: 11, tip: 12 },   ringFinger: { base: 13, middle: 14, topKnuckle: 15, tip: 16 },   pinky: { base: 17, middle: 18, topKnuckle: 19, tip: 20 }, };  const hands = new Hands({   locateFile: (file) => `..\/node_modules\/@mediapipe\/hands\/${file}`, }); hands.setOptions({   maxNumHands: 1,   modelComplexity: 0, }); hands.onResults(onResults);  const camera = new Camera(video$, {   onFrame: async () => {     await hands.send({ image: video$ });   },   facingMode: undefined,   width,   height, }); camera.start();  const getFingerCoords = (landmarks) =>   landmarks[handParts.indexFinger.topKnuckle];  function onResults(handData) {   if (!handData.multiHandLandmarks.length) return;    updatePinchState(handData.multiHandLandmarks[0]); }  const PINCH_EVENTS = {   START: \"pinch_start\",   MOVE: \"pinch_move\",   STOP: \"pinch_stop\", };  const OPTIONS = {   PINCH_DELAY_MS: 250, };  const state = {   isPinched: false,   pinchChangeTimeout: null, };  function isPinched(landmarks) {   const fingerTip = landmarks[handParts.indexFinger.tip];   const thumbTip = landmarks[handParts.thumb.tip];   if (!fingerTip || !thumbTip) return;    const distance = {     x: Math.abs(fingerTip.x - thumbTip.x),     y: Math.abs(fingerTip.y - thumbTip.y),     z: Math.abs(fingerTip.z - thumbTip.z),   };    const areFingersCloseEnough =     distance.x &lt; 0.08 &amp;&amp; distance.y &lt; 0.08 &amp;&amp; distance.z &lt; 0.11;    return areFingersCloseEnough; }  function triggerEvent({ eventName, eventData }) {   const event = new CustomEvent(eventName, { detail: eventData });   document.dispatchEvent(event); }  function updatePinchState(landmarks) {   const wasPinchedBefore = state.isPinched;   const isPinchedNow = isPinched(landmarks);   const hasPassedPinchThreshold = isPinchedNow !== wasPinchedBefore;   const hasWaitStarted = !!state.pinchChangeTimeout;    if (hasPassedPinchThreshold &amp;&amp; !hasWaitStarted) {     registerChangeAfterWait(landmarks, isPinchedNow);   }    if (!hasPassedPinchThreshold) {     cancelWaitForChange();      if (isPinchedNow) {       triggerEvent({         eventName: PINCH_EVENTS.MOVE,         eventData: getFingerCoords(landmarks),       });     }   } }  function registerChangeAfterWait(landmarks, isPinchedNow) {   state.pinchChangeTimeout = setTimeout(() => {     state.isPinched = isPinchedNow;      triggerEvent({       eventName: isPinchedNow ? PINCH_EVENTS.START : PINCH_EVENTS.STOP,       eventData: getFingerCoords(landmarks),     });   }, OPTIONS.PINCH_DELAY_MS); }  function cancelWaitForChange() {   clearTimeout(state.pinchChangeTimeout);   state.pinchChangeTimeout = null; }  function onPinchStart(eventInfo) {   const fingerCoords = eventInfo.detail;   console.log(\"Pinch started\", fingerCoords); }  function onPinchMove(eventInfo) {   const fingerCoords = eventInfo.detail;   console.log(\"Pinch moved\", fingerCoords); }  function onPinchStop(eventInfo) {   const fingerCoords = eventInfo.detail;   console.log(\"Pinch stopped\", fingerCoords); }  document.addEventListener(PINCH_EVENTS.START, onPinchStart); document.addEventListener(PINCH_EVENTS.MOVE, onPinchMove); document.addEventListener(PINCH_EVENTS.STOP, onPinchStop);<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c <code>console.log(\"Pinch moved\", fingerCoords);<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/9_\/sf\/cq\/9_sfcqzwehlu-owjcusnfbymfck.png\" data-src=\"https:\/\/habrastorage.org\/webt\/9_\/sf\/cq\/9_sfcqzwehlu-owjcusnfbymfck.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0449\u0438\u043f\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ou\/nc\/uw\/ouncuwc7duce7-brv6bvhx16mak.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ou\/nc\/uw\/ouncuwc7duce7-brv6bvhx16mak.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<h2>\u276f \u041d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0449\u0438\u043f\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0441\u0443\u0441\u0442\u0430\u0432\u043e\u0432 \u043f\u0430\u043b\u044c\u0446\u0435\u0432 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0449\u0438\u043f\u043e\u043a. \u042d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0449\u0438\u043f\u043a\u0430.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c <code>index.html<\/code>, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0432 \u043d\u0435\u0433\u043e \u0432\u0442\u043e\u0440\u043e\u0439 &#171;\u043a\u0443\u0440\u0441\u043e\u0440&#187;, \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u043a\u043b\u0438\u043a\u043e\u0432 \u0438 \u043a\u043d\u043e\u043f\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;div class=\"cursor2\">&lt;\/div> &lt;div class=\"counter-box\">   &lt;p>0&lt;\/p>   &lt;button>Click me by pinch&lt;\/button> &lt;\/div><\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c <code>style.css<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">body {   margin: 0;   overflow: hidden; }  canvas {   display: none; }  video {   max-width: 100vw;   max-height: 100vh; }  .cursor, .cursor2 {   height: 0;   left: 0;   position: absolute;   top: 0;   transition: transform 0.1s;   width: 0;   z-index: 10; }  .cursor::after, .cursor2::after {   background-color: #0275d8;   border-radius: 50%;   content: \"\";   display: block;   height: 50px;   left: 0;   position: absolute;   top: 0;   transform: translate(-50%, -50%);   width: 50px; }  .cursor2::after {   background-color: #5cb85c;   width: 20px;   height: 20px; }  .counter-box {   left: 50%;   position: absolute;   top: 50%;   transform: translate(-50%, -50%); }  p {   font-size: 2rem;   text-align: center; }  button {   border-radius: 4px;   border: 2px solid #0275d8;   font-size: 1rem;   padding: 1rem; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>js<\/code> \u0444\u0430\u0439\u043b <code>click-button-by-pinch.js<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u0442\u0438\u043b\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/code> \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Element\/getBoundingClientRect\">getBoundingClientRect<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { Camera } from \"@mediapipe\/camera_utils\"; import { Hands } from \"@mediapipe\/hands\"; import \"..\/style.css\";  const video$ = document.querySelector(\"video\"); const cursor$ = document.querySelector(\".cursor2\"); const counter$ = document.querySelector(\"p\"); const button$ = document.querySelector(\"button\"); \/\/ \u043a\u043d\u043e\u043f\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 const buttonRect = button$.getBoundingClientRect();<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u043a\u043b\u0438\u043a\u043e\u0432 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let count = 0;  button$.addEventListener(\"click\", () => {   counter$.textContent = ++count; });<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d \u043a\u043e\u0434\u0443 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043e\u043d\u0447\u0438\u043a\u0430 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const getFingerCoords = (landmarks) => landmarks[handParts.indexFinger.tip];<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>updateCursorPosition<\/code> \u043c\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u043c &#171;\u043a\u0443\u0440\u0441\u043e\u0440&#187;, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0438 \u0441\u0442\u0438\u043b\u0438\u0437\u0443\u0435\u043c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">function updateCursorPosition(landmarks) {   const fingerCoords = getFingerCoords(landmarks);   if (!fingerCoords) return;    const { x, y } = convertCoordsToDomPosition(fingerCoords);    cursor$.style.transform = `translate(${x}, ${y})`;    const hit = isIntersected();   if (hit) {     button$.style.border = \"2px solid #5cb85c\";   } else {     button$.style.border = \"2px solid #0275d8\";   } }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u0430&#187; \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">function isIntersected() {   const cursorRect = cursor$.getBoundingClientRect();    \/\/ \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0441\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \"\u043a\u0443\u0440\u0441\u043e\u0440\u0430\" \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u043a\u043d\u043e\u043f\u043a\u0438   const hit =     cursorRect.x >= buttonRect.x &amp;&amp;     cursorRect.y >= buttonRect.y &amp;&amp;     cursorRect.x + cursorRect.width &lt;= buttonRect.x + buttonRect.width &amp;&amp;     cursorRect.y + cursorRect.height &lt;= buttonRect.y + buttonRect.height;    return hit; }<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0449\u0438\u043f\u043a\u0430:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const PINCH_EVENTS = {   START: \"pinch_start\",   \/\/ \u0434\u043b\u044f \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430   STOP: \"pinch_stop\", };  function updatePinchState(landmarks) {   const wasPinchedBefore = state.isPinched;   const isPinchedNow = isPinched(landmarks);   const hasPassedPinchThreshold = isPinchedNow !== wasPinchedBefore;   const hasWaitStarted = !!state.pinchChangeTimeout;    if (hasPassedPinchThreshold &amp;&amp; !hasWaitStarted) {     registerChangeAfterWait(landmarks, isPinchedNow);   }    if (!hasPassedPinchThreshold) {     cancelWaitForChange();   } }  document.addEventListener(PINCH_EVENTS.START, onPinchStart);<\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0449\u0438\u043f\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 \u043f\u0440\u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">function onPinchStart() {   const hit = isIntersected();    if (hit) {     button$.click();   } }<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import { Camera } from \"@mediapipe\/camera_utils\"; import { Hands } from \"@mediapipe\/hands\"; import \"..\/style.css\";  const video$ = document.querySelector(\"video\"); const cursor$ = document.querySelector(\".cursor2\"); const counter$ = document.querySelector(\"p\"); const button$ = document.querySelector(\"button\"); const buttonRect = button$.getBoundingClientRect();  let count = 0;  button$.addEventListener(\"click\", () => {   counter$.textContent = ++count; });  const width = window.innerWidth; const height = window.innerHeight;  const handParts = {   wrist: 0,   thumb: { base: 1, middle: 2, topKnuckle: 3, tip: 4 },   indexFinger: { base: 5, middle: 6, topKnuckle: 7, tip: 8 },   middleFinger: { base: 9, middle: 10, topKnuckle: 11, tip: 12 },   ringFinger: { base: 13, middle: 14, topKnuckle: 15, tip: 16 },   pinky: { base: 17, middle: 18, topKnuckle: 19, tip: 20 }, };  const hands = new Hands({   locateFile: (file) => `..\/node_modules\/@mediapipe\/hands\/${file}`, }); hands.setOptions({   maxNumHands: 1,   modelComplexity: 0, }); hands.onResults(onResults);  const camera = new Camera(video$, {   onFrame: async () => {     await hands.send({ image: video$ });   },   facingMode: undefined,   width,   height, }); camera.start();  const getFingerCoords = (landmarks) => landmarks[handParts.indexFinger.tip];  const convertCoordsToDomPosition = ({ x, y }) => ({   x: `${x * 100}vw`,   y: `${y * 100}vh`, });  function updateCursorPosition(landmarks) {   const fingerCoords = getFingerCoords(landmarks);   if (!fingerCoords) return;    const { x, y } = convertCoordsToDomPosition(fingerCoords);    cursor$.style.transform = `translate(${x}, ${y})`;    const hit = isIntersected();   if (hit) {     button$.style.border = \"2px solid #5cb85c\";   } else {     button$.style.border = \"2px solid #0275d8\";   } }  function onResults(handData) {   if (!handData.multiHandLandmarks.length) return;    updateCursorPosition(handData.multiHandLandmarks[0]);    updatePinchState(handData.multiHandLandmarks[0]); }  const PINCH_EVENTS = {   START: \"pinch_start\",   STOP: \"pinch_stop\", };  const OPTIONS = {   PINCH_DELAY_MS: 250, };  const state = {   isPinched: false,   pinchChangeTimeout: null, };  function isPinched(landmarks) {   const fingerTip = landmarks[handParts.indexFinger.tip];   const thumbTip = landmarks[handParts.thumb.tip];   if (!fingerTip || !thumbTip) return;    const distance = {     x: Math.abs(fingerTip.x - thumbTip.x),     y: Math.abs(fingerTip.y - thumbTip.y),     z: Math.abs(fingerTip.z - thumbTip.z),   };    const areFingersCloseEnough =     distance.x &lt; 0.08 &amp;&amp; distance.y &lt; 0.08 &amp;&amp; distance.z &lt; 0.11;    return areFingersCloseEnough; }  function isIntersected() {   const cursorRect = cursor$.getBoundingClientRect();    const hit =     cursorRect.x >= buttonRect.x &amp;&amp;     cursorRect.y >= buttonRect.y &amp;&amp;     cursorRect.x + cursorRect.width &lt;= buttonRect.x + buttonRect.width &amp;&amp;     cursorRect.y + cursorRect.height &lt;= buttonRect.y + buttonRect.height;    return hit; }  function triggerEvent({ eventName, eventData }) {   const event = new CustomEvent(eventName, { detail: eventData });   document.dispatchEvent(event); }  function updatePinchState(landmarks) {   const wasPinchedBefore = state.isPinched;   const isPinchedNow = isPinched(landmarks);   const hasPassedPinchThreshold = isPinchedNow !== wasPinchedBefore;   const hasWaitStarted = !!state.pinchChangeTimeout;    if (hasPassedPinchThreshold &amp;&amp; !hasWaitStarted) {     registerChangeAfterWait(landmarks, isPinchedNow);   }    if (!hasPassedPinchThreshold) {     cancelWaitForChange();   } }  function registerChangeAfterWait(landmarks, isPinchedNow) {   state.pinchChangeTimeout = setTimeout(() => {     state.isPinched = isPinchedNow;      triggerEvent({       eventName: isPinchedNow ? PINCH_EVENTS.START : PINCH_EVENTS.STOP,       eventData: getFingerCoords(landmarks),     });   }, OPTIONS.PINCH_DELAY_MS); }  function cancelWaitForChange() {   clearTimeout(state.pinchChangeTimeout);   state.pinchChangeTimeout = null; }  function onPinchStart() {   const hit = isIntersected();    if (hit) {     button$.click();   } }  document.addEventListener(PINCH_EVENTS.START, onPinchStart);<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/bj\/m3\/qx\/bjm3qxlr74j7sebrlodb2awgi34.png\" data-src=\"https:\/\/habrastorage.org\/webt\/bj\/m3\/qx\/bjm3qxlr74j7sebrlodb2awgi34.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u044e, \u043f\u0435\u0440\u0432\u043e\u0439 \u043c\u043e\u0435\u0439 \u043c\u044b\u0441\u043b\u044c\u044e \u0431\u044b\u043b\u043e: &#171;\u0410 \u0431\u0443\u0434\u0443\u0449\u0435\u0435-\u0442\u043e, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0443\u0436\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u043b\u043e&#187; \ud83d\ude42<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u0441\u0430\u043c\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0431\u0435\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0435\u0440\u0437\u0430\u0439\u0442\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u044d\u0442\u043e \u0432\u0441\u0435, \u0447\u0435\u043c \u044f \u0445\u043e\u0442\u0435\u043b \u0441 \u0432\u0430\u043c\u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0438 \u043d\u0435 \u0437\u0440\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 happy coding!<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p><a href=\"https:\/\/cloud.timeweb.com\/vds-promo-8-rub?utm_source=habr&amp;utm_medium=blog_1560_476&amp;utm_campaign=habr&amp;utm_content=1560_476\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/p-\/u9\/l2\/p-u9l27ynelxi92bcmdxhu76ma8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/p-\/u9\/l2\/p-u9l27ynelxi92bcmdxhu76ma8.png\"\/><\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \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\/company\/timeweb\/blog\/698286\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/698286\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tb\/2u\/fx\/tb2ufxookpot0mirap8x-dzoedg.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tb\/2u\/fx\/tb2ufxookpot0mirap8x-dzoedg.jpeg\" data-blurred=\"true\"\/>  <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0415\u0449\u0435 \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0436\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0432 \u0444\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0438\u043b\u044c\u043c\u0430\u0445. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0441\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u2014 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u0430 \u0438 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 (\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043e\u0442 <code>Google<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c 5 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0438\u0445 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 (canvas);<\/li>\n<li>\u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043a\u0438\u0441\u0442\u0438 \u0440\u0443\u043a\u0438;<\/li>\n<li>\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 &#171;\u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c&#187; \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u043b\u044c\u0446\u0430;<\/li>\n<li>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0436\u0435\u0441\u0442\u0430 &#171;\u0449\u0438\u043f\u043e\u043a&#187; (pinch);<\/li>\n<li>\u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0449\u0438\u043f\u043a\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c <code>JavaScript<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b\u0430 <a href=\"https:\/\/www.smashingmagazine.com\/2022\/10\/motion-controls-browser\/\">\u044d\u0442\u0430 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0440\u0443\u043a\u0438 \u0438 \u0436\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/google.github.io\/mediapipe\/\">MediaPipe<\/a>. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u2014 <a href=\"https:\/\/yarnpkg.com\/\">Yarn<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/harryheman\/Blog-Posts\/tree\/master\/motion-controls\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/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-341035","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341035","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=341035"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341035\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}