{"id":538,"date":"2019-10-09T11:06:29","date_gmt":"2019-10-09T03:06:29","guid":{"rendered":"http:\/\/weitaoc.com\/?p=538"},"modified":"2019-10-09T14:58:34","modified_gmt":"2019-10-09T06:58:34","slug":"h5%e4%ba%ba%e8%84%b8%e8%af%86%e5%88%ab","status":"publish","type":"post","link":"http:\/\/weitaoc.com\/?p=538","title":{"rendered":"h5\u4eba\u8138\u8bc6\u522b"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u6700\u8fd1\u5e2e\u522b\u4eba\u505a\u4e00\u4e2aapp\u5d4c\u5165\u4eba\u8138\u8bc6\u522b\u7684\u529f\u80fd\uff0c\u4e3b\u8981\u662f\u7528\u4e00\u4e2a\u5f00\u6e90\u7684js\u5e93\uff0c\u8fd9\u91cc\u7eaa\u5f55\u4e00\u4e0b\uff0c\u4ee5\u53ca\u78b0\u5230\u7684\u5751\u3002<\/p><\/blockquote>\n\n\n\n<p>js\u5e93\u4f7f\u7528\u7684\u6b6a\u679c\u4ec1\u5f00\u53d1\u4e00\u5957\u4e1c\u897f\uff0c\u53eb<strong><a href=\"https:\/\/github.com\/eduardolundgren\/tracking.js\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">tracking<\/a><\/strong>\uff0c\u6253\u5f00\u6444\u50cf\u5934\uff0c\u6839\u636e\u753b\u9762\u6355\u6349\u8138\u90e8(\u5fc5\u987b\u662f\u8138\u90e8)\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"607\" height=\"354\" src=\"http:\/\/weitaoc.com\/wp-content\/uploads\/2019\/10\/1-1.png\" alt=\"\" class=\"wp-image-539\" srcset=\"http:\/\/weitaoc.com\/wp-content\/uploads\/2019\/10\/1-1.png 607w, http:\/\/weitaoc.com\/wp-content\/uploads\/2019\/10\/1-1-300x175.png 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/figure>\n\n\n\n<p>\u6355\u83b7\u5230\u8138\u90e8\u540e\uff0c\u4f1a\u628a\u56fe\u7247\u8fdb\u884c\u622a\u56fe\uff0c\u8f6c\u6210base64\u7684\u56fe\u7247\uff0c\u4e0a\u4f20\u7ed9\u670d\u52a1\u7aef\uff0c\u670d\u52a1\u7aef\u8fdb\u884c\u4e0b\u4e00\u6b65\u7684\u4eba\u8138\u8bc6\u522b\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<p>\u672c\u5730\u6d4b\u8bd5\u65e0\u788d\uff0c\u4f46\u662f\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u4e4b\u540e\u53d1\u73b0MediaDevices.getUserMedia` undefined\u3002\u7f51\u4e0a\u67e5\u4e86\u4e00\u4e0b\u8d44\u6599\uff0c\u672c\u5730\u8c03\u7528\u6ca1\u95ee\u9898\uff0c\u5982\u679c\u4e0a\u4f20\u5230\u670d\u52a1\u5668\uff0c\u5730\u5740\u5fc5\u987b\u662fhttps\uff0c\u5426\u5219\u90fd\u662f undefined \u3002<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\"getUserMedia\u652f\u6301\u6d4f\u89c8\u5668\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"https:\/\/caniuse.com\/#search=getUserMedia\" target=\"_blank\">getUserMedia\u652f\u6301\u6d4f\u89c8\u5668<\/a><\/p>\n\n\n\n\n<div class=\"codecolorer-container html4strict geshi\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<br \/>73<br \/>74<br \/>75<br \/>76<br \/>77<br \/>78<br \/>79<br \/>80<br \/>81<br \/>82<br \/>83<br \/>84<br \/>85<br \/>86<br \/>87<br \/>88<br \/>89<br \/>90<br \/>91<br \/>92<br \/>93<br \/>94<br \/>95<br \/>96<br \/>97<br \/>98<br \/>99<br \/>100<br \/>101<br \/>102<br \/>103<br \/>104<br \/>105<br \/>106<br \/>107<br \/>108<br \/>109<br \/>110<br \/>111<br \/>112<br \/>113<br \/>114<br \/>115<br \/>116<br \/>117<br \/>118<br \/>119<br \/>120<br \/>121<br \/>122<br \/>123<br \/>124<br \/>125<br \/>126<br \/>127<br \/>128<br \/>129<br \/>130<br \/>131<br \/>132<br \/>133<br \/>134<br \/>135<br \/>136<br \/>137<br \/>138<br \/>139<br \/>140<br \/>141<br \/>142<br \/>143<br \/>144<br \/>145<br \/>146<br \/>147<br \/>148<br \/>149<br \/>150<br \/>151<br \/>152<br \/>153<br \/>154<br \/>155<br \/>156<br \/>157<br \/><\/div><\/td><td><div class=\"html4strict codecolorer\" style=\"white-space:nowrap\"><span style=\"color: #00bbdd;\">&lt;!DOCTYPE html&gt;<\/span><br \/>\n<span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">html<\/span>&gt;<\/span><br \/>\n<br \/>\n<span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">head<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">meta<\/span> <span style=\"color: #000066;\">charset<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;utf-8&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">meta<\/span> <span style=\"color: #000066;\">name<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;viewport&quot;<\/span><\/span><br \/>\n<span style=\"color: #009900;\"> &nbsp; &nbsp;<span style=\"color: #000066;\">content<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no&quot;<\/span> <span style=\"color: #66cc66;\">\/<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">title<\/span>&gt;<\/span>\u4eba\u8138\u8bc6\u522b<span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">title<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">link<\/span> <span style=\"color: #000066;\">href<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;vendor\/fontawesome-free\/css\/all.min.css&quot;<\/span> <span style=\"color: #000066;\">rel<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;stylesheet&quot;<\/span> <span style=\"color: #000066;\">type<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;text\/css&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;link rel=&quot;stylesheet&quot; href=&quot;css\/layer.css&quot;&gt; --&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">link<\/span> <span style=\"color: #000066;\">rel<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;stylesheet&quot;<\/span> <span style=\"color: #000066;\">href<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;css\/demo.css&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">link<\/span> <span style=\"color: #000066;\">href<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;css\/sb-admin-2.min.css&quot;<\/span> <span style=\"color: #000066;\">rel<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;stylesheet&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">type<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;text\/javascript&quot;<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;js\/face\/jquery-1.9.1.js&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;vendor\/bootstrap\/js\/bootstrap.bundle.min.js&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">type<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;text\/javascript&quot;<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;js\/face\/layer.js&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;js\/face\/tracking.js&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">src<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;js\/face\/face-min.js&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">script<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;script src=&quot;js\/face\/dat.gui.min.js&quot;&gt;&lt;\/script&gt; --&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;script src=&quot;js\/face\/stats.min.js&quot;&gt;&lt;\/script&gt; --&gt;<\/span><br \/>\n<span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">head<\/span>&gt;<\/span><br \/>\n<br \/>\n<span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">body<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;container&quot;<\/span>&gt;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;row justify-content-center&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;col-xl-10 col-lg-12 col-md-9&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;div class=&quot;card&quot;&gt; --&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;row&quot;<\/span>&gt;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;col-lg-12&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">a<\/span> <span style=\"color: #000066;\">href<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;javascript:returnLogin()&quot;<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;btn btn-primary btn-user btn-block return&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Return<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">a<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;div class=&quot;col-lg-4&quot;&gt;&lt;\/div&gt; --&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;col-lg-12&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;video <span style=\"color: #000066;\">id<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;video&quot;<\/span> preload autoplay loop muted <span style=\"color: #000066;\">style<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;width:100%;object-fit:fill&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span>video&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;canvas <span style=\"color: #000066;\">id<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;canvas&quot;<\/span> <span style=\"color: #000066;\">width<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;100%&quot;<\/span> <span style=\"color: #000066;\">height<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;100%&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span>canvas&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;input type=&quot;button&quot; value=&quot;\u5f00\u59cb&quot; id=&quot;start&quot; onclick=&quot;Shoot()&quot;\/&gt; --&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;div class=&quot;col-lg-4&quot;&gt;&lt;\/div&gt; --&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">div<\/span> <span style=\"color: #000066;\">id<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;face2&quot;<\/span> <span style=\"color: #000066;\">class<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;col-lg-12&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;canvas <span style=\"color: #000066;\">id<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;canvas1&quot;<\/span>&gt;&lt;<span style=\"color: #66cc66;\">\/<\/span>canvas&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span style=\"color: #808080; font-style: italic;\">&lt;!-- &lt;\/div&gt; --&gt;<\/span><br \/>\n&nbsp; &nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #66cc66;\">\/<\/span><span style=\"color: #000000; font-weight: bold;\">div<\/span>&gt;<\/span><br \/>\n&nbsp; <span style=\"color: #009900;\">&lt;<span style=\"color: #000000; font-weight: bold;\">script<\/span> <span style=\"color: #000066;\">type<\/span><span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;text\/javascript&quot;<\/span> th:inline<span style=\"color: #66cc66;\">=<\/span><span style=\"color: #ff0000;\">&quot;javascript&quot;<\/span>&gt;<\/span><br \/>\n&nbsp; &nbsp; $('#fps').hide();<br \/>\n&nbsp; &nbsp; \/\/ \/*<span style=\"color: #404040;\">&lt;![CDATA[*\/<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ &nbsp;var ctx = \/*[[${#httpServletRequest.getScheme() + &quot;:\/\/&quot; + #httpServletRequest.getServerName() + &quot;:&quot; + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]*\/ &nbsp; &nbsp; <\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ &nbsp;window.onload = function() {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;var video = document.getElementById('video');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;var canvas = document.getElementById('canvas');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;var canvas1 = document.getElementById('canvas1');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;var context = canvas.getContext('2d');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;var tracker = new tracking.ObjectTracker('face');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;tracker.setInitialScale(4);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;tracker.setStepSize(2);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;tracker.setEdgesDensity(0.1);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;tracking.track('#video', tracker, {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;camera: true<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;});<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;tracker.on('track', function (event) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;if (event.data.length === 0) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;console.info('\u65e0\u4eba\u8138');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;context.clearRect(0, 0, canvas.width, canvas.height);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;} else {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;event.data.forEach(function (rect) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;context.strokeStyle = '#a64ceb';<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;context.strokeRect(rect.x, rect.y, rect.width, rect.height);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;context.font = '11px Helvetica';<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;context.fillStyle = &quot;#fff&quot;;<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ &nbsp; context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ &nbsp; context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Shoot();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;});<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;}<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;});<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ &nbsp; var gui = new dat.GUI();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ &nbsp; gui.add(tracker, 'edgesDensity', 0.1, 0.5).step(0.01);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ &nbsp; gui.add(tracker, 'initialScale', 1.0, 10.0).step(0.1);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ &nbsp; gui.add(tracker, 'stepSize', 1, 5).step(0.1);<\/span><br \/>\n<br \/>\n<br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;\/\/ };<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;var isCheck = false;<\/span><br \/>\n<br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp;function Shoot() {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;if (isCheck) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;console.log(&quot;\u6b63\u5728\u8fdb\u884c\u4eba\u8138\u8bc6\u522b&quot;);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;return;<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; }<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; console.log(&quot;\u4eba\u8138\u8bc6\u522b\u4e2d...&quot;);<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; isCheck = true;<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; layer.msg('login...');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;var trackerTask = tracking.track(video, tracker);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;var context = canvas1.getContext('2d');<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;\/\/\u628a\u5f53\u524d\u89c6\u9891\u5e27\u5185\u5bb9\u6e32\u67d3\u5230\u753b\u5e03\u4e0a<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;context.drawImage(video, 0, 5, 320, 140);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;var dom = document.createElement(&quot;a&quot;);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;dom.href = this.canvas.toDataURL(&quot;image\/png&quot;);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;\/\/ dom.download = new Date().getTime() + &quot;.png&quot;;<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;dom.click();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;\/\/\u5220\u9664\u5b57\u7b26\u4e32\u524d\u7684\u63d0\u793a\u4fe1\u606f &quot;data:image\/png;base64,&quot;<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;var data = canvas1.toDataURL();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;var b64 = data.substring(22);<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;var path = &quot;\/facemanager\/search&quot;;<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;$.ajax({<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;type: 'post',<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;dataType: 'json',<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;url: path,<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;data: {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imgdata: b64<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;},<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp;success: function (result) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (result.error_code == '0') {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trackerTask.stop();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;layer.open({<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;title: '\u6e29\u99a8\u63d0\u793a',<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;content: '\u6b22\u8fce ' + result.user_info,<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yes: function (index, layero) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trackerTask.run();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;layer.close(index); \/\/\u5982\u679c\u8bbe\u5b9a\u4e86yes\u56de\u8c03\uff0c\u9700\u8fdb\u884c\u624b\u5de5\u5173\u95ed<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trackerTask.stop();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;layer.open({<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;title: '\u6e29\u99a8\u63d0\u793a',<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;content: result.error_msg,<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yes: function (index, layero) {<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trackerTask.run();<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;layer.close(index); \/\/\u5982\u679c\u8bbe\u5b9a\u4e86yes\u56de\u8c03\uff0c\u9700\u8fdb\u884c\u624b\u5de5\u5173\u95ed<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<\/span><br \/>\n<br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;isCheck = false;<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; &nbsp; },<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; &nbsp; error:function(){<\/span><br \/>\n<br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isCheck = false;<\/span><br \/>\n<br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp; &nbsp; &nbsp;})<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; };<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; <\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; function returnLogin(){<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; &nbsp; &nbsp; window.location.href=&quot;login.html&quot;;<\/span><br \/>\n<span style=\"color: #404040;\">&nbsp; &nbsp; }<\/span><br \/>\n<span style=\"color: #404040;\"> &nbsp;&lt;\/script&gt;<\/span><br \/>\n<span style=\"color: #404040;\">&lt;\/body&gt;<\/span><br \/>\n<br \/>\n<span style=\"color: #404040;\">&lt;\/html&gt;<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"http:\/\/weitaoc.com\">\u8ff7\u8def\u7684\u8001\u9f20<\/a> &raquo; <a href=\"http:\/\/weitaoc.com\/?p=538\">h5\u4eba\u8138\u8bc6\u522b<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5e2e\u522b\u4eba\u505a\u4e00\u4e2aapp\u5d4c\u5165\u4eba\u8138\u8bc6\u522b\u7684\u529f\u80fd\uff0c\u4e3b\u8981\u662f\u7528\u4e00\u4e2a\u5f00\u6e90\u7684js\u5e93\uff0c\u8fd9\u91cc\u7eaa\u5f55\u4e00\u4e0b\uff0c\u4ee5\u53ca\u78b0\u5230\u7684\u5751\u3002<\/p>\n","protected":false},"author":1,"featured_media":540,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[61],"class_list":["post-538","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-front-end","tag-61"],"views":15140,"_links":{"self":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=538"}],"version-history":[{"count":6,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":561,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions\/561"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=\/wp\/v2\/media\/540"}],"wp:attachment":[{"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/weitaoc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}