GUI Code
Over here Python script that creates a graphical user interface (GUI) using the Tkinter library. The GUI displays a label, an image, and a button. When the button is clicked, it calls the runvirtualmouse() function. runvirtualmouse() function: This function creates an instance of the GestureController class and starts it. The exact implementation of the GestureController class and its functionality is not provided in the code snippet.
Python3
def runvirtualmouse(): gc1 = GestureController() gc1.start() root = tk.Tk() root.geometry( "300x300" ) label = tk.Label(root, text = "Welcome to Virtual Mouse" , fg = "brown" ,font = 'TkDefaultFont 16 bold' ) label.grid(row = 0 , columnspan = 5 , pady = 10 , padx = 10 ) image = ImageTk.PhotoImage(Image. open ( "tap.png" )) img_label = tk.Label(image = image , width = 100 , height = 100 , borderwidth = 3 , relief = "solid" ) img_label.grid(row = 1 , columnspan = 5 , pady = 10 , padx = 10 ) start_button = tk.Button(root,text = " Track Mouse" ,fg = "white" , bg = 'green' , font = 'Helvetica 12 bold italic ' ,command = runvirtualmouse , height = "4" , width = "16" ,activebackground = 'lightblue' ) start_button.grid(row = 3 ,column = 2 , pady = 10 , padx = 20 ) root.mainloop() label.geometery( "400X300" ) root.geometery(row = 0 ,columnspan = 5 , pady = 10 ,padx = 10 ) root.main loop() |
Output:
1. When run the .py file: GUI will be open
2. Click on Track Mouse Button: Webcam will be open to capture hand gestures.
3. No action performed : When all the five figures up then the cursor will stop moving.
4) Cursor Moving: When both index and multiple fingers up.
5)Left Button Click: Lower the index finger and raise the middle finger.
6)Right Button Click: Lower the middle finger and raise the index finger.
7)Brightness Controll: Make pinch of index finger and thumb and raise all the rest of fingers and move hand horizontally.
8)Volume Control: Make pinch of index finger and thumb and raise all the rest of fingers. Move hand vertically.
9)Scrolling Vertically: In left hand, make pinch of index finger and thumb and raise all the rest of fingers and move hand vertically.
10)Drag & Drop: Lower the all the fingers after selecting element then drag the the element and drop it wherever we want.
11)Double Click: Join/closed both index finger and middle finger then double click action perform.
Real-Time AI Virtual Mouse System Using Computer Vision
AI Virtual Mouse is a software that allows users to give inputs of a mouse to the system without using the actual mouse. To the extreme, it can also be called hardware as it uses an ordinary camera. A virtual muse can usually be operated with multiple input devices, which may include an actual mouse or computer keyboard. The virtual mouse uses a web camera with the help of different image processing techniques. Using figures detection methods for instant Camera access and a user-friendly interface makes it more easily accessible. The system is used to implement a motion-tracking mouse, a physical mouse that saves time and also reduces effort. The hand movements of a user are mapped into mouse inputs. A web camera is set to take images continuously. Most laptops today are equipped with webcams, which have recently been used in security applications utilizing face recognition. To harness the full potential of a webcam, it can be used for vision-based CC which would effectively eliminate the need for a computer mouse or mouse pad. The usefulness of a webcam can also be greatly extended to other HCI applications such as a sign language database or motion controller.
Software Specification:
- Python Libraries: Various Python libraries like OpenCV, NumPy, PyAutoGUI, and TensorFlow can be used for building the Al virtual mouse system.
- Open CV: This library is used for image and video processing, which can be used for hand detection and tracking.
- NumPy: NumPy is used for numerical computations, and it is used to process the captured images.
- PyAutoGUI: PyAuto GUI is used to control the mouse movements and clicks.
- Mediapipe: A cross-platform framework for building multi-modal applied machine learning pipelines.
- Comtypes: A Python module that provides access to Windows COM and .NET components.
- Screen-Brightness-Control: A Python module for controlling the brightness of the screen on Windows, Linux, and macOS.
Detecting which Fingure is Up and Performing the particular Mouse Function
Over here we are detecting which finger is Up using the tip ID of the respective finger that we found using the MideaPipe and the respective figure that we found using the Mediapipe and the respective coordinates of the fingers that are up, according to that we found using the MediaPipe and the respective co-coordinates of the figures that are up and according to that the particular mouse function is performed.
Mouse Functions depending on the Hand Gestures and Hand Tip Detection. Using Computer Vision for the mouse cursor moving around the system window. If the index fingure is up with tip Id = 1 or both the index finger with tip Id = 1 and the middle finger with tip Id =2 are up, the mouse cursor is made to move around the window of the computer using the AutoPy package of Python.