Finding people silhouette in OpenCV C++

2020-02-08 18:00发布

问题:

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++.

回答1:

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 :)