{"id":307863,"date":"2020-08-02T15:00:32","date_gmt":"2020-08-02T15:00:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=307863"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=307863","title":{"rendered":"\u041a\u0430\u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u044a\u0435\u043c\u043a\u0443 \u043f\u0440\u0438 \u0443\u043b\u044b\u0431\u043a\u0435 \u0437\u0430 \u043f\u043e\u043b\u0447\u0430\u0441\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e HUAWEI ML Kit"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/513488\/\">\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Huawei HMS Core 4.0, \u2014 \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f ML Kit.<\/p>\n<p>  \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u0441\u0435\u0440\u0432\u0438\u0441 ML Kit? \u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435?<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043e\u0434\u043d\u0443 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 ML Kit \u2014 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0446\u0430.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041e\u0431\u0437\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/u5\/ad\/_g\/u5ad_grsdm40m9jz8lqgtghtsoe.gif\" \/><\/div>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043b\u0438\u0446\u0430, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043b\u0438\u0446\u0430 (\u0440\u0430\u0434\u043e\u0441\u0442\u044c, \u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435, \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435, \u0433\u0440\u0443\u0441\u0442\u044c \u0438 \u0437\u043b\u043e\u0441\u0442\u044c), \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 (\u043f\u043e\u043b, \u0432\u043e\u0437\u0440\u0430\u0441\u0442, \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u043e\u0434\u0435\u0436\u0434\u044b \u0438 \u0430\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440\u044b), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043e\u0442\u043a\u0440\u044b\u0442\u044b \u0433\u043b\u0430\u0437\u0430 \u0438\u043b\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b. \u041e\u043d\u0430 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043d\u043e\u0441\u0430, \u0433\u043b\u0430\u0437, \u0433\u0443\u0431 \u0438 \u0431\u0440\u043e\u0432\u0435\u0439 \u0438 \u0434\u0430\u0436\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b \u043b\u0438\u0446 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0410 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u0430 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 Android.<\/p>\n<h2>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u044a\u0435\u043c\u043a\u0438 \u043f\u0440\u0438 \u0443\u043b\u044b\u0431\u043a\u0435 \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u044b \u043b\u044e\u0434\u0435\u0439<\/h2>\n<p>  \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435, \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u0435\u043c\u043e-\u0432\u0435\u0440\u0441\u0438\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u044a\u0435\u043c\u043a\u0438 \u043f\u0440\u0438 \u0443\u043b\u044b\u0431\u043a\u0435. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0434\u0435\u043c\u043e-\u0432\u0435\u0440\u0441\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0430 <a href=\"https:\/\/github.com\/HMS-Core\/hms-ml-demo\">github.com\/HMS-Core\/hms-ml-demo<\/a>.<\/p>\n<h3>1. \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h3>\n<p>  \u041f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u043b\u044e\u0431\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 HMS Core \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439. \u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 Maven \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c SDK.<\/p>\n<h4>1.1 \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 Maven, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 Huawei, \u0432 \u0444\u0430\u0439\u043b build.gradle \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h4>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0430\u0434\u0440\u0435\u0441 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f Maven:<\/p>\n<pre><code class=\"plaintext\">buildscript {     repositories {                 maven {url 'http:\/\/developer.huawei.com\/repo\/'}     }    }allprojects {     repositories {                maven { url 'http:\/\/developer.huawei.com\/repo\/'}     }}<\/code><\/pre>\n<p>  <\/p>\n<h4>1.2 \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 SDK \u0432 \u0444\u0430\u0439\u043b build.gradle \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 SDK \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 SDK:<\/p>\n<pre><code class=\"plaintext\">dependencies{    \/\/ import the basic SDK    implementation 'com.huawei.hms:ml-computer-vision:1.0.2.300'    \/\/ Import the face detection SDK   implementation 'com.huawei.hms:ml-computer-vision-face-recognition-model:1.0.2.300'     }<\/code><\/pre>\n<p>  <\/p>\n<h4>1.3 \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0444\u0430\u0439\u043b AndroidManifest.xml<\/h4>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u041c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430.<\/p>\n<pre><code class=\"plaintext\">&lt;manifest        &lt;application          &lt;meta-data                                 android:name=&quot;com.huawei.hms.ml.DEPENDENCY&quot;                      android:value= &quot;face&quot;\/&gt;                     &lt;\/application&gt;&lt;\/manifest&gt; <\/code><\/pre>\n<p>  <\/p>\n<h4>1.4 \u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u0440\u0430\u0432\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u0430\u043c\u0435\u0440\u0435 \u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 AndroidManifest.xml<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">&lt;!--Camera permission--&gt;&lt;uses-permission android:name=&quot;android.permission.CAMERA&quot; \/&gt;&lt;!--Storage permission--&gt;&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; \/&gt;<\/code><\/pre>\n<p>  <\/p>\n<h3>2. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u0434\u0430<\/h3>\n<p>  <\/p>\n<h4>2.1 \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043b\u0438\u0446\u0430 \u0434\u043b\u044f \u0441\u044a\u0435\u043c\u043a\u0438 \u0444\u043e\u0442\u043e \u043f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0443\u043b\u044b\u0431\u043a\u0438<\/h4>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u044a\u0435\u043c\u043a\u0443 \u0444\u043e\u0442\u043e \u043f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0443\u043b\u044b\u0431\u043a\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f: <\/p>\n<p>  (1) \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430. <br \/>  (2) \u041f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0443. <br \/>  (3) \u041f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 transactResult \u0432 analyzer.setTransacto \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0438 \u043b\u0438\u0446\u0430. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 (\u0447\u0442\u043e \u043d\u0430 \u043b\u0438\u0446\u0435 \u0435\u0441\u0442\u044c \u0443\u043b\u044b\u0431\u043a\u0430). \u041a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u0430\u043c\u0435\u0440\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0444\u043e\u0442\u043e.<\/p>\n<pre><code class=\"plaintext\">private MLFaceAnalyzer analyzer;private void createFaceAnalyzer() {     MLFaceAnalyzerSetting setting =             new MLFaceAnalyzerSetting.Factory()                     .setFeatureType(MLFaceAnalyzerSetting.TYPE_FEATURES)                     .setKeyPointType(MLFaceAnalyzerSetting.TYPE_UNSUPPORT_KEYPOINTS)                     .setMinFaceProportion(0.1f)                     .setTracingAllowed(true)                     .create();                      this.analyzer = MLAnalyzerFactory.getInstance().getFaceAnalyzer(setting);     this.analyzer.setTransactor(new MLAnalyzer.MLTransactor&lt;MLFace&gt;() {         @Override        public void destroy() {         }          @Override        public void transactResult(MLAnalyzer.Result&lt;MLFace&gt; result) {             SparseArray&lt;MLFace&gt; faceSparseArray = result.getAnalyseList();             int flag = 0;             for (int i = 0; i &lt; faceSparseArray.size(); i++) {                 MLFaceEmotion emotion = faceSparseArray.valueAt(i).getEmotions();                 if (emotion.getSmilingProbability() &gt; smilingPossibility) {                     flag++;                 }             }             if (flag &gt; faceSparseArray.size() * smilingRate && safeToTakePicture) {                 safeToTakePicture = false;                 mHandler.sendEmptyMessage(TAKE_PHOTO);             }         }     });}<\/code><\/pre>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0444\u043e\u0442\u043e:<\/p>\n<pre><code class=\"plaintext\">private void takePhoto() {     this.mLensEngine.photograph(null,             new LensEngine.PhotographListener() {                 @Override                public void takenPhotograph(byte[] bytes) {                     mHandler.sendEmptyMessage(STOP_PREVIEW);                     Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);                     saveBitmapToDisk(bitmap);                 }             });}<\/code><\/pre>\n<p>  <\/p>\n<h4>2.2 \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 LensEngine \u0434\u043b\u044f \u0437\u0430\u0445\u0432\u0430\u0442\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">private void createLensEngine() {     Context context = this.getApplicationContext();     \/\/ Create LensEngine     this.mLensEngine = new LensEngine.Creator(context, this.analyzer).setLensType(this.lensType)             .applyDisplayDimension(640, 480)             .applyFps(25.0f)             .enableAutomaticFocus(true)             .create();}<\/code><\/pre>\n<p>  <\/p>\n<h4>2.3 \u041e\u0442\u043f\u0440\u0430\u0432\u044c\u0442\u0435 \u0437\u0430\u044f\u0432\u043a\u0443 \u043d\u0430 \u043f\u0440\u0430\u0432\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c \u0438 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u0435 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0438 LensEngine<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">@Overridepublic void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     this.setContentView(R.layout.activity_live_face_analyse);     if (savedInstanceState != null) {         this.lensType = savedInstanceState.getInt(&quot;lensType&quot;);     }     this.mPreview = this.findViewById(R.id.preview);     this.createFaceAnalyzer();     this.findViewById(R.id.facingSwitch).setOnClickListener(this);     \/\/ Checking Camera Permissions     if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {         this.createLensEngine();     } else {         this.requestCameraPermission();     }}     private void requestCameraPermission() {     final String[] permissions = new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};      if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {         ActivityCompat.requestPermissions(this, permissions, LiveFaceAnalyseActivity.CAMERA_PERMISSION_CODE);         return;     }}@Overridepublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,                                        @NonNull int[] grantResults) {     if (requestCode != LiveFaceAnalyseActivity.CAMERA_PERMISSION_CODE) {         super.onRequestPermissionsResult(requestCode, permissions, grantResults);         return;     }     if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {         this.createLensEngine();         return;     }}<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/h2>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438? \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u0437\u043d\u0430\u043a\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u043e\u0432\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u0441\u0435\u0433\u043e \u0437\u0430 \u043f\u043e\u043b\u0447\u0430\u0441\u0430! \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f.<\/p>\n<p>  \u0414\u0435\u043b\u0430\u0442\u044c \u0444\u043e\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u0440\u0438 \u0443\u043b\u044b\u0431\u043a\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z8\/6y\/zs\/z86yzsmgcaub62h2wsoritr6nn4.gif\" \/><\/div>\n<p>  \u0414\u0435\u043b\u0430\u0442\u044c \u0444\u043e\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u0440\u0438 \u0443\u043b\u044b\u0431\u043a\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/av\/po\/wz\/avpowzrgvjo1rfe3p_2gidguyz4.gif\" \/><\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0439\u0434\u0438\u0442\u0435 \u043d\u0430 \u043d\u0430\u0448 \u0441\u0430\u0439\u0442: <a href=\"https:\/\/developer.huawei.com\/consumer\/en\/doc\/development\/HMS-Guides\/ml-introduction-4\">developer.huawei.com\/consumer\/en\/doc\/development\/HMS-Guides\/ml-introduction-4<\/a><\/p>\n<p>  \u041c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f HUAWEI ML Kit. \u0421\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438!<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/513488\/\"> https:\/\/habr.com\/ru\/post\/513488\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/513488\/\">\u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Huawei HMS Core 4.0, \u2014 \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f ML Kit.<\/p>\n<p>  \u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u0435\u043d \u0441\u0435\u0440\u0432\u0438\u0441 ML Kit? \u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435?<\/p>\n<p>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043e\u0434\u043d\u0443 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 ML Kit \u2014 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0446\u0430.  <\/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-307863","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307863","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=307863"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307863\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}