How can I detect faces using Ruby?

自闭症网瘾萝莉.ら 提交于 2019-12-03 00:07:27

If you are going to try and write something from scratch, there is a great explanation of the process on the Carnegie Mellon Website - neat graphics too.

However, your best bet is probably trying to hook into the Opensource Computer Vision project. Here is a good tutorial on using OpenCV for facial recognition.

Since the other answers to that interesting question are mostly outdated now, here the 2012 solution:

Using jQuery with jquery.objectdetect:

$("#faces").objectdetect("all", {classifier: objectdetect.frontalface}, function(coords) {
    // Do something with the face coordinates
});

Using jQuery with jquery.facedetection:

var coords = $("#faces").faceDetection();
// Do something with the face coordinates

Not using jQuery: Both plugins are based on stand-alone libraries that do not depend on jQuery at all.


In reply to @joeforker who said

"If you really don't understand that the notion JQuery can detect faces is a joke, you need to learn a lot before you will be ready to detect faces."

Or you just have to wait a year or two ;)

It looks like you are new to programming. Perhaps you have an advanced mathematics degree? If you really don't understand that the notion JQuery can detect faces is a joke, you need to learn a lot before you will be ready to detect faces. If you're lucky you can find an easy out-of-the-box solution. Unfortunately, face recognition is in the class of problems that tend to lack easy out of the box solutions. JavaScript is right out.

http://rubyforge.org/projects/opencv/ is a Ruby binding to OpenCV. The pitiful documentation (autogenerated API docs only) at http://doc.blueruby.mydns.jp/opencv/ mentions a face_detect.rb that might be helpful. As with most bindings, you should also consult the documentation for the original library e.g. http://opencv.willowgarage.com/wiki/FaceDetection

You should also understand that face detection (where are the faces in this photo?) is a different and easier problem than face recognition (whose face is it).

I do not know if this question was properly answered or how you resolved it, but I recently encountered this problem myself. I'm currently investigating external API's to implement my solution. The two Ruby API's that I am currently comparing are rdetection and Face.com's API

I'm primarily using it for face-aware image-crop using ImageMagick, so your needs and results may differ.

Detecting faces reliably is one of the hard problems in Computer Science. Realistically, there's no practical way for you to do it using Ruby, JavaScript or any other application language using current technology. If you tell us why you need to detect faces then we might be able to suggest a practical alternative approach.

Collect a lot of cash and contact these guys for a good solution!

Wikipedia has a good article about this which also explains why you're trying to do something that is still extremely complex to do.

FRGC is also interesting... If you do find a solution, you can take part in this challenge.

This is a face recognition tutorial using Javascript and face recognition APIs using Mashape - http://blog.mashape.com/post/45712257463/face-recognition-using-javascript-and-mashape

It also lets you detect if the person is smiling or not :)

Javascript Neural Nets have been used for OCR so should be possible if much harder for faces.

After some research and help from this thread I've decided to make a rubygem which can be found here: https://github.com/dennisdevulder/rekognize

This uses the face recognition API from rekognition.com.

Face detection is done using intensive memory based algorithms, which actually go through the image data to detect face like patterns. They may be many facial recognition / Pattern recoginition algorithms and APIS available for free (or for a fee) which you can use/implement with Ruby or Javascript.

I know this is an old question, but if anyone happens on it like I did check these out: blog post, test page, and Github.

This should get you started. It's about using OpenCV with Ruby via FFI: http://rubysource.com/detecting-faces-with-ruby-ffi-in-a-nutshell/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!