face detection? photoshop script

New Here ,
Aug 04, 2016 Aug 04, 2016

Copy link to clipboard

Copied

Hello,

I'm exploring possibility of auto face detection and selection using photoshop script. Has anyone tried something similar? Please guide me in right direction.

I need to find and select face(with head) automatically and move in different layer.

http://facedetection.jaysalvat.com/  This website has Jquery. But wanted to do this with photoshop script.

faces.JPG

TOPICS
Actions and scripting

Views

3.0K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 05, 2016 Aug 05, 2016

mahendrak15024337 wrote:

Thanks JJMack!

Let's say if we take out face selection. But is there any photoshop script command/method that detect whether the layer/image has face(s) on it or not?

Thanks again!

If you leave out face detection how would one know if there is a face or not in a layer.  Even Adobe Face detection does not detect all faces in images.  The new Face Detection in CC 2015.5 liquify had no problem finding all 8 faces in your example.  Yet I have seen portrait images it has failed t

...

Likes

Translate

Translate
LEGEND ,
Aug 04, 2016 Aug 04, 2016

Copy link to clipboard

Copied

A couple of Photoshop features use face detection.  However there is no select faces feature that I know of.

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 05, 2016 Aug 05, 2016

Copy link to clipboard

Copied

Thanks JJMack!

Let's say if we take out face selection. But is there any photoshop script command/method that detect whether the layer/image has face(s) on it or not?

Thanks again!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 05, 2016 Aug 05, 2016

Copy link to clipboard

Copied

mahendrak15024337 wrote:

Thanks JJMack!

Let's say if we take out face selection. But is there any photoshop script command/method that detect whether the layer/image has face(s) on it or not?

Thanks again!

If you leave out face detection how would one know if there is a face or not in a layer.  Even Adobe Face detection does not detect all faces in images.  The new Face Detection in CC 2015.5 liquify had no problem finding all 8 faces in your example.  Yet I have seen portrait images it has failed to identify a face in.  CC 2015.5 has so many issues I do not use it.   Older versions of Photoshop starting with CS6  have face detection in color range to help select skin.

Capture.jpg

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 06, 2016 Aug 06, 2016

Copy link to clipboard

Copied

Thanks JJMack for helping! This actually gives us direction.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2016 Aug 07, 2016

Copy link to clipboard

Copied

Forgetting Photoshop detecting faces for this example, however if this metadata was in the image from another product (Apple Photos, Google Picasa etc) then one could potentially do something with the face metadata from Bridge or Photoshop.

Here is some metadata exported from Apple Photos, the image is width is 2448 and the height is 3264:

<mwg-rs:Type>Face</mwg-rs:Type>
<mwg-rs:Area rdf:parseType="Resource">
<stArea:y>0.493500</stArea:y>
<stArea:w>0.178000</stArea:w>
<stArea:x>0.454000</stArea:x>
<stArea:h>0.237000</stArea:h>
<stArea:unit>normalized</stArea:unit>

Off hand I am not sure how one would translate the normalized X/Y/W/H coordinates back into pixels.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 10, 2016 Aug 10, 2016

Copy link to clipboard

Copied

Hi,

you can definitely build such a tool – a PS face detection HTML panel – but due to technology constraints the steps are a little bit convoluted.

You'd need to:

1. Write an Adobe Generator plugin to extract the Active Document composite as PNG/JPG (or alternative make your Panel save it programmatically)

2. Load the JPG/PNG into an HTML Panel in PS

3. Use the jQuery plugin in there

The result is an array of coordinates in your Javascript – from that point onwards, you can do whatever you want via scripting, like make a selection duplicate each face in its own layer, etc.

Hope this helps,

Davide Barranca

---

http://htmlpanelsbook.com

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2022 Jul 25, 2022

Copy link to clipboard

Copied

LATEST

Hello dear Davide Barranca
I took your advice
Everything works fine in the browser for me, but when I create a plugin in UXP DevTools
I get an error jQuery    r.getClientRects is not a function
error.jpg


 

 

 

 

 

<!DOCTYPE html>
<html>
<head>
  <script src="jquery-3.2.1.min.js"></script>
  <script src="jquery.facedetection.min.js"></script>
  <script src="index.js"></script>      
</head>
<style>
  body {
    color: white;
    padding: 0 16px;
  }
  li:before {
    content: '• ';
    width: 3em;
  }

</style>
<body>
  <img id="picture" src="face.png">
</body>
<script>
  $('#picture').faceDetection({
      complete: function (faces) {
          console.log(faces);
      }
  });   
</script>
</html>

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

Save time with Adobe Express quick actions