I'm building an application that will take an image of a single person's whole body and will produce a "mugshot" for that person.
Mugshot meaning an image of the person's whole face, neck, hair and ears at the same general size of another mugshot.
Currently I'm using
http://askernest.com/archive/2008/05/03/face-detection-in-c.aspx
to implement OpenCV and I'm using
harrcascade_frontalface_default.xml
harrcascade_frontalface_alt.xml
harrcascade_frontalface_alt2.xml
harrcascade_frontalface_alt_tree.xml
as my cascades.
I use all of the cascades because a single one will not detect all my faces. After I get all of the faces detected by all of the cascades I find my average square and use that for my final guess of how tall and wide the mugshot should be.
My problem is 3 parts.
My current process is rather slow. How can I speed up the detection process?
I'm finding that the processing time is directly related to photo size. 我发现处理时间与照片尺寸直接相关。 Reducing the size of the photos may prove to be helpful.
A single cascade will not detect all the faces I come across so I'm using all of them. This of course produces many varied squares and a few false positives. What method can I use to identify false positives and leave them out of the average square calculation? ex.
I'm implementing an average of values within standard deviation. 我正在实现标准偏差范围内的平均值。 Will post code soon.
I'm not exactly sure of the best way find the mugshot given the square coordinates of the face. Where can I find face to mugshot ratios?
Solved this one. 解决了这个问题。 Assuming all my heads are ratios of their faces.
static public Rectangle GetMugshotRectangle(Rectangle rFace) { int y2, x2, w2, h2; //adjust as neccessary double heightRatio = 2; y2 = Convert.ToInt32(rFace.Y - rFace.Height * (heightRatio - 1.0) / 2.0); h2 = Convert.ToInt32(rFace.Height * heightRatio); //height to width ratio is 1.25 : 1 in mugshots w2 = Convert.ToInt32(h2 * 4 / 5); x2 = Convert.ToInt32((rFace.X + rFace.Width / 2) - w2 / 2); return new Rectangle(x2, y2, w2, h2); }
I just need to get rid of those false positives.
Ok make that 4 issues.
A single cascade could do what all of your cascades do if it is set up this way, plus it does not give you several results to judge from. The cascades you use are maybe different in the collection of teaching pictures they are made of or in some parameters.
A tutorial on how to build an own cascade can be found here . It would be useful to get the pictures used to train the four cascades you use but I don't know if they are publicly available.
I suggest you to use Upper-body Haar cascade file which will return you the rectangle till shoulder. Please find Head and shoulders cascade file at " http://alereimondo.no-ip.org/OpenCV/34 "
Ok, I figured it out but the project is on ice for the moment.
I do not have the source to paste as the VM takes forever to load up.
If someone is really interested, let me know and I'll post.
If you see something that looks like it could be done better let me know.
The steps I took were as follows.
Done!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.