TechieYan Technologies

Click the Image Smartly using OpenCV

Abstract

Smart Selfie using OpenCV is an Interface which allows us to click selfies without touching our mobiles or any photo capturing devices. So, in this click the images project we have used OpenCV to do the trick for us, where using the OpenCV’s video capture function and some haarcascade files integrated with flask web framework we have made a smart selfie web application where you can click images without touching any keys on your laptop. The photos are later saved on your device specified directory for later use.

Code Description & Execution

Algorithm Description

So, here we are using an OpenCV’s face, eye and smile cascade files to identify facial expressions of a person in the frame and then whenever it detects any smile or blink of an eye, it will capture the image. These cascading classifiers are like models which are trained on several positive similar images. So, in order to detect facial expression or eye of a person we use another cascade. detect Multiscale () function to detect the faces and draw a rectangle box over the face.

Reference links:

https://en.wikipedia.org/wiki/Cascading_classifiers,

https://docs.opencv.org/3.4/db/d28/tutorial_cascade_classifier.html

How to Execute?

Note: Make sure you have checked the add to path tick boxes while installing python, anaconda.

Refer to this link, if you are just starting and want to know how to install anaconda.

If you already have anaconda and want to check on how to create anaconda environment, refer to this article set up jupyter notebook. You can skip the article if you have knowledge of installing anaconda, setting up environment and installing requirements.txt

 
  1. Install the prerequisites/software’s required to execute the code from reading the above blog which is provided in the link above.
  2. Press windows key and type in anaconda prompt a terminal opens up.
  3. Before executing the code, we need to create a specific environment which allows us to install the required libraries necessary for our project.
  • Type conda create -name “env_name”, e.g.: conda create -name project_1
  • Type conda activate “env_name, e.g.: conda activate project_1
  1. After creating an environment, install the required libraries using requirements.txt, i.e., type in pip install -r requirements.txt
  2. Make sure you are in the correct path in your terminal, where you have saved your executable file/folder. E.g.: cd A:\project\AI\Completed\project_name, then press enter.
  3. Run app.py, then you will be redirected to your webpage there you can select he image to detect and click an image.
  4. Press ctrl+c to quit from the terminal

Final Result

Click the Image Smartly using OpenCV final result

Issues you may face while executing the code

  1. We might face an issue while installing specific libraries.
  2. Make sure you have the latest version of python, since sometimes it might cause version mismatch.
  3. Adding path to environment variables in order to run python files and anaconda environment in code editor, specifically in visual studio code.
  4. make sure to change the path where your classifiers are saved.

Click here to download the code and associated files.

+91 7075575787