OpenCV Python Tutorial Face Recognition Face Blur | Blur out everyone's face in a live video!

Поделиться
HTML-код
  • Опубликовано: 13 июл 2024
  • Welcome to my first tutorial on using OpenCV in Python! I will show you how to use Face Recognition and blur out everyone's face in a live video! Very cool. Thanks for coding with SalteeKiller!
    If you like these videos, please subscribe so that you will be notified when the next video goes up.
    Source Code:
    github.com/107124/facial-blur
    Need some Coding Merchandise to wear?
    www.salteekiller.store
    My Portfolio Website: kst-bottega-react-portfolio.h...
    WATCH NEXT:
    Build a Weather App in 25 minutes:
    • How to CODE a WEATHER ...
    WHY we need YOU to code:
    • HOW TO CODE || Trailer...
    Python 2021: How to Create a Countdown Timer:
    • How to code a Timer in...
    Python 2021: How to translate into Morse Code Tutorial:
    www.youtube.com/watch?v=ecxAQ
    Python 2021: Simple Calculator in 4 lines of code:
    • How to code a Calculat...
    Python 2021: How to create a Histogram or Bar Graph:
    • How to code Graphs in ...
    Python 2021: How to use for-loop's:
    • How to code for loops ...
    Python 2021: How to do the FizzBuzz challenge:
    • How to code FizzBuzz i...
    #python
    #coding
    #codingtutorials
    #beginners
    #simple
    #salteekiller
    #openCV
    #facerecognition
    #facialrecognition

Комментарии • 19

  • @Bilal_chaim
    @Bilal_chaim 2 года назад +1

    Thanks 👍

  • @volkinaxe
    @volkinaxe Год назад

    been looking for something like this but ez to use something that has a user inter face

  • @nkofr
    @nkofr 9 месяцев назад +2

    Nice, how to blur only one specific person in a group of people?

    • @SalteeKiller
      @SalteeKiller  7 месяцев назад +2

      1. Detect faces in the image or video.
      2. Apply a blur effect to all detected faces.
      3. Identify the faces of individuals who should remain unblurred.
      4. Keep those specific faces unblurred or apply a milder blur effect.
      Here’s a high-level approach using Python and OpenCV:
      1. Face Detection:
      Use a face detection model (like Haar cascades or deep learning-based face detectors available in OpenCV or other libraries) to locate faces in the image.
      2. Blur Faces:
      Apply a blur effect (Gaussian blur, pixelation, etc.) to the detected faces using OpenCV’s image processing functions.
      3. Identify Unblurred Faces:
      Identify the faces of individuals who should remain unblurred. This might involve user input, a database of known faces, or some form of facial recognition if applicable.
      4. Keep Specific Faces Unblurred:
      For the faces of individuals who should not be blurred, exclude them from the blur process or apply a different, less intense blur effect.
      Here’s a simplified example using OpenCV and face detection to blur faces in an image:
      import cv2 as cv
      # Load the image
      image = cv.imread('path_to_your_image.jpg')
      # Load pre-trained face detection model
      face_cascade = cv.CascadeClassifier(cv.data.haarcascades + 'haarcascade_frontalface_default.xml')
      # Detect faces
      gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
      faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
      # Blur all detected faces
      for (x, y, w, h) in faces:
      face = image[y:y+h, x:x+w]
      blurred_face = cv.GaussianBlur(face, (99, 99), 30) # Apply Gaussian blur; adjust parameters as needed
      image[y:y+h, x:x+w] = blurred_face
      # Show the image with blurred faces
      cv.imshow('Blurred Faces', image)
      cv.waitKey(0)
      cv.destroyAllWindows()
      To selectively keep certain faces blurred, you’ll need additional logic to identify and handle those specific faces differently within the loop. Perhaps adding an image of the people who want to be blurred, and if the image matches someone in the video, then blur. I’m sorry I don’t have quite enough time to build out that entire program but that should be a great start!
      Remember, handling face blurring and unblurring requires careful consideration of privacy concerns and the consent of individuals whose faces are being processed.

    • @nkofr
      @nkofr 7 месяцев назад

      @@SalteeKiller Thank you for this very detailled answer!!!!

  • @FQXZ7
    @FQXZ7 7 месяцев назад +1

    thank u , Is there a way to blur everyone faces except certain people? like people who do not mind appearing in public, Is it possible to make an option to remove the blur for them?

    • @SalteeKiller
      @SalteeKiller  7 месяцев назад +1

      1. Detect faces in the image or video.
      2. Apply a blur effect to all detected faces.
      3. Identify the faces of individuals who should remain unblurred.
      4. Keep those specific faces unblurred or apply a milder blur effect.
      Here’s a high-level approach using Python and OpenCV:
      1. Face Detection:
      Use a face detection model (like Haar cascades or deep learning-based face detectors available in OpenCV or other libraries) to locate faces in the image.
      2. Blur Faces:
      Apply a blur effect (Gaussian blur, pixelation, etc.) to the detected faces using OpenCV’s image processing functions.
      3. Identify Unblurred Faces:
      Identify the faces of individuals who should remain unblurred. This might involve user input, a database of known faces, or some form of facial recognition if applicable.
      4. Keep Specific Faces Unblurred:
      For the faces of individuals who should not be blurred, exclude them from the blur process or apply a different, less intense blur effect.
      Here’s a simplified example using OpenCV and face detection to blur faces in an image:
      import cv2 as cv
      # Load the image
      image = cv.imread('path_to_your_image.jpg')
      # Load pre-trained face detection model
      face_cascade = cv.CascadeClassifier(cv.data.haarcascades + 'haarcascade_frontalface_default.xml')
      # Detect faces
      gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
      faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30))
      # Blur all detected faces
      for (x, y, w, h) in faces:
      face = image[y:y+h, x:x+w]
      blurred_face = cv.GaussianBlur(face, (99, 99), 30) # Apply Gaussian blur; adjust parameters as needed
      image[y:y+h, x:x+w] = blurred_face
      # Show the image with blurred faces
      cv.imshow('Blurred Faces', image)
      cv.waitKey(0)
      cv.destroyAllWindows()
      To selectively keep certain faces unblurred, you’ll need additional logic to identify and handle those specific faces differently within the loop. Perhaps adding an image of the people who want to be unblurred, and if the image matches someone in the video, then don’t blur. I’m sorry I don’t have quite enough time to build out that entire program but that should be a great start!
      Remember, handling face blurring and unblurring requires careful consideration of privacy concerns and the consent of individuals whose faces are being processed.

  • @deltaxsingh
    @deltaxsingh Год назад +1

    Anything like this for all text inside a video? Trying to remove all personal information from multiple videos

    • @SalteeKiller
      @SalteeKiller  Год назад

      Yes you can do that. You can do the same thing in this video, but you’ll also include another library that detects text. So look up the “pytesseract” library. It combines opencv and detects texts in the photo/video.

  • @creativeguyty
    @creativeguyty Год назад +1

    Hey Saltee, I'm trying to find a software engineer to build me a program that will allow me to upload a lot of videos and photos and have it automatically blur the face for me. Any recommendations?

    • @SalteeKiller
      @SalteeKiller  Год назад

      You can find one pretty quickly on Upwork. Just post the project and details there and you’ll get people offering work: www.upwork.com/hire/?SEM_GGL_US_NonBrand_Marketplace_DSA&campaignid=348930905&matchtype&device=m&partnerId=EAIaIQobChMIyq7_7pjZ-QIVpMiUCR0ucQ3eEAAYASAAEgJwCvD_BwE&gclid=EAIaIQobChMIyq7_7pjZ-QIVpMiUCR0ucQ3eEAAYASAAEgJwCvD_BwE

    • @granatapfel6661
      @granatapfel6661 11 месяцев назад

      Plate recognizer with docker im using it

  • @ArmadusMalaysia
    @ArmadusMalaysia 2 года назад +1

    Any idea how I can do this recording live on my phone?

    • @SalteeKiller
      @SalteeKiller  2 года назад +1

      First, install the OpenCV library in Python; pip install opencv-python.
      Download and install the IP Webcam application on your smartphones.
      After installing the IP Webcam app, make sure your phone and PC are connected to the same network. Run the app on your phone and click Start Server.
      After that, your camera will open with an IP address at the bottom. Copy the IP address as we will need to use it in our Python code to open your phone’s camera.
      thecleverprogrammer.com/2021/01/05/use-phone-camera-with-python/#:~:text=First%2C%20install%20the%20OpenCV%20library,phone%20and%20click%20Start%20Server.

    • @ArmadusMalaysia
      @ArmadusMalaysia 2 года назад +1

      @@SalteeKiller thanks for the detailed answer! So basically still needs to connect to the PC, right? I was looking for something like an offline app to just blur or pixelate while I'm recording anything.

    • @SalteeKiller
      @SalteeKiller  2 года назад

      @@ArmadusMalaysia Yes you gotta connect to your computer because that’s where your code is. “You can’t call someone if they don’t have a phone”. Same thing. Why would your phone camera auto blur if there’s no code telling it to. So unless you make an official iPhone app or some kind of api database it’s just not going to do anything.

    • @ArmadusMalaysia
      @ArmadusMalaysia 2 года назад +1

      @@SalteeKiller I see. Well, that makes me wonder how some apps allow us to add a variety of masks following, our face while we record ourselves. The problem I have with those apps is they don't have blur features following our face.

    • @SalteeKiller
      @SalteeKiller  2 года назад +1

      @@ArmadusMalaysia yes they just don’t the api to find the facial parameters it requires to find and blur the face. But it’s ideas like this that you should always look for. There’s a problem, so figure out how to create something that fixes that’s problem! The classes i teach at boot camps i try to challenge the students over the weekends to find something like that and see if they can come up with a solution. Then on Mondays if anyone did do it, would share what they created. Keep at it!