How to Save ONLY ONE face picture using OpenCV? - python

What am I trying to do?
Listen to camera video
Detect faces
Save only faces to folder
The problem:
I have done all of those things above EXCEPT it gives me bunch of same person faces because it checks it on every frame it captures and gives as new face when it's the same person.
I want the script to understand that it's the same person and skip it. (of course it depends on accuracy overall, but that's okay, as long as it's not giving me 60 files of same face a second)
So I was thinking to somehow use face_verify within the same library, but couldn't make it working quickly and decided to ask first instead of wasting time on something what most likely not gonna work.
Any suggestions? Hopefully described it well, also didn't find any duplicates of this question.
Thanks in advance

It depends on what you are using, face-detection or face-recognition.
Face-detection will just detect faces and return bounding box for each frame. In this case you can use any simple tracking algorithm (like SORT) which will give tracking ID for each bounding boxes in each frame. This way you can ensure to save only 1 face for each tracking ID
In case of Face-recognition, it's all the more easier as each detected face has an associated label (similar to a tracking ID in the above approach). So you can simply save face-images based on labels (1 image per label)

Related

Object Detection using opencv python

fig:Shoe in the red circle is to be detected
I am trying to create a python script using cv2 that can recognize the shoe of the baller and determine whether the shoe is beyond, on or before the white line(refer to the image).
I have no idea about any kind of approach to use, what kind of algorithms might be helpful. Need some guideline, please help!
(Image is attached)
I realize this would work better as a comment because it isn't a full answer, but I don't have enough rep yet to leave comments, haha.
You may be interested in OpenCV's Canny Edge detection algorithm:
http://docs.opencv.org/trunk/da/d22/tutorial_py_canny.html
This will allow you to find shapes within your image.
Also, you can find similarly colored blobs using SimpleBlobDetector:
https://www.learnopencv.com/blob-detection-using-opencv-python-c/
This should make it fairly easy to detect the white line.
In order to detect a more complex object like the shoe, you'll probably have to make something like a object detection cascade file and use a CascadeClassifier to find it:
http://docs.opencv.org/2.4/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html#cascade-classifier
http://johnallen.github.io/opencv-object-detection-tutorial/
Basically, you take a bunch of pictures to "teach" what the object looks like, and output that info to a file that a CascadeClassifier can use to detect objects in input images. It may be hard to distinguish between different brands of shoe though, if you need it to be that specific. Also, you may need to adjust the input images (saturation, brightness, etc) before trying to detect objects in order to get good results.

Detecting a table in an image

Im fairly new to image processing so I was looking for some help on where to start or some input on how to do this if you know the answer.
What I would like to be able to do is take an image with a table in it, and be able to detect the table. Id even be happy to settle with detecting many planar surfaces as I can sift through that part easily. What I get right now with openCV when I do some contour detection is:
Original,
Contour Detected
As you can see this may have potential with some sophistication maybe, but it missed the bulk of the table. Im currently working in Python for this as well.

How do i implement a people counter in a video

I want to count number of people going up or down using a reference line let's say in the middle of that video. Now, How do I actually implement it using python and openCV.. I saw a lot of videos showing the people counter but no one has the method or instructions on how to exactly do that.. I don't need code.. Plz just tell me the method..
Btw here is something that i tried.. But this isn't working:
import cv2
Take a look at the detailed breakdown here, as pointed out in comments by leaf, but basically you can use the OpenCV2 built-in methods to perform pedestrian detection. OpenCV ships with a pre-trained HOG + Linear SVM model that can be used to perform pedestrian detection in both images and video streams.
To separate the Up & Down counters I would split each frame on the vertical line before running the detection on each half separately. You can count the number of people going in the given direction in a single frame by a simple len(contours) while processing that frames direction half.
To track the total number of people going in a given direction you will need to detect the motion of each contour across the frame and only add a new entry to the count when a new contour is created near the entry edge of the direction frame - of course this could be confused by people sprinting through the frame, moving the opposite direction to the expected running up the down or vice-versa and entering the frame then backing out.

openCV track object in video and obtain a better image from multiple frames

I'm working on detecting license plates with openCV, python and a raspberry pi. Most of it is already covered. What I want is to detect the ROI (Region of interest) of the plate, track it on a few frames and add those together to get a more clear and crisp image of the plate.
I want to get a better image of the plate by taking the information from several frames. I detect the plate, and have a collection of plates from several frames, as many as I wish and as many as the car is moving by the camera. How can I take all those and get a better version?
You need to ensure that your frame rate is fast enough to get a decent still of the moving car. When filming, each frame will most likely be blurry, and our brain pieces together the number plate on playback. Of course a blurry frame is no good for letter recognition, so is something you'll need to deal with on the hardware side, rather than software side.
Remember the old saying: Garbage in; Garbage out.

Best Method for Identifying Broken Ellipses

I've been trying to identify ellipses in these pictures for a long time now for a project I'm working on. At the moment I'm trying a new method with a bit of success. I blur the image then subtract the original from it. After that I threshold that image which is how I get this: http://imgur.com/gIkv30A
I've been trying a few methods but have had pretty much no success with any of them. I can't get any more of the noise removed without compromising the quality of the ellipses I have found, but the ellipses I want to find seem to be decently defined.
If anyone has an idea on where I can go now I'd love to hear it.
Thanks,
Andy
edit:
Original Image: http://imgur.com/3ttIFiz
The main method I've tried so far using an adaptive threshold on the image then fitting an ellipse around each of the contours I find after that. It works quite well in one set of images, but performs very poorly in this set. I can see my current method working well in both I get it right.
How well it works with old images: http://imgur.com/eUYiYNa
How well it works with the new (more relevant to the program) images: http://imgur.com/1UXxXAp

Categories

Resources