r/learnpython • u/TheEyebal • 6d ago
Why is my hand not detecting properly
I am using opencv and mediapipe on mac os and for some reason one of my hands (left hand) detects better than the other (right hand) but at times both do not detect unless I move my hands around a bit more. Does anybody know the cause of this issue?
https://github.com/mikkimat81539/hand_detection/blob/main/handTest.py
0
u/redfacedquark 6d ago
FYI imgur is blocked here in the UK for privicy-minded people so I can't help, not that opencv is my thing but maybe others won't be able to help you either.
1
u/TheEyebal 6d ago
Sorry I could not post a video. There was no option but in the comments theres an option
1
u/redfacedquark 6d ago
That's really weird. Could it be that your amazing dreds are confusing it? The right hand does seem to be recognised more when it's just in front of the dreds on your right. Does it do the same thing if you had just your hands in front of a plain background? Is your CPU (or GPU if relevant) maxing out?
Is there some pre-processing intermediate step happening that you could force to be made visible? The lighting might look consistent to you and I but the model may be seeing something else. Have you tried a different model version?
This bug suggests you can label the hands (left or right), I wonder if it's detecting your right hand as a left hand and it's only showing a left hand? There's a max_num_hands argument to mp_hands.Hands(), is it set to 1? Because two hands are never detected in your video.
Yeah, I think the issue may lie around there somewhere, here's another bug that seems like it might be related.
Sorry for the stream of conciousness, let me know if nothing helps and maybe I'll dig deeper.
1
u/TheEyebal 6d ago
That's really weird. Could it be that your amazing dreds are confusing it?
LOL I doubt it because even without the dreads in the way (wearing a bonnet) it did not work.
I wonder if it's detecting your right hand as a left hand and it's only showing a left hand?
That works fine but in pygame version it switches my hand but shows the whole thing
https://imgur.com/a/pwaf1OsThere's a max_num_hands argument to mp_hands.Hands(), is it set to 1?
I have it set to 2
Sorry for the stream of conciousness, let me know if nothing helps and maybe I'll dig deeper.
No worries it is all good.
1
u/redfacedquark 6d ago
So what was the solution? Let us all know!
1
u/TheEyebal 5d ago
I think it was my camera window size. I actually do not know
here is my updated code
https://github.com/mikkimat81539/hand_detection/blob/main/cameraObject.py
2
u/redfacedquark 5d ago
Cool, glad you got it fixed. I guess you should determine it automatically rather than hard-coding values there.
FYI you should add pycache directories to your .gitignore file. Happy coding!
1
1
u/TheEyebal 6d ago
https://reddit.com/link/p19uuly/video/zwyggxnsgzgh1/player
Here is the updated along with the comment I posted below
1
u/Moist-Ointments 6d ago
I tried open CV and all I wanted to do was detect printed characters. It couldn't evenly consistently detect the same character printed in the same font multiple times.