{"id":329255,"date":"2022-02-08T09:00:10","date_gmt":"2022-02-08T09:00:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329255"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329255","title":{"rendered":"<span>JavaScript: \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u0435\u043b\u0444\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/cm\/yu\/dk\/cmyudkffaaxue4r760lyvmate6i.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B5%D0%BB%D1%84%D0%B8\">\u0441\u0435\u043b\u0444\u0438<\/a> \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0437\u0430\u0445\u0432\u0430\u0442 \u043c\u0435\u0434\u0438\u0430\u043f\u043e\u0442\u043e\u043a\u0430 (\u0434\u0430\u043b\u0435\u0435 \u0442\u0430\u043a\u0436\u0435 \u2014 \u043f\u043e\u0442\u043e\u043a) \u0438\u0437 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u044b \u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430;<\/li>\n<li>\u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>video<\/code>;<\/li>\n<li>\u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0432\u0438\u0434\u0435\u043e\u0442\u0440\u0435\u043a (\u0434\u0430\u043b\u0435\u0435 \u0442\u0430\u043a\u0436\u0435 \u2014 \u0442\u0440\u0435\u043a), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439;<\/li>\n<li>\u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 (capabilities) \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a (settings) \u0434\u043b\u044f \u0444\u043e\u0442\u043e;<\/li>\n<li>\u0438\u0437 \u0442\u0440\u0435\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a;<\/li>\n<li>\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 (<code>&lt;input type=\"range\"><\/code>) \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0434\u043b\u044f \u0444\u043e\u0442\u043e;<\/li>\n<li>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043d\u0438\u043c\u0430\u0442\u044c \u0444\u043e\u0442\u043e (take photos) \u0438 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u044b (grab frames);<\/li>\n<li>\u0444\u043e\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>img<\/code>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f;<\/li>\n<li>\u0444\u0440\u0435\u0439\u043c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 (<code>canvas<\/code>), \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/harryheman\/Blog-Posts\/tree\/master\/image-capture\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c <code>JavaScript<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <a href=\"https:\/\/vitejs.dev\/\"><code>Vite<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0439 \u0432 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u0435\u0434\u0438\u0430 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/581086\/\">\u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0430\u0443\u0434\u0438\u043e\u0437\u0430\u043c\u0435\u0442\u043e\u043a<\/a>;<\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/591417\/\">\u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u043a\u0440\u0430\u043d\u0430<\/a>;<\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/646831\/\">\u0441\u0442\u0430\u0442\u044c\u044f \u043e \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0430\u0443\u0434\u0438\u043e \u0438 \u0432\u0438\u0434\u0435\u043e\u0442\u0440\u0435\u043a\u043e\u0432<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/www.w3.org\/TR\/image-capture\">MediaStream Image Capture<\/a> \u2014 \u0437\u0430\u0445\u0432\u0430\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f;<\/li>\n<li><a href=\"https:\/\/w3c.github.io\/mediacapture-main\">Media Capture and Streams<\/a> \u2014 \u0437\u0430\u0445\u0432\u0430\u0442 \u043f\u043e\u0442\u043e\u043a\u0430;<\/li>\n<li><a href=\"https:\/\/w3c.github.io\/FileAPI\">File API<\/a> \u2014 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044b <a href=\"https:\/\/developer.mozilla.org\">MDN<\/a> \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439. \u041d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u043e\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <a href=\"https:\/\/caniuse.com\/?search=imagecapture\">71%<\/a> \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d\u0435 \u0440\u0430\u043d\u043e. \u041c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 &#171;\u0412\u0435\u0431 \u0437\u0430\u0432\u0442\u0440\u0430\u0448\u043d\u0435\u0433\u043e \u0434\u043d\u044f&#187;.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># image-capture - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 # --template vanilla - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d yarn create vite image-capture --template vanilla # \u0438\u043b\u0438 npm init vite ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d, \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u0437 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaDevices\/getUserMedia\"><code>getUserMedia<\/code><\/a> \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaDevices\"><code>MediaDevices<\/code><\/a> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Navigator\"><code>Navigator<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043f\u043e\u0442\u043e\u043a\u0443 \/\/ https:\/\/w3c.github.io\/mediacapture-main\/#constrainable-interface \/\/ https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaTrackConstraints const constraints = { video: true } \/\/ \u043f\u043e\u0442\u043e\u043a \/\/ https:\/\/w3c.github.io\/mediacapture-main\/#mediastream \/\/ https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStream const stream = await navigator.mediaDevices.getUserMedia(constraints)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0442\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0435\u043a\u043e\u0432 (\u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0431\u043e\u043b\u0435\u0435). \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStream\/getTrackById\"><code>getTrackById<\/code><\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStream\/getTracks\"><code>getTracks<\/code><\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStream\/getAudioTracks\"><code>getAudioTracks<\/code><\/a> \u0438 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStream\/getVideoTracks\"><code>getVideoTracks<\/code><\/a>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0442\u0440\u0435\u043a\u0438 \/\/ https:\/\/w3c.github.io\/mediacapture-main\/#mediastreamtrack \/\/ https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStreamTrack const videoTracks = stream.getVideoTracks() \/\/ \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 (\u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c) \u0442\u0440\u0435\u043a const videoTrack = stream.getVideoTracks()[0]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0442\u0440\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStreamTrack\/getCapabilities\"><code>getCapabilities<\/code><\/a> \u0438 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStreamTrack\/getSettings\"><code>getSettings<\/code><\/a>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/w3c.github.io\/mediacapture-main\/#dom-mediastreamtrack-getcapabilities const trackCapabilities = videoTrack.getCapabilities() \/\/ https:\/\/w3c.github.io\/mediacapture-main\/#dom-mediastreamtrack-getsettings const trackSettings = videoTrack.getSettings()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a \u0442\u0440\u0435\u043a\u0443 (\u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043b\u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445) \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/MediaStreamTrack\/applyConstraints\"><code>applyConstraints<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/w3c.github.io\/mediacapture-main\/#dictionary-mediatrackconstraints-members const advancedConstraints = {  contrast: 75,  sharpness: 75 } \/\/ https:\/\/w3c.github.io\/mediacapture-main\/#dom-mediastreamtrack-applyconstraints await applyConstraints({ advanced: [advancedConstraints] })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0444\u0440\u0435\u0439\u043c\u043e\u0432 \u0438\u0437 \u0432\u0438\u0434\u0435\u043e\u0442\u0440\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageCapture\"><code>ImageCapture<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/www.w3.org\/TR\/image-capture\/#imagecaptureapi const imageCapture = new ImageCapture(videoTrack)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0434\u043b\u044f \u0444\u043e\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageCapture\/getPhotoCapabilities\"><code>getPhotoCapabilities<\/code><\/a> \u0438 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageCapture\/getPhotoSettings\"><code>getPhotoSettings<\/code><\/a>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/www.w3.org\/TR\/image-capture\/#dom-imagecapture-getphotocapabilities const photoCapabilities = await imageCapture.getPhotoCapabilities() \/\/ https:\/\/www.w3.org\/TR\/image-capture\/#dom-imagecapture-getphotosettings const photoSettings = await imageCapture.getPhotoSettings()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u0438\u043c\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageCapture\/takePhoto\"><code>takePhoto<\/code><\/a>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Blob\"><code>Blob<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/www.w3.org\/TR\/image-capture\/#dom-imagecapture-takephoto \/\/ \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 - \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0444\u043e\u0442\u043e \/\/ https:\/\/www.w3.org\/TR\/image-capture\/#photosettings-section \/\/ https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageCapture\/takePhoto#parameters const blob = await imageCapture.takePhoto(photoSettings)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>blob<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/URL\/createObjectURL\"><code>createObjectUrl<\/code><\/a> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/URL\"><code>URL<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/w3c.github.io\/FileAPI\/#dfn-createObjectURL const src = URL.createObjectUrl(blob)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f (release) \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>blob<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/URL\/revokeObjectURL\"><code>revokeObjectUrl<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/w3c.github.io\/FileAPI\/#dfn-revokeObjectURL URL.revokeObjectUrl(src)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageCapture\/grabFrame\"><code>grabFrame<\/code><\/a>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageBitmap\"><code>ImageBitmap<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ https:\/\/www.w3.org\/TR\/image-capture\/#dom-imagecapture-grabframe const imageBitmap = await imageCapture.grabFrame()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 <code>imageBitmap<\/code> \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CanvasRenderingContext2D\/drawImage\"><code>drawImage<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const canvas$ = document.querySelector('canvas') const ctx = canvas$.getContext('2d')  ctx.drawImage(imageBitmap, 0, 0)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (pixel data) \u0438\u0437 \u0445\u043e\u043b\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CanvasRenderingContext2D\/getImageData\"><code>getImageData<\/code><\/a>. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ImageData\"><code>ImageData<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0438\u043a\u0441\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 `imageData.data` const imageData = ctx.getImageData(0, 0, canvas$.width, canvas$.height)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 <code>ImageData<\/code> \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/CanvasRenderingContext2D\/putImageData\"><code>putImageData<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">ctx.putImageData(imageData, 0, 0)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0434\u0430\u0432\u043d\u043e \u0433\u043e\u0442\u043e\u0432 \u0438 \u0441 \u043d\u0435\u0442\u0435\u0440\u043f\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">- index.html - styles  - loader.css  - main.css - scripts  - utils    - getMedia.js    - takePhoto.js    - grabFrame.js  - globals.js  - main.js - ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 (<code>index.html<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;head>  &lt;link rel=\"stylesheet\" href=\"styles\/main.css\" \/> &lt;\/head> &lt;body>  &lt;!-- \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 -->  &lt;div class=\"lds-roller\">    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>    &lt;div>&lt;\/div>  &lt;\/div>  &lt;!-- \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 -->  &lt;div id=\"app\">    &lt;div>      &lt;!-- \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u0430 -->      &lt;video autoplay muted>&lt;\/video>      &lt;!-- \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 -->      &lt;div class=\"result\">        &lt;!-- \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u0444\u043e\u0442\u043e -->        &lt;img \/>        &lt;!-- \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0442\u043e -->        &lt;a class=\"photo-link\">Download&lt;\/a>        &lt;!-- \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u0444\u0440\u0435\u0439\u043c\u0430 -->        &lt;canvas width=\"0\" height=\"0\">&lt;\/canvas>        &lt;!-- \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0430 -->        &lt;a class=\"canvas-link\">Download&lt;\/a>      &lt;\/div>    &lt;\/div>    &lt;!-- \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 -->    &lt;form class=\"settings\">      &lt;!-- \u043a\u043d\u043e\u043f\u043a\u0438 \u0434\u043b\u044f -->      &lt;div class=\"controls\">        &lt;!-- \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u0438\u043c\u043a\u0430 -->        &lt;button class=\"take-photo\">Take photo&lt;\/button>        &lt;!-- \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u043d\u0438\u043c\u043a\u0430 -->        &lt;button class=\"remove-photo\" type=\"button\">Remove photo&lt;\/button>        &lt;!-- \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0430 -->        &lt;button class=\"grab-frame\" type=\"button\">Grab frame&lt;\/button>        &lt;!-- \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0445\u043e\u043b\u0441\u0442\u0430 -->        &lt;button class=\"clear-canvas\" type=\"button\">Clear canvas&lt;\/button>      &lt;\/div>    &lt;\/form>  &lt;\/div>  &lt;!-- \u0441\u043a\u0440\u0438\u043f\u0442\u044b -->  &lt;!-- \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 -->  &lt;script src=\"scripts\/globals.js\">&lt;\/script>  &lt;!-- \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c -->  &lt;script type=\"module\" src=\"scripts\/main.js\">&lt;\/script> &lt;\/body><\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0442\u0438\u043b\u044f\u043c\u0438 (<code>styles\/loader.css<\/code>) \u044f \u0432\u0437\u044f\u043b <a href=\"https:\/\/loading.io\/css\/\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u0440\u0430\u0441\u043e\u0442\u044b (<code>styles\/main.css<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">@import url('https:\/\/fonts.googleapis.com\/css2?family=Montserrat:wght@200;400;600&amp;display=swap'); @import '.\/loader.css';  *, *::before, *::after {  margin: 0;  padding: 0;  box-sizing: border-box;  font-family: 'Monserrat', sans-serif;  font-size: 1rem;  color: #292b2c; }  :root {  --primary: #0275d8; }  body {  display: flex;  justify-content: center; }  #app {  padding: 1rem;  display: none; }  video, img, canvas {  max-width: 320px;  border-radius: 4px; }  .settings {  padding: 0 1rem; }  .field {  margin-bottom: 0.75rem;  flex-grow: 1;  display: grid;  align-items: center;  grid-template-columns: repeat(3, 1fr);  grid-gap: 1rem; }  .controls {  margin-bottom: 1rem;  display: flex; }  button {  padding: 0.3rem 0.5rem;  background: var(--primary);  border: none;  border-radius: 4px;  outline: none;  color: #f7f7f7;  font-size: 0.88rem;  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);  transition: 0.3s;  cursor: pointer;  user-select: none; }  button:active {  box-shadow: none; }  button[disabled] {  filter: grayscale(50);  opacity: 0.8;  cursor: not-allowed; }  .result {  display: flex;  flex-direction: column;  align-items: center; }  a {  margin: 0.5rem 0;  text-decoration: none;  font-size: 0.8rem;  display: none; }  a[href] {  color: var(--primary);  border-bottom: 1px dashed var(--primary); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (<code>scripts\/globals.js<\/code>).<\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0440\u0438\u0432\u0435\u0442, jQuery const $ = (selector, parent = document) => parent.querySelector(selector)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0440\u0438\u0432\u0435\u0442, React const create$ = (tag, attrs, children) => {  if (typeof tag !== 'string') return  const $ = document.createElement(tag)   if (attrs) {    if (typeof attrs !== 'object') return     for (const k in attrs) {      const v = attrs[k]       if (k === 'class') {        $.className = v        continue      }       if (k === 'style' &amp;&amp; typeof v === 'object') {        Object.assign($.style, v)        continue      }       if (k === 'text') {        $.textContent = v        continue      }       $[k] = v    }  }   if (Array.isArray(children) &amp;&amp; children.length > 0) {    children.forEach(([tag, attrs, children]) => {      $.append(create$(tag, attrs, children))    })  }   return $ }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const create$ = (template) => {  if (typeof template !== 'string') return  return new Range().createContextualFragment(template).children[0] }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const render$ = (parent, child, place = 'beforeend') => {  parent.insertAdjacentElement(place, child) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \/\/ `attrs` - \u043e\u0431\u044a\u0435\u043a\u0442 \/\/ \u043a\u043b\u044e\u0447\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 - \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 const setAttrs = ($, attrs) => {  if (attrs &amp;&amp; (typeof attrs !== 'object' || Array.isArray(attrs))) return   Object.keys(attrs).forEach((key) => {    $.setAttribute(key, attrs[key])  }) }  \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \/\/ `attrs` - \u043c\u0430\u0441\u0441\u0438\u0432 \/\/ \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 - \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 const removeAttrs = ($, attrs) => {  if (!Array.isArray(attrs)) return   attrs.forEach((name) => {    $.removeAttribute(name)  }) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const loader$ = $('.lds-roller') const app$ = $('#app') const video$ = $('video') const image$ = $('.result img') const photoLink$ = $('.photo-link') const canvas$ = $('.result canvas') const canvasLink$ = $('.canvas-link') const controls$ = $('.controls') const grabFrame$ = $('.grab-frame') const removePhoto$ = $('.remove-photo') const clearCanvas$ = $('.clear-canvas') const settings$ = $('.settings')<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f \u0438\u043d\u043f\u0443\u0442\u043e\u0432 const inputs$ = [] \/\/ \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f const ctx = canvas$.getContext('2d') \/\/ \u0432\u0438\u0434\u0435\u043e\u0442\u0440\u0435\u043a, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 `ImageCapture` \u0438 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0444\u043e\u0442\u043e let videoTrack let imageCapture let photoSrc<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c (\u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435) \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0442\u0440\u0435\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const settingDictionary = {  brightness: '\u042f\u0440\u043a\u043e\u0441\u0442\u044c',  colorTemperature: '\u0426\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430',  contrast: '\u041a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c',  saturation: '\u041d\u0430\u0441\u044b\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c',  sharpness: '\u0420\u0435\u0437\u043a\u043e\u0441\u0442\u044c',  pan: '\u041f\u0430\u043d\u043e\u0440\u0430\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435',  tilt: '\u041d\u0430\u043a\u043b\u043e\u043d',  zoom: '\u041c\u0430\u0441\u0448\u0442\u0430\u0431' }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0431\u0435\u0440\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044f\u0445. \u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0434\u043b\u044f \u0442\u0440\u0435\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/www.w3.org\/TR\/image-capture\/#constrainable-properties\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0432\u0438\u0434\u0435\u043e\u043f\u043e\u0442\u043e\u043a\u0430 \u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0438\u043d\u043f\u0443\u0442\u043e\u0432 (<code>scripts\/utils\/getMedia.js<\/code>).<\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const defaultConstraints = {  \/\/ \u044d\u0442\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u044f\u0432\u043d\u043e  video: {    pan: true,    tilt: true,    zoom: true  } }  async function getMedia(  constraints = defaultConstraints ) {  try {    \/\/ TODO  } catch (e) {    console.error(e)  } }  export default getMedia<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0432\u0438\u0434\u0435\u043e\u043f\u043e\u0442\u043e\u043a, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>video<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLMediaElement\/srcObject\"><code>srcObject<\/code><\/a>, \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0432\u0438\u0434\u0435\u043e\u0442\u0440\u0435\u043a \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>ImageCapture<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const stream = await navigator.mediaDevices.getUserMedia(constraints) video$.srcObject = stream \/\/ \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 videoTrack = stream.getVideoTracks()[0] imageCapture = new ImageCapture(videoTrack)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0444\u043e\u0442\u043e \u0438 \u0442\u0440\u0435\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const photoCapabilities = await imageCapture.getPhotoCapabilities() console.log('*** Photo capabilities', photoCapabilities)  const photoSettings = await imageCapture.getPhotoSettings() console.log('*** Photo settings', photoSettings)  const trackCapabilities = videoTrack.getCapabilities() console.log('*** Track capabilities', trackCapabilities)  const trackSettings = videoTrack.getSettings() console.log('*** Track settings', trackSettings)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u043a\u043b\u044e\u0447\u0438 &#171;\u0441\u043b\u043e\u0432\u0430\u0440\u044f&#187; \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">Object.keys(settingDictionary).forEach((key) => {  \/\/ TODO })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">if (key in trackSettings) {  \/\/ TODO }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e\u043b\u044f \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0442\u0440\u0435\u043a\u0430 \u2014 fieldTemplate;<\/li>\n<li>\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u044f \u2014 field$;<\/li>\n<li>\u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u0438\u043d\u043f\u0443\u0442 \u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u043f\u0443\u0442\u0430 \u2014 input$ \u0438 info$, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e;<\/li>\n<li>\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u043f\u0443\u0442\u0430 \u2014 oninput;<\/li>\n<li>\u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0438\u043d\u043f\u0443\u0442 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u043f\u0443\u0442\u043e\u0432 \u2014 inputs$;<\/li>\n<li>\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043f\u043e\u043b\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">const fieldTemplate = `  &lt;div class=\"field\">    &lt;label for=\"${key}\">      ${settingDictionary[key]}    &lt;\/label>    &lt;input      type=\"range\"      id=${key}      name=${key}      min=${trackCapabilities[key].min}      max=${trackCapabilities[key].max}      step=${trackCapabilities[key].step}      value=${trackSettings[key]}    \/>    &lt;p>${trackSettings[key]}&lt;\/p>  &lt;\/div> `  const field$ = create$(fieldTemplate) \/\/ \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 - \u044d\u0442\u043e `label`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 const [_, input$, info$] = field$.children  input$.oninput = ({ target: { value } }) => {  info$.textContent = value }  inputs$.push(input$)  render$(settings$, field$)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">loader$.style.display = 'none' app$.style.display = 'flex'<\/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 \u044d\u0442\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u044b:<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">const defaultConstraints = {  video: {    pan: true,    tilt: true,    zoom: true  } }  async function getMedia(constraints = defaultConstraints) {  try {    const stream = await navigator.mediaDevices.getUserMedia(constraints)    video$.srcObject = stream    videoTrack = stream.getVideoTracks()[0]    imageCapture = new ImageCapture(videoTrack)     const photoCapabilities = await imageCapture.getPhotoCapabilities()    console.log('*** Photo capabilities', photoCapabilities)    const photoSettings = await imageCapture.getPhotoSettings()    console.log('*** Photo settings', photoSettings)    const trackCapabilities = videoTrack.getCapabilities()    console.log('*** Track capabilities', trackCapabilities)    const trackSettings = videoTrack.getSettings()    console.log('*** Track settings', trackSettings)     Object.keys(settingDictionary).forEach((key) => {      if (key in trackSettings) {        const fieldTemplate = `          &lt;div class=\"field\">            &lt;label for=\"${key}\">              ${settingDictionary[key]}            &lt;\/label>            &lt;input              type=\"range\"              id=${key}              name=${key}              min=${trackCapabilities[key].min}              max=${trackCapabilities[key].max}              step=${trackCapabilities[key].step}              value=${trackSettings[key]}            \/>            &lt;p>${trackSettings[key]}&lt;\/p>          &lt;\/div>        `        const field$ = create$(fieldTemplate)        const [_, input$, info$] = field$.children        input$.oninput = ({ target: { value } }) => {          info$.textContent = value        }        inputs$.push(input$)        render$(settings$, field$)      }    })     loader$.style.display = 'none'    app$.style.display = 'flex'  } catch (e) {    console.error(e)  } }  export default getMedia<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u0438\u043c\u043a\u0430 (<code>scripts\/utils\/takePhoto.js<\/code>).<\/p>\n<p>  <\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0444\u043e\u0442\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const defaultSettings = {  imageHeight: 480,  imageWidth: 640 }  async function takePhoto(settings = defaultSettings) {  \/\/ TODO }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const advancedConstraints = {} for (const { name, value } of inputs$) {  advancedConstraints[name] = value }  try {  await videoTrack.applyConstraints({    advanced: [advancedConstraints]  }) } catch (e) {  console.error(e) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>blob<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>takePhoto<\/code>, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u043a\u0443 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0435 \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <code>img<\/code> \u0438 <code>a<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">try {  const blob = await imageCapture.takePhoto(settings)  \/\/ \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f  photoSrc = URL.createObjectURL(blob)   image$.src = photoSrc  setAttrs(photoLink$, {    href: photoSrc,    download: `my-photo-${Date.now()}.png`,    style: 'display: block;'  }) } catch (e) {  console.error(e) }<\/code><\/pre>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u0443 \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u0430 (<code>scripts\/utils\/grabFrame.js<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async function grabFrame() {  try {    \/\/ TODO  } catch(e) {    console.error(e)  } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>ImageBitmap<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <code>grabPhoto<\/code>, \u043e\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 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u0444\u0440\u0435\u0439\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const imageBitmap = await imageCapture.grabFrame()  canvas$.width = imageBitmap.width canvas$.height = imageBitmap.height  \/\/ \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u0444\u0440\u0435\u0439\u043c ctx.drawImage(imageBitmap, 0, 0)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0438\u0442\u0430\u0435\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u0438 \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0446\u0432\u0435\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const imageData = ctx.getImageData(0, 0, canvas$.width, canvas$.height) const { data } = imageData for (let i = 0; i &lt; data.length; i += 4) {  data[i] ^= 255 \/\/ \u043a\u0440\u0430\u0441\u043d\u044b\u0439  data[i + 1] ^= 255 \/\/ \u0437\u0435\u043b\u0435\u043d\u044b\u0439  data[i + 2] ^= 255 \/\/ \u0441\u0438\u043d\u0438\u0439 }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043b\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">ctx.putImageData(imageData, 0, 0)  setAttrs(canvasLink$, {  href: canvas$.toDataURL(),  download: `my-frame-${Date.now()}.png`,  style: 'display: block;' })<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0444\u0440\u0435\u0439\u043c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTMLCanvasElement\/toDataURL\"><code>toDataURL<\/code><\/a>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/Data_URIs\"><code>URL<\/code> \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>data:<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u044f\u043c\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Glossary\/Base64\"><code>base64<\/code><\/a>.<\/p>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (<code>scripts\/main.js<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0437\u0430\u0445\u0432\u0430\u0442 \u043c\u0435\u0434\u0438\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import getMedia from '.\/utils\/getMedia' import takePhoto from '.\/utils\/takePhoto' import grabFrame from '.\/utils\/grabFrame'  getMedia()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u043e\u0440\u043c\u044b \u2014 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043d\u0438\u043c\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">settings$.onsubmit = (e) => {  e.preventDefault()  \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043d\u0438\u043c\u043e\u043a  takePhoto()  \/\/ \u0441\u043d\u0438\u043c\u0430\u0435\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438  removePhoto$.disabled = false }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\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\u043e\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">controls$.onclick = ({ target }) => {  \/\/ \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0438\u043a \u043f\u043e \u043a\u043d\u043e\u043f\u043a\u0435  if (target.localName !== 'button') return  \/\/ \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0446\u0435\u043b\u0438 \u043a\u043b\u0438\u043a\u0430  switch (target) {    \/\/ \u0446\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430 - \u043a\u043d\u043e\u043f\u043a\u0430 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0444\u043e\u0442\u043e    case removePhoto$:      \/\/ \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 `blob`      URL.revokeObjectURL(photoSrc)      \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0444\u043e\u0442\u043e      image$.removeAttribute('src')      \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u043e\u0442\u043e      removeAttrs(photoLink$, ['href', 'download', 'style'])      \/\/ \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443      removePhoto$.disabled = true      break    \/\/ \u0446\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430 - \u043a\u043d\u043e\u043f\u043a\u0430 \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0444\u0440\u0435\u0439\u043c\u0430    case grabFrame$:      \/\/ \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0444\u0440\u0435\u0439\u043c      grabFrame()      \/\/ \u0441\u043d\u0438\u043c\u0430\u0435\u043c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438      clearCanvas$.disabled = false      break    \/\/ \u0446\u0435\u043b\u044c \u043a\u043b\u0438\u043a\u0430 - \u043a\u043d\u043e\u043f\u043a\u0430 \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0445\u043e\u043b\u0441\u0442\u0430    case clearCanvas$:      \/\/ \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0445\u043e\u043b\u0441\u0442      ctx.clearRect(0, 0, canvas$.width, canvas$.height)      \/\/ \u0441\u0436\u0438\u043c\u0430\u0435\u043c \u0445\u043e\u043b\u0441\u0442      setAttrs(canvas$, { width: 0, height: 0 })      \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0444\u0440\u0435\u0439\u043c      removeAttrs(canvasLink$, ['href', 'download', 'style'])      \/\/ \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443      clearCanvas$.disabled = true      break    default:      return  } }<\/code><\/pre>\n<p>  <\/p>\n<hr\/>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0417\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 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>yarn dev<\/code> \u0438\u043b\u0438 <code>npm run dev<\/code> \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <code>http:\/\/localhost:3000<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/da\/xu\/l3\/daxul3bs4ghuhvuaiko_j06xuks.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>Take photo<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/4g\/z4\/ld\/4gz4ldxxrtnxetbaxaiehoil-am.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0435\u043b\u0444\u0438 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043b\u044f \u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0444\u043e\u0442\u043e, \u043d\u0430\u0436\u0430\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>Remove photo<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438 \u0441\u043d\u043e\u0432\u0430 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c <code>Take photo<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/j9\/ry\/rb\/j9ryrbzwayp_j3afbyfk81mfph8.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p><em>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/em>: \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a \u0442\u0440\u0435\u043a\u0443 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0432\u0438\u0434\u0435\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e\u0431 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u0442\u0440\u0435\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0444\u043e\u0442\u043e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>Grab frame<\/code>:<\/p>\n<p>  <img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/0a\/3y\/gb\/0a3ygb-vld1twvtp0fk1-5tmzrq.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u0434\u043b\u044f \u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0445\u043e\u043b\u0441\u0442, \u043d\u0430\u0436\u0430\u0432 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 <code>Clear canvas<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f.<\/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 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/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\/?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=cloud&amp;utm_content=direct&amp;utm_term=low\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/bh\/0m\/fv\/bh0mfviu_rma7be5uylpewumuxi.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\/650233\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/650233\/<\/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_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" data-src=\"https:\/\/habrastorage.org\/webt\/cm\/yu\/dk\/cmyudkffaaxue4r760lyvmate6i.png\"\/>  <\/p>\n<p>  <\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%B5%D0%BB%D1%84%D0%B8\">\u0441\u0435\u043b\u0444\u0438<\/a> \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0437\u0430\u0445\u0432\u0430\u0442 \u043c\u0435\u0434\u0438\u0430\u043f\u043e\u0442\u043e\u043a\u0430 (\u0434\u0430\u043b\u0435\u0435 \u0442\u0430\u043a\u0436\u0435 \u2014 \u043f\u043e\u0442\u043e\u043a) \u0438\u0437 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u043c\u0435\u0440\u044b \u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430;<\/li>\n<li>\u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>video<\/code>;<\/li>\n<li>\u0438\u0437 \u043f\u043e\u0442\u043e\u043a\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0432\u0438\u0434\u0435\u043e\u0442\u0440\u0435\u043a (\u0434\u0430\u043b\u0435\u0435 \u0442\u0430\u043a\u0436\u0435 \u2014 \u0442\u0440\u0435\u043a), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439;<\/li>\n<li>\u0438\u0437 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 (capabilities) \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a (settings) \u0434\u043b\u044f \u0444\u043e\u0442\u043e;<\/li>\n<li>\u0438\u0437 \u0442\u0440\u0435\u043a\u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a;<\/li>\n<li>\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 (<code>&lt;input type=\"range\"><\/code>) \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u0434\u043b\u044f \u0444\u043e\u0442\u043e;<\/li>\n<li>\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043d\u0438\u043c\u0430\u0442\u044c \u0444\u043e\u0442\u043e (take photos) \u0438 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u044b (grab frames);<\/li>\n<li>\u0444\u043e\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 <code>img<\/code>, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f;<\/li>\n<li>\u0444\u0440\u0435\u0439\u043c \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0445\u043e\u043b\u0441\u0442\u0435 (<code>canvas<\/code>), \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f.<\/li>\n<\/ul>\n<p>  <\/p>\n<p><a href=\"https:\/\/github.com\/harryheman\/Blog-Posts\/tree\/master\/image-capture\">\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043e \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c <code>JavaScript<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <a href=\"https:\/\/vitejs.dev\/\"><code>Vite<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<\/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-329255","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329255","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=329255"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329255\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}