Pages

Tuesday, June 20, 2017

Cursor Control using specific Hand Gesture (OpenCV Libraries in C++):

Overview:

This small software is a semester project for the course Data Structure and Algorithms. The software uses OpenCV libraries in C++ to detect a specific hand gesture and after that it assigns the control of the windows cursor to the movement of hand. In this software the this specific gesture is connecting the tip of index finger with the tip of thumb. In this position you got the control of the cursor. And when you show your palm (gesture vanished) the cursor will be controlled by mouse/touch-pad only. watch the video carefully for better understanding of the idea.

Video Demo:





Platform:

Windows 7 / 8 / 10

Download and Install:

1. Download the project .rar file from the this  dropbox link.

2. Open Project in Visual Studio Professional. Make sure you have Opencv 3.2 libraries installed in C:\ directory and in Environment Variables.

3. Build and Run.

Solution Workflow:
  • Capturing video from webcam
  • Detection of hand and finger tips.
  • Detecting the contour of the largest area.
  • Comparing the radius of the contour with specific value (given in the code).
  • If the radius lies in the range, assign the coordinates of the center of circle to cursor.


A look at Code:

Lets us have a quick overview of the code that what it is actually doing and how it is doing so.
  1.  First of all some necessary libraries and header files to include.
  2.  Global Variables, camframe (frame captured from the webcam), mainframe (processing will be done on this one, it is actually a copy of the camframe).  canny_output (frame in which edges are detected). bsframe (frame after background subtraction if one wants to use bs).
  3. A point which gets the value of your current screen resolution.
  4. ratiox and ratioy varibles for the adjusting the ratio for the webcam image and your current screen (for the movement of cursor) which results in the matching the position of hand in image and cursor on screen.
  5. Some function prototypes.
  6. contour_hull function is where the main image processing comes in.
  7. GetDesktopResolution() is used to find the current screen resolution.


Working of the Code:
  1. Finding the screen resolution.
  2. Capturing frames from webcam in BGR (blue, green, red format) in camframe.
  3. Shift to mainframe (rest of the working on the mainframe).
  4. Converting to Grayscale.
  5. Apply Gaussian Blur (so that only major edges should remain to detect).
  6. Applying a certain threshold (controlled by the user).
  7. Using canny edge detector to find edges.
  8. Finding contours.
  9. Constructing Hulls from contours.
  10. Drawing the Hull of largest area on camframe. 
  11. Drawing the defect points (finger tips).
  12. Drawing square and Circle around the largest Hull.
  13. Finding the radius of the circle and checking it for a certain range.
  14. If it lies in that range (25 < radius < 40) then assign the coordinates of the center of the circle after multiplying it with a proper factor (arise due to difference in webcam resolution and screen resolution)  to the cursor using function SetCursorPos() of windows.h.

Tuesday, January 10, 2017

Arduino 2-in-1 Door Lock System - RFID and PIN

RFID (Radio Frequency IDentification) has many real world applications. One of them is in locking and unlocking systems which scan the RFID tag and compare the information to the already stored information in the database and decide whether to unlock the door or not.


Such a system is designed by our team of four members (I, Hamza Ghaffar, Hamza Sumbal and Muhammad Bisaam) as an end semester project for the course "Electrical Network Analysis".

Monday, May 16, 2016

ChatLAN - A Python Chat Messenger for LAN Using PyQt4 GUI

Overview

This application is designed to enable the users connected to the same Local Area Network(LAN) to chat with each other. It is very simple, easy-to-use and fast app with aesthetic Graphical User Interface(GUI). The users are required to connect to the same LAN using a router or a wifi hotspot to start chatting with other users connected and using this program.

Video Demo: