 Hello and welcome. Today, we're going to be looking at a program called Face Detect, which is probably in your repositories. I'm running Debian SID here, and it's in my repositories. And I want to say I haven't actually looked at the code for this, but it seems to work exactly like some example Python code. I was using a year or two ago that I found online. So I wouldn't be surprised if it's that exact code. But if you're on a Debian-based system, try sudo apt install face detect. And it should install. I've always had it installed. In fact, let me look at something while I have this up. Let me do sudo aptitude show. And she gave me information. Oh, I don't need a sudo for that about that. So we can see where it comes from. Does it say here that it's a Python script? And it doesn't really say. But I wouldn't be surprised if the code, if it's not Python-based and almost exactly like the example code I saw. Oh, it does say up here that it depends on Python. So yeah, it's probably basically that example code I saw. It does say here also that it's used in programs such as f-gallery, which is going to be one of the videos I'm working on. Actually, why I'm doing this video is because I was going to do a video on f-gallery, which I'm still going to, but I wanted to go over face detect first. Anyway, once you've installed it, again, sudo apt install face detect, you should be able to run it. And the simplest way to run it is type in face detect. And then the name of an image. So I'll give you, I'll give it this image, this first image here, which is a picture of my daughter. It's going to be this one here. So we'll go ahead and run that. And what it does is it gives you the coordinates, it's of a box around the face. So if you can now use that to pipe it into other applications such as image magic or whatever, and you can use that to crop or do whatever you want with the image, but that's going to create a square around the face. To show you what that looks like, you can also do dash o for output, and I'll just call something test.jpeg. And that's going to generate a new image. It still gives me the output here, but that new image right here, when I look at it, you can see it drew a light square around my daughter's face. So that's great. So you have the coordinates drawing the faces around it. Let's run this on a few more of these. Let's go ahead and just remove that test, jpeg. Here we have an image of me, my daughter, and my son. So again, we will say face detect and image, and that's going to be 2019 07 14. This one right here. And here it will give you a list of three different boxes. So that'd be the three different faces. And again, I can do dash o test.jpeg, and I can open that up. And if you can see here, it has drawn boxes around all three of our faces. Now it is not perfect if I was to take this image here of my wife and daughter and give it face detect and that image is only going to give me one face. It's not seeing one of my, I didn't even check which one it did not see. I'll put, we'll just do taste, we'll automatically override. Let's see, I haven't tried this yet. So yeah, probably overrode that. And so yeah, it's seeing my daughter's face, but some reason it's not seeing my wife's face. So it's not perfect, but it works when it works. No face detection is perfect, but I have no clue. Usually there's reasons when it doesn't detect a face, face detection applications. I'm not sure why it's not seeing my wife's there because it's pretty straight on view and a clear image. But another thing, instead of getting a square around the face, I can do dash c. And what that's gonna do is just give you two quarts and that would be the center of the face. So if you're trying to find the center of someone's face, that would be how you did that. Now, again, if we were to show this, you know, the description of this, it says here that it's using Python 3 and OpenCSV, which is what the Python script that I was looking at uses. OpenCSV is used for detecting things and pictures. You can train it to find certain things by giving it example images, but you can use it to detect hands or fingers, eyes or noses and mouth. So I mean, if you actually dove into the Python a little bit more, you can instead of just detecting faces, you can detect and there's already libraries out there for standard things such as, you know, faces and eyes and nose and mouth, which great if you're wanting to, you know, make one of those applications that overlays sunglasses or a hat on somebody, OpenCSV would be the way you'd want to go and using it with Python. A little bit I played around with it was fairly easy. But if you just need to detect faces, this face detect works fairly well. And of course, you can always check out the man file, which isn't very long, you know, the program's fairly simple. Here extract only the biggest face. So I guess if you don't have people in the background and we ignore them, extract only the best matching faces. And I haven't looked into this option yet. Query only, oh, okay. So this, I didn't read about that. I didn't have tried this yet. So if we, now I wish I had an image without a face on it. Give me one second. Okay, I should grab another image that I had. It's just, you know, a river. So I will close that. So from my understanding, and I have not tried this yet. So you guys are about to see me use this for the first time, but dash q, instead of giving you coordinates, you can give it an image. So for example, that it's going to exit one way as opposed to, let me grab this one. It's the tact. Whoops, wasting my time doing that. That image. And so now I should build dollar sign question mark. And if I run this one again and do dollar sign question mark, I'm thinking, there you go. Okay, so for those of you don't know about scripting, dollar sign echo is a variable in your shell it gives the exit code of the last ran command. So what this is doing is it's either going to face a tech with the dash q option is going to give an exit code of either zero or two, and then you can check that. So you can detect if you just want to know, is there a face in this image or not? This is one way to do that. So for example, if I want to, I can say for I in all dot jpeg. So I'm looking at all images and I can do echo dollar sign I and that will list all my files, but now I can run them against face, oops, face detect. I can do dash q and now let me before that, now I'm getting into scripting more echo dollar sign I. So I'll echo out the name and then here I will then echo dollar sign question mark. So now I should get a list of the names and I should get a one or a zero, whether there, if there's a face it should be zero, if, or sorry, I said one or zero, a face if it's zero, two if there's not and I'm going to do dash n for no new lines. So I'm going to do that. I could have put a space in there that would have been nicer. So as you can see this one ends in a two. So that means there's no faces found in that image, which is this image here. As you can see, 643, 643. And theoretically I should be able to do something like this. Actually I don't need two commands. I don't know why I did those two commands. I could do, sorry, I hear with a space that would have been better, maybe even a dash. So there we go. Same thing, cutting out a command. But I'm thinking I should be able to maybe do this. Again, I have not tried this. Ampersand, ampersand, echo, face in, or actually let me do dollar sign, I has a face. I don't know if this is going to work. Dollar sign, I has no faces. Let's run that and see if that works. Yep, it does. Okay, so again for those of you who are not familiar with scripting, again I'm getting a little more in-depth in here than I was originally planning on with this tutorial, is first of all, I'm using a for loop, which means I'm just looping through the name of each file in here that is a JPEG file. I'm running it through face attack with dash Q, which is going to exit one way or another. The ampersand, ampersand means if it's successful, meaning it finds a face, echo out this, and then the ampersand, or sorry, these are ampersands, I don't remember what I just said. And then the two double pipe character is saying, well, it fails if there's not a face. So basically it's like an if, then statement, but in line. So I hope that makes sense. If it doesn't, that's more than you're probably looking for in this tutorial, but if you are familiar with it, that might be very useful. You can sort your images now by ones with faces and not. Anyway, I hope you found that useful. Again, I went a little more in-depth there at the end than I originally did, but face attack, again, it might be in your repositories. It's in my repositories for Debbie and Sid. And if not, you can Google search, openCV Python face attack, and you'll probably find a script that's basically exactly like this one. Or, you know, again, let me go here. This is the homepage of the project. So you can go there and check this out. And that is about it. I do thank you for watching. Please visit filmsbychrist.com. That's Chris McKay. I hope you enjoyed the video. Be sure to like, share, subscribe, comment, support me through Patreon or PayPal, links in the description or on my website under the sports section. I hope that you have a great day.