13 Replies Latest reply on Mar 11, 2011 8:43 AM by cmessel

    Face or shape detection?

    Rocksand1

      I work with a magazine that prints mug shots of criminals. I get the mug shots of the people's faces, and I have tons of them to put on my layout. They are all different sizes, and right now I have to go through by hand and resize each one to fit it inside the image frame so that that face fills up the frame and is not cut off. Is there any type of script that could somehow detect the face or shape of the people and automatically size them to fit within the image box? If not, does anyone know an easier way for me to do this? It takes forever because I have hundreds to do.

       

      Thanks!

        • 1. Re: Face or shape detection?
          John Hawkinson Level 5

          Not in InDesign, no. That kind of image processing is not really its province.

           

          I suppose you could try asking in the Photoshop forums...I'm not really a Photoshop person, but I dont think it has support for face detection. But certainly there is software out there that does -- google picassa has face recognition, and facebook has face detection. While face recognition is really difficult just detecting the face isn't too bad. So I'm sure you can find some software that can interface with a script to give you the dimensions, and then you can certainly crop in automated fashion to externally-specified dimensions in InDesign.

          • 2. Re: Face or shape detection?
            absqua Level 4

            I've used this Perl module with limited success:

             

            http://search.cpan.org/~jiro/Image-ObjectDetect-0.12/lib/Image/ObjectDetect.pm

             

            I didn't have enough of a need for it to invest the time to really make it work.

             

            It should be possible to go from, say, JavaScript to Applescript to the shell to Perl, and return coordinates you could use to crop and resize the images in InDesign. Lot of work though.

             

            Jeff

            • 3. Re: Face or shape detection?
              Rocksand1 Level 1

              I will try it out, but I just found out what a script is last week so I doubt I'll be able to do too much with it.

               

              I did find a free program that does what I was needing, you can open a file in it and it automatically detects and crops to the face, but the problem is that it will only let me do one picture at a time. I have over 500 to do every week, so that would just take too long.

               

              I know this is no longer InDesign related, but if anyone has any ideas about possibly being able to set up a macro or script through that program that would allow it to do multiple images at a time, let me know. Finding a solution to this would save me so many hours.

               

              The name of the program is SNFaceCrop, I downloaded it from http://sourceforge.net/projects/snfacecrop/

              • 4. Re: Face or shape detection?
                John Hawkinson Level 5

                Curiously, both of the two software packages mentioned so far, SNFaceCrop and ObjectDetect.pm are based on OpenCV, the Open Source Computer Vision library.

                 

                Are you using Windows or a Mac? It does matter for some of this stuff. (I guess you must be using Windows because SNFaceCrop is a Windows app; that makes it a bit tougher to assist you, since you need to bring in a lot of extra stuff to run perl or python or other scripting languages that seem to have easily accessible OpenCV bindings...)

                 

                I think what you are asking for is fairly outside the realm of what can be reasonably expected to be provided on this forum. So someone may pop up and be very generous and invest the time to give you a solution, but I'm afraid you are better off breaking the problem into two parts and asking elsewhere.

                 

                The part you should solve elsewhere: feed a list of files to a program that invokes the OpenCV library and determines the face position and produces a list of files and their face positions.

                 

                Then, given that, we can show you how to take that list into InDesign and do {whatever you want}. Crop the photos to the face positions, leaving some margin, array the images in some intelligent fashion based on the face positions, etc., etc.

                 

                That said, I'm not sure what the best place to ask is. I would (again), probably suggest starting in the PhotoShop Scripting forum, though in truth that is probably a bad suggestion: it is less active than this one and you don't really want to solve the problem in PhotoShop. Still, you want to reach out to some people who regularly think about image processing...

                 

                You might also spend a while googling or OpenCV-based projects (seems like there are a lot) and trying to find one that does what you want. It probably exists, it sounds like a straightforward application of that software.

                 

                GOOD LUCK! Please do report back here, whatever you find!

                • 5. Re: Face or shape detection?
                  Rocksand1 Level 1

                  Thanks for the reply.

                   

                  I am actually using a Mac, but I run Windows on it too if I have some programs that will only run in windows. However, unfortunately I know absolutely nothing about programming or the OpenCV, perl, or python stuff you are talking about, I just know how to use actual programs, but have no idea about code or anything like that.

                   

                  I'll keep looking, it seems so simple yet I can't find it anywhere. There is a program called Luxand that supposedly does it for passport photos, but the program is $2200 and from what I can tell with the free trial it will only do them one at a time, which I can do with SNFaceCrop for free.

                   

                  But thanks again for your help.

                  • 6. Re: Face or shape detection?
                    edenshochat

                    We have a really simple open REST or JSON API for face.com (100% free for what you want). I realize you don't do programming, but checkout http://developers.face.com, and post on the forums what you need. Some good soul might write a cropping script for you.

                    • 7. Re: Face or shape detection?
                      ellishumphres

                      Is each photo from each County Department the same, or is EVERY photo different? I am assuming you are doing work for Just Busted or another similar weekly paper. If each County has its own... "zoom" factor, you could automate each County's set of images individually using Photoshop batches. You could have a droplet for each County, and drop every photo onto the right spot...

                      • 8. Re: Face or shape detection?
                        absqua Level 4

                        I can imagine a really nice script using the Extendables http library and the face.com APIs mentioned above. You could do the whole thing in InDesign, working on a selection, and just modify the placement of the images within their frames without cropping the original images.

                         

                        To edenshochat: Is there a code sample somewhere showing how to use the face.com APIs with uploaded images rather than urls? I poked around a little bit but couldn't figure out how to do it. And: would the terms of service allow one to non-commercially distribute this kind of app using one's own API key, or would one need to ask users to get their own keys? (Please feel free to PM me if these questions are wandering too far afield.)

                         

                        Jeff

                        • 9. Re: Face or shape detection?
                          Rocksand1 Level 1

                          Unfortunately even ones from the same county have different size and

                          placement of the faces.

                           

                          Rocksand

                           

                          Sent from my Sprint HTC Evo 4G.

                          • 10. Re: Face or shape detection?
                            edenshochat Level 1

                             

                            Cool idea to integrate through extendables.org!

                            It's pretty easy to upload an image vs. use a URL - we use POST (vs. GET) to upload images, and there's a post message example on each of the supporting methods (e.g. http://developers.face.com/docs/api/faces-detect/).

                            As for the API limits - you can create a sample API key which will be the default for distro, so that others can set it up and test it easily. but if the code is hosted somewhere and used by someone else, they need to create their own API key at face.com and apply it instead.
                            • 11. Re: Face or shape detection?
                              cmessel

                              Hi

                               

                              As a free solution try a webservice. It detects the coordinates of faces in images from a given URL. A demo is shown at http://detection.myvhost.de

                               

                              Its designed to detect frontal faces, so its a good test case for you. You can use it in any programming language since it is a webservice, and best of all you can use it on windows, linux, mac, android, iphone etc. Another cool thing about it is that its free. No limitations and everyone can use it!

                               

                              I have some spare time on my hands so if you try to describe exactly what you need, what size the images should be resized to, etc I can help you. Would be really nice to get some feedback from your use case. It could help me also improve the webservice (its opensource)

                               

                              Best regards,

                              Cristian

                              • 12. Re: Face or shape detection?
                                Rocksand1 Level 1

                                That would be amazing. Should I send you some sample mugshots and show you

                                what I need?

                                 

                                Rocksand

                                 

                                Sent from my Sprint HTC Evo 4G.

                                • 13. Re: Face or shape detection?
                                  cmessel Level 1

                                  Yes please. And if it is ok I would prefer to use the mailing list http://groups.google.com/group/detection-api

                                   

                                  That way I don't have to check the forum every time. If you could describe exactly what you need, give target dimensions and some sample images I can get started.

                                   

                                  Cheers

                                  Cristian