How to Detect Only Hand Movement using OpenCV HSV and Background Subtraction? - python

I am having difficulty creating a detector for hand and its movement due to the program didn't run when I put BgSubtraction and HSV codes altogether. It can only run with HSV code with the following result
The code is in python and I got it from OpenCV doc with a few modifications
here's the link
What I want is for the camera to detect only the hand model without noise and the background, I read it in a journal and it needs HSV Thresholding and Background Subtraction. Is it possible? Any solution?
Thank you.

Related

Remove Background image opencv

Please hold before downgrading the Question. I am not looking for a segmentation or detection algorithm/library.
I have also seen this Post
Remove background of the image using opencv Python
But the solution marked correct is again what I don't want. I want exactly
What are the ways to Subtract the BACKGROUND image from FOREGROUND?
Input:
Background Image without vehicle like the above post
Foreground Image with the vehicle
Output:
Vehicle
Be kind and thanks for the help.
Link to the Input Images Input
Link to the Output Output
OpenCV background Subtractor models Documentation
After a lot of testing, Videos based MOG/MOG2 works better than single Image based background subtraction with KNN.
This article solved my problem

ocr image cleansing with python opencv

I'm currently learning about computer vision OCR. I have an image that needs to be scan. I face a problem during the image cleansing.
I use opencv2 in python to do the things. This is the original image:
image = cv2.imread(image_path)
cv2.imshow("imageWindow", image)
I want to cleans the above image, the number at the middle (64) is the area I wanted to scan. However, the number got cleaned as well.
image[np.where((image > [0,0,105]).all(axis=2))] = [255,255,255]
cv2.imshow("imageWindow", image)
What should I do to correct the cleansing here? I wanted to make the screen where the number 64 located is cleansed coz I will perform OCR scan afterwards.
Please help, thank you in advance.
What you're trying to do is called "thresholding". Looks like your technique is recoloring pixels that fall below a certain threshold, but the LCD digit darkness varies enough in that image to throw it off.
I'd spend some time reading about thresholding, here's a good starting place:
Thresholding in OpenCV with Python. You're probably going to need an adaptive technique (like Adaptive Gaussian Thresholding), but you may find other ways that work for your images.

How to make shadowed part of background count as background (picture below) with OpenCV in Python?

I am very new to OpenCV(and to StackOverflow). I'm writing a program with OpenCV which takes a picture with an object (i.e. pen(rice, phone) put on paper) and calculates what percent does the object make of the picture.
Problem I'm facing with is when I threshold image (tried adaptive and otsu) photo is a little bit shadow around edges:
Original image
Resulted picture
And here's my code:
import cv2
img = cv2.imread("image.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
b,g,r = cv2.split(img)
th, thresh = cv2.threshold(b, 100, 255, cv2.THRESH_BINARY|cv2.THRESH_OTSU)
cv2.imwrite("image_bl_wh.png", thresh)
Tried to blur and morphology, but couldn't do it.
How can I make my program count that black parts around the picture as background and is there more better and easier way to do it?
P.S. Sorry for my English grammar mistakes.
This is not a programmatic solution but when you do automatic visual inspection it is the first thing you should try: Improve your set-up. The image is simply darker around the edges so increasing the brightness when recording the images should help.
If that's not an option you could consider having an empty image for comparison. What you are trying to do is background segmentation and there are better ways than simple color thresholding they do however usually require at least one image of the background or multiple images.
If you want a software only solution you should try an edge detector combined with morphological operators.

OpenCV pixel lump detection (detecting white pixel lump)

So, I have the following Image
I want to detect the white lump in that image ignoring the thin white line.
I need help with the approach that I can use to detect it with OpenCV python.
Please help, I don't want the code but need a direction on how to go about it.
Thank you
I suggest the following solution:
Make it binary.
Perform opening morphological transformation.

Counting people in an image using opencv and python

I am new to openCV and python both. I am trying to count people in an image. The image is supposed to be captured with an overhead camera or the way a CCTV camera is placed.
I have converted the colored image into binary image and then inverted the binary image. Then I used bitwise OR on original and inverted binary image so that the background is white and the people are colored.
How to count these people? Is it necessary to use a classifier or can i just count the contours ,if yes then how to count them?
Plus there are some issues with the technique I'm using.
Faces of people are light in color so sometimes only hair are getting extracted.
The dark objects other than people also get extracted.
If the floor is dark it won't give the binary image that is needed.
So is there any other method to achieve what I'm trying to do here?
Not sure but it may worth to check there.
It explain how to perform face recognition using openCV and python in pictures and extand it to webcam here, it's not quite what your looking for but may give you some clue/

Categories

Resources