‫Well, hello, my friends, and welcome again and this video.
‫We are going to continue with our app and we will create the face detection process method.
‫I will start by initializing the text view and setting it to face detector loading.
‫So I'm displaying just a message for the user telling him that we are processing your image, so face
‫detector
‫in process or we can make processing,
‫processing
‫image.
‫We will create a final string builder because we are going to build a string, adding the builder using
‫the builder view string builder and here a bitmap drobo controllable equal to bitmap drobo and image
‫view the get drop.
‫This image of the bitmap drivable.
‫I'm getting that driveable for and setting it to the image of you.
‫And now we are going to get the input image from the face detector package.
‫So input image.
‫You see, guys, this is Mel Kit vision dot com.
‫Improve image image equal to input image from bitmap, bitmap and zero
‫face detector here.
‫Face detector options.
‫High accuracy I will make as high accuracy option.
‫Equal to new phase detection options.
‫Dot dot builder.
‫Dot set.
‫This is the builder the set performance this then you face options that are option plus enter.
‫We can remove the qualifier face detector.
‫So set per set performance.
‫I need that qualifier here.
‫Sometimes Ed, sometimes understudy will go some errors.
‫But don't worry.
‫Sad.
‫Performance mode do face detector options.
‫Dot performance you can set the fast the accurate for everyone.
‫So I will choose the accurate mode.
‫I will set the landmark mode to phase detector options dot landmark mode all.
‫Then I will set the classification mode to face detector options dot you can classification mode all.
‫So these are the options that you can check and edit when you create a face detector options instance.
‫Okay.
‫So these are the options, the performance, I'm setting it to accurate mode, the landmark mode and
‫the classification mode, all dot enabled enabled tracking dot build.
‫Then I will create a face detector option or study instance detector
‫phase detection
‫dot get client.
‫And what is the client?
‫It's.
‫An option of fire based detector.
‫So the high accuracy option instance that we have created before.
‫Okay, now I will I will continue with the face detector.
‫And start by the task.
‫I would make it as a task list of phase a result equal detector thought process, and we passed the
‫image that we need to process the result.
‫Dot add on success a listener new.
‫New on Success Listener.
‫If it is succeeded, if the task completed successfully, what we will do if faces which is a list of
‫face objects does not equal to zero.
‫So if we have faces, what we will do if the faces dot size equal equal to one.
‫If we have only a one.
‫One phase a builder up and.
‫Faces size plus face texted.
‫This is just an information for the for the user for how many faces that we have detected if the face
‫is.
‫If the faces else, if faces dot size greater than one, then what we will do.
‫We are going to make the same boulder up and faces that size.
‫And here we use the faces because we have more than one.
‫So this is for singular and this is for the plural of the faces.
‫This is for the F.
‫Now I will create a loop that checks for all the faces here.
‫A for loop face phase inside the faces for each loop for each face inside a face list.
‫Create an instance of of class face called face small f what we will do.
‫We are going to process every face itself, every single face.
‫Processing that every single face.
‫How to do that?
‫Where have a for loop looping through all the faces inside the faces list that we have detected.
‫So for example if we had detected ten faces so we are going to loop through all these ten faces.
‫So face get tracking ID float rotation y equal to face dot get tracking ID.
‫Or get had
‫had a y
‫float rotation of z equal to face dot.
‫Get head and forth zet why we are using this this is for head is rotated to the right rotation rotation
‫y degrees and this is for detecting the head is tilted sideways rotate as a rotation Z degrees.
‫So we are storing inside a variable rotation z the value of the angle, how the head is tilted sideways.
‫So this is for the head is rotated to the right by how many degrees and this is how the head is tilted
‫sideways.
‫Now the builder band
‫one face tracking ID.
‫This is the ID.
‫And I'm going to close the bracket, the angled bracket,
‫and I will go to another line.
‫Felder so happened to
‫had a rotation.
‫We are going to use these data that we have gathered and display them into a readable format through
‫rotation through.
‫Right.
‫And I'm getting a string dot format.
‫What we are going to format for the string that that the the decimal.
‫So I need only two numbers after the floating point.
‫So what we will make, we are going to format this text by getting only the two numbers after the point.
‫And this is the format.
‫This is the correct format.
‫This is how we format the text rotation y and plus this degree.
‫Degrees.
‫Like this and new line.
‫I will copy this.
‫Three had a rotation had tilted sideways.
‫Sideways by rotation by using the rotation z.
‫This is the variable that we have get from the head ruler angle.
‫Degrees and.
‫And.
‫Now.
‫The probability of smiling, smiling, smiling.
‫Throwback velvet here.
‫Tilting.
‫Tilting and rotation and rotating probability.
‫We have calculated and get it getting the the probability of tilting and rotating the head and smiling
‫probability in this section.
‫So if the face doth get smiling, probability greater than zero,
‫what we will do?
‫We are going to create a float.
‫Smiling probability.
‫Equal to faze dot.
‫Get smiling probability and builder dot append.
‫Four.
‫These are the data that we are appending to the string builder for every smile, for every face that
‫we have in the faces list.
‫So remember what we are doing.
‫I am getting here.
‫The string, the string, that format.
‫Again, I need to format the text and getting only the two two decimals to numbers after the decimal.
‫And smiling.
‫Probability
‫plus.
‫Plus.
‫The.
‫Here.
‫This is how we detect the smiling probability.
‫Now let's.
‫What we are going to do next is to detect if the left eye is opened or the right eye is opened, how
‫to do so the same way as smiling probability I will use left eye
‫open
‫probability
‫face dot get not smiling, get a left eye open probability.
‫If it is greater than zero, then make a float named as left eye left eye and append to the string bolder.
‫The left eye displayed this in the same way I'm going to use for that right.
‫I get a right.
‫You can see how many data you can, how much data you can get get landmark the contour or bounding box
‫or landmark contour.
‫ID said y smiling left.
‫And so if the right I open probability, then I will create a right eye and here the right eye.
‫This is how we calculate the probability and how we detect if it is, if the faces are smiling or if
‫we have a left eye or right eye open.
‫Okay.
‫This is for the for loop.
‫After getting the four out from the for loop.
‫What we will do, we will show the detection.
‫Okay.
‫So this is show detection method that we are going to create.
‫Next,
‫the builder and the true.
‫Okay.
‫And here, don't miss to add the builder dot app.
‫And I bend that
‫between the lines.
‫Between every every phase has been detected.
‫Now.
‫On failure.
‫I will add here the result does not add on failure.
‫Listener view.
‫On Failure.
‫Listener.
‫If the task failed, with an exception, what we will do, we will create a string boulder.
‫Boulder one equal to new string boulder.
‫And I will display the message by using this boulder builder on the append.
‫Sorry.
‫There is some error.
‫Is an error
‫and show the detection.
‫This is the method that we are going to create.
‫Show detection belt.
‫This is the second part of meter type builder and the false third parameter.
‫So this is.
‫How we finish our loop.
‫Now I am going to create a new method here called Show Detection Public.
‫And this is the final method void show detection.
‫It took into the parameter.
‫Final string title.
‫Final String Builder.
‫Builder Boolean success.
‫And in this video we have finished the method.
‫Face detection process.
‫And in the next video we are going to create the show detection.
‫But.