CarDriving-using-OpenCV
The project is based on Numpy and OpenCV library. This project is based on capturing the movements of the hand and accordingly controlling the steering wheel of the car. The algorithm involves-
- Considering only the skin colour using HSV format.
- Making sure that a portion of the frame consists of the palm and call this portion as our new frame.
- Finding the largest contour in this new frame and its Convexity-Defects followed by its Centroid.
- Finding the finger-tips from the Convexity-Defect and drawing a line from the Centroid ( centre of the palm ) to the fingertip.
- Now, in-order to determine the hand-pose for steering, we find the total number of fingertips on either sides of the centroid by storing them in two variables; Left and Right.
- Depending on the requirements, if Left>Right, then invoke a KeyPress for 'A' or 'LeftArrowButton' else otherwise.
- If the Contour area for the largest contour is less than a threshold, then invoke a keyPress for 'W' or 'UpArrowButton'.
- The invocation for the keyPresses can be done using the Pyautogui library. However, this slows down the performance.
- Therefore, I've used the directkeys.py file which consists of the wrappers for keyboard press. For, more details about this visit https://docs.python.org/3/library/ctypes.html
- The project can further be improved by using a gesture for the 'Brake' keypress. Still working on it.
The GIF file attached in the repo shows a demo version. Note that the code doesn't slow down the process as in the GIF file.