Thesearecamerasthathave a sortofextraseparatemechanismonthesideofthem, whichwastherangefindermechanism.
Now, thiswasalldonewithoptics, andthewayitworksisyoubasicallysee a viewpointofwhatyou'relookingat, andthenyouget a kindoflike a ghostimagethatshiftedtooneside.
Normally, whatyouhavetodoischange a dialontherangefindermechanismtobringthetwoimageskindoflyingontopofeachother.
Sosomeofthemostsomeoftheearliestmechanismsfordoingactive, ortofocusedusedsomething a bitlikesonar, soitwouldsendout a pingfromthecamera, anditwouldbasicallytimehowlongittooktohitsomethingandbounceback, justlikethewaysonoworks.
Anditwouldusethattoworkout a distancethatyoucouldthenusetofocusitandseekingyousound.
Whatwe'reactuallygonnaconcentrateontodayisthepassiveapproachishowdoWeactuallyfocus a camerawhenwe'renotsendingoutlightorsound, sowe'rejustusingonthelightthat's comingintothelenstodothefocusing.
Soifwehave a raycomingfromhereandwesortoffollowitthrough, so I'm notgonnadrawthecomplicatedopticshere, yourlightraysthatgothroughthelensfalluponanautofocussensor.
Sothisisreallyessentially a sortofone D stripofphotodiedsosetofpixels.
Essentially, it's like a littleimagesensorthatthelighthitshere.
Nowthetrickbehindfacedetectionisyoumeasuretopartsoflightsoyouwouldactuallyhave a secondsensor.
Sothissecondlightrayhereactuallyhitsus a differentsensor.
Somathematicallyyoucandosomethingcalledcrosscorrelationthere, whichis a wayofessentiallylookingathowtobestmatchtwosignalsthatareoffsetfromeachotheronwhatthatgivesyouis a distance.
Mostsystemsusethiskindofpeopledomostisso a lotofsystemswillusebothtosay a lotofsalonswilluseboth.
Andthereasoniswhenyou'refocusingthroughtheviewfinder, ittendstousefacedetectionbecauseit's usingtheopticsofthethelenssystemtosteal a bitofthelightandpassittothesepairsofautofocussenses.
Soyouget a onepairforeachwaterfocusregion, butyoucanonlydothatwhenyou'relookingthroughtheviewfinder.
Soifwejustgothroughanimage, a pairofpixelsat a time, andcalculatethedifferencebetweenthemwhenwekindofmaximizethatthetotalofallthosedifferences, thenwe'reinprettygoodfocusbecausewegotthemostcontrastwecanhave.
Sothat's whatthissimpleexampleherewilldigon.
Thislinehereisjustcalculatingthedifferencebetweenthem, So I'm justcalculatingdifferencesintheexdirection.
Inthecontrasthere, we'rejustgoingtodo a neighboringexpixels.
Okay, sowecouldcalculatealltheneighboring.
Whypixelsaswell.
Butjusttokeepitsimple, I'm doingthis.
Wecoulduseprobably a bettermeasureofcontrast.
Sosomethinglike a sub l operatororsomethingelsethat's goodfordetectingedges.
Butjustas a verysimpleexample, Let's justmeasurethedifferencebetweenneighboringpixelsandseehowthatchangesaswegooutoffocus, which I'llsimulatebyblowingtheimage.
Soif I runthis, itwillmoveovertheimageittakes a littlewhilebecause I'm movingacrossallthepixels, weget a numberhere, whichisessentiallythetotalof a ll.
Ifyou'rerunningthisover a wholeimage, you'regonnagetissues.
Soquiteoften, Forexample, onyourphone, youcanyoucanessentiallyselect a regiontofocusonsoyoucanpress a regiononyourphoneoryoucanselect a focuspointonliveyouorsomethinglikethat.
Well, thatwilldoisitwillonlycalculatethisdifferenceacross a particularregionofanimage.
Theotherthingtosay, I suppose, iswe'vegonethrougheverypixelintheimagehere, butactuallyyouwouldprobablyonlysortofsubsampletheimageinordertomakeitquicker.
Thecontrastdetectionworkswithoutfancyoptics, anditworkson a liveviewwhereyoucanjustseetheimage, butit's a bitslowerbecauseyouhavetodothishuntingapproach, Sowouldn't itbeniceifwecoulddosomekindoffacedetection?