Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding people silhouette in OpenCV C++

I would like to extract the silhouette of a human in a photo and remove the background. The photo could be taken of the full body, only the upper body or only the lower body.

What I have done so far is track the face using Haar Cascades, but the algorithm I use does a rectangle over the face and I would need the shape of all the body. I have tried HOG as well, but as well it gives me a rectangle and it doesn't work with all photos.

It would be great if somebody could help me. I'm using OpenCV and C++.

like image 784
mapetilan Avatar asked Dec 13 '11 12:12

mapetilan


People also ask

How to use OpenCV to find an object in an image?

Features 2D + Homography to Find a Known Object – in this tutorial, the author uses two important functions from OpenCV. These two functions are ‘findHomography’ and ‘perspectiveTransform’. These two are used to find objects in images. The ‘findHomography’ is a function based on a technique called Key-point Matching.

How to detect human faces in real-time in OpenCV using C++?

How to detect human faces in real-time in OpenCV using C++? Detecting face in real-time is similar to detecting a face in still pictures. The only difference is in real-time face detection, and we have to take a video stream of computer. In this program, we used 'VideoCapture ()' function.

How do I draw a contour in OpenCV?

OpenCV makes it really easy for finding, and drawing contours in images. It provides two simple functions to do so: findContours() , and drawContours() . As promised earlier, for hands-on coding experience we will see how to use the above functions of OpenCV.

How to identify the contours of an image?

Let’s consider such an example too. When the objects in an image are strongly contrasted against their background, you can clearly identify the contours associated with each object. But what if you have an image, like Figure 16 below.


1 Answers

You can try the GrabCut or GraphCut algorithms (At least grabcut is present in OpenCV).

You tell them the rectangle (where the body is), and they do the best to cut the object inside. It's not fast, nor perfect, but you'll have a hard time trying to find something better.

This is an open research field, so if your images do not get cut as you want, prepare yourself for some years of post-PhD research to find better algorithms :)

like image 106
Sam Avatar answered Sep 18 '22 14:09

Sam