Also, ifyouenjoythisvideo, makesuretoletmeknowdownbelowsothat I cancreate a parttwotothisvideowhere I usefacerecognitioninordertodeterminewhoisin a pictureanddisplaytheirnamenexttotheirface.
Let's getstartednow.
Inorderaccomplishedthisfacerecognition.
We'regoingtobeusing a librarycoldface a phdotJsYoucanseeoverhereontheright, andthisis a wrapperaround.
There's goingtobe a linkinthedescriptionbelowwhereyoucandownloadthislibraryfromAlso, you'regonnaneedtodownloadthemodelsthatyou'llbeusingforyourfacedetectionwhenwegettothemodelsection.
I justwanttocreate a blankhtmlpagehereandinsideofthiswewanttoput a videoelementbecausethisisgoingtobewherewerenderourwebcamwherewedoourrealtimefacedetection.
It'llloaduprighthere, andthisisjust a livepreviewofmyWebcamandmaybeslightlydelayed, butthat's justbecauseit's goingthroughthebrowserasopposedtogoingdirectlyintomyrecordingsoftware.
Sonowoncewehavethatdonewhat's alsoincludeourface a p I library, whilewe'reatitsowecoulddo a scripthere.
Wewantedtoforthisoneaswell, andwewantthisface a P I, andwewanttomakesurethatthisisdefinedaboveournormalscriptsothatitgetsloadedbeforeweactuallyrunourscript.
Nowwecanworkonactuallysettingupthefacedetection, andthisisactuallyincrediblystraightforwardtoDioWewanttodoiswewanttodo a setintervalsothatwecanrunthecodeinsideofthismultipletimesin a row.
Wewanttomakesureit's in a sinkingdysfunctionbecausethisisgoingtobeanasynchronouslibrary, andallweneedtodoinsideofhereisgetourdetection.
Sowe'regoingtojustsaydetectionisgoingtobeequaltoawaitingourfaceFBIorjust a face a p i dotdetectallfaces.
Andwe'regoingtodothis, forexample, every 100 millisecondsandwhatwewanttodoinsteadofhereiswewanttopasstheelement, whichinourcase, is a videoelementaswellaswhattypeoflibrarywe'regoingtousetodetectthefaces.
Inourcase, we'reusingthetinyfaceCPswell, safe a c p i.
Also, wewanttomakesurewematchourcanvastothisdisplaysizesowecansayface a P i dotmatchdimensionsdotmatchdimensionsandweputitinourcanvasaswellas a displaysize.
Makesureyouspelldimensionsproperly.
Andnowifwesaythatweshouldgetmuchbetterdetectionoveronthesideandifwejustgiveit a second, youcanseethatit's detectingmyface.
Andas I moved, it's followingmearound.
Italsohas a number, whichishowpercentsureitis.
Soit's about 90% surethatthisis a facewhichisperfect.
Sonowwecanactuallystartdrawingevenmoredetails.
Wecangointotheface a p i dotdrawagain, andthistimewecandrawtheWayneMarkssowecansayyouarefacedlandmarks.