GithubHelp home page GithubHelp logo

amarlearning / finger-detection-and-tracking Goto Github PK

View Code? Open in Web Editor NEW
392.0 24.0 154.0 25.98 MB

Finger Detection and Tracking using OpenCV and Python

License: MIT License

Python 100.00%
opencv opencv-python numpy python matplotlib object-detection computer-vision hand-detection finger-detection tracking-by-detection

finger-detection-and-tracking's Introduction

Finger Detection and Tracking

Issues

Tracking the movement of a finger is an important feature of many computer vision applications. In this application, A histogram based approach is used to separate out the hand from the background frame. Thresholding and Filtering techniques are used for background cancellation to obtain optimum results.

Tutorial

Finger Detection and Tracking using OpenCV and Python

How to run the code

Go to the Finger Detection and Tracking directory. Then,

  1. Install the dependencies
    pip install pipenv
    pipenv shell
    pipenv install
  2. Run the code with command cd "Finger Detection and Tracking" && python FingerDetection.py
  3. Put your parm over the green squares
  4. Then, press z key to start tracking
  5. Finish program with Esc key.

Demo

Demo GitHub Sectory

Stargazers over time

Stargazers over time

Issues

You can report the bugs at the issue tracker

OR

You can tweet me if you can't get it to work. In fact, you should tweet me anyway.


License

Built with โ™ฅ by Amar Prakash Pandey(@amarlearning) under BSD 2-Clause "Simplified" License

You can find a copy of the License at BSD 2-Clause "Simplified" License

finger-detection-and-tracking's People

Contributors

amarlearning avatar codacy-badger avatar daohanlu avatar dependabot[bot] avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finger-detection-and-tracking's Issues

ValueError issue

I got this after pressing 'z' and I have no idea about this. T T

[ WARN:[email protected]] global C:\b\abs_5e60wdx8td\croots\recipe\opencv-suite_1663884119901\work\modules\videoio\src\cap_gstreamer.cpp (862) cv::GStreamerCapture::isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
QMimeDatabase: Error loading internal MIME data
An error has been encountered at line 1 of : Premature end of document.:
Traceback (most recent call last):
File "c:\Users\20227\Desktop\git_pull\Finger-Detection-and-Tracking\Finger Detection and Tracking\FingerDetection.py", line 175, in
main()
File "c:\Users\20227\Desktop\git_pull\Finger-Detection-and-Tracking\Finger Detection and Tracking\FingerDetection.py", line 160, in main
manage_image_opr(frame, hand_hist)
File "c:\Users\20227\Desktop\git_pull\Finger-Detection-and-Tracking\Finger Detection and Tracking\FingerDetection.py", line 124, in manage_image_opr
contour_list = contours(hist_mask_image)
File "c:\Users\20227\Desktop\git_pull\Finger-Detection-and-Tracking\Finger Detection and Tracking\FingerDetection.py", line 23, in contours
_, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

Unable to detect and track finger tip

Hey,
Firstly there was an error in FingerDetction.py bold line below:
def contours(hist_mask_image):
gray_hist_mask_image = cv2.cvtColor(hist_mask_image, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray_hist_mask_image, 0, 255, 0)
__, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
return cont
The error was findContours function return 2 arguments but code is expecting 3 values. Hence I modifed the code as
cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

No code is working fine, but finger is not detected. Is this due to above change or lightening/other factors?

Program terminates after entering z

Error: Traceback (most recent call last):
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 175, in
main()
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 160, in main
manage_image_opr(frame, hand_hist)
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 124, in manage_image_opr
contour_list = contours(hist_mask_image)
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 23, in contours
_, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
PS C:\Users\29442> & C:/Users/29442/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/29442/Desktop/AUTD/REALsense/Finger-Detection-and-Tracking-master/Finger-Detection-and-Tracking-master/Finger Detection and Tracking/FingerDetection.py"
Traceback (most recent call last):
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 175, in
main()
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 160, in main
manage_image_opr(frame, hand_hist)
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 124, in manage_image_opr
contour_list = contours(hist_mask_image)
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 23, in contours
_, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
PS C:\Users\29442> & C:/Users/29442/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/29442/Desktop/AUTD/REALsense/Finger-Detection-and-Tracking-master/Finger-Detection-and-Tracking-master/Finger Detection and Tracking/FingerDetection.py"
Traceback (most recent call last):
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 175, in
main()
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 160, in main
manage_image_opr(frame, hand_hist)
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 124, in manage_image_opr
contour_list = contours(hist_mask_image)
File "c:\Users\29442\Desktop\AUTD\REALsense\Finger-Detection-and-Tracking-master\Finger-Detection-and-Tracking-master\Finger Detection and Tracking\FingerDetection.py", line 23, in contours
_, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

Code not working

Traceback (most recent call last):
File "FingerDetection.py", line 1, in
import cv2
ModuleNotFoundError: No module named 'cv2'

getting this error: :(

Could you add description HOW TO run the code on your readme?

Hi. Thanks for your nice hand-tracking code.

I think it's better to add following sentences to your README so that the beginners can try your code easily.

## How to run the code
Go to the Finger Detection and Tracking directory.
Then, 

1. Run the code with command `python FingerDetection.py`
2. Put your parm over the green squares
3. Then, press `z` key to start tracking
4. Finish program with `Esc` key.

Regards

Can you give me some steps of instructions how to have it running on Ubuntu?

I just run the FingerDetection.py on the Terminal with these commands:

phyton FingerDetection.py
chmod +x FingerDetection.py
./FingerDetection.py

and got this as result:

import-im6.q16: not authorized cv2' @ error/constitute.c/WriteImage/1037. import-im6.q16: not authorized np' @ error/constitute.c/WriteImage/1037.
./FingerDetection.py: line 4: hand_hist: command not found
./FingerDetection.py: line 5: traverse_point: command not found
./FingerDetection.py: line 6: total_rectangle: command not found
./FingerDetection.py: line 7: hand_rect_one_x: command not found
./FingerDetection.py: line 8: hand_rect_one_y: command not found
./FingerDetection.py: line 10: hand_rect_two_x: command not found
./FingerDetection.py: line 11: hand_rect_two_y: command not found
./FingerDetection.py: line 14: syntax error near unexpected token (' ./FingerDetection.py: line 14: def rescale_frame(frame, wpercent=130, hpercent=130):'

a little question

A great application. I have learned a lot from your tutorial, but I got some questions.

  1. First is that I don't know what is the folder named OpenCV models used for?
  2. Second is how to learn OpenCV efficiently for me as a beginner?

thx : )

Issue

when I press the key z the program goes to not responding

issue

Thank you bro @amarlearning for the code and tutorials:
Getting error while running FingerDetection.py file --

_, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

ValueError: not enough values to unpack (expected 3, got 2)

it is require any dependency file to run or why it is not working in my laptop.

Process

I tried the code but I did not understood what you did in the first part. I just push 'z' but everything goes wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.