Template:FileContentsByBot/Faces

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Faces
#Position ConfidenceEyesCoverageMouthNoseEarsTypePose
Template documentationview · edit · history · purge ]

Contains the required markup to represent Category:Unidentified people, Category:Groups, Category:Faces, Category:Portraits, ... by a bot. For more information on how it got detected, please confer Face detection. Represents a collection of table rows (<tr>) marking the faces. Please use multiple or one {{FileContentsByBot/Faces}} for the formatting. Refer to {{FileContentsByBot/Faces}} to find how you can read the position from the HTML.
Row's id: FileContentsByBot-Faces. Caption class: bot-Faces-legend.
Contains the required markup to represent a face with eyes and coordinates detected by a bot.

Usage

{{FileContentsByBot/Faces
 |1 =
 |ID =
 |Confidence =
 |Coverage =
 |Position-00 =
 |Position-01 =
 |Position-02 =
 |Position-03 =
 |Eyes-00-00 =
 |Eyes-00-01 =
 |Eyes-00-02 =
 |Eyes-00-03 =
 |Eyes-01-00 =
 |Eyes-01-01 =
 |Eyes-01-02 =
 |Eyes-01-03 =
 |Mouth-00 =
 |Mouth-01 =
 |Mouth-02 =
 |Mouth-03 =
 |Nose-00 =
 |Nose-01 =
 |Nose-02 =
 |Nose-03 =
 |Type =
}}

Template parameters

ParameterDescriptionDefaultStatus
1Any number of {{FileContentsByBot/Faces}} blocks. Confer example below.emptyoptional
IDThe face's id. The numbers should start with 1. Increment 1. Type: Integer.
Field's class: bot-Faces-ID.
emptyrequired
ConfidenceShowing "how sure the bot was" that the depicted item was a face. Type: Float/Single. Min: 0. Max: 1.
Field's class: bot-Faces-Confidence.
emptyrequired
CoverageShowing how much of the image is covered by face. Type: Float/Single. Min: 0. Max: 1.
Field's class: bot-Faces-Coverage.
emptyrequired
Position-00The face's left position (leftmost coordinate) in px. Refer to this template to find how you can read the data from the HTML. Number only. Type: Integer.
Row's class: bot-Faces-Position.
Field's class: bot-Faces-Position-left.
emptyrequired
Position-01The face's top position (topmost coordinate) in px. Number only. Type: Integer.
Row's class: bot-Faces-Position.
Field's class: bot-Faces-Position-top.
emptyrequired
Position-02The face's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Position.
Field's class: bot-Faces-Position-width.
emptyrequired
Position-03The face's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Position.
Field's class: bot-Faces-Position-height.
emptyrequired
Eyes-00-00The 1st eye's left position (leftmost coordinate) in px. Refer to this template to find how you can read the data from the HTML. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-1-Position-left.
emptyoptional
Eyes-00-01The 1st eye's top position (topmost coordinate) in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-1-Position-top.
emptyoptional
Eyes-00-02The 1st eye's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-1-Position-width.
emptyoptional
Eyes-00-03The 1st eye's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-1-Position-height.
emptyoptional
Eyes-01-00The 2nd eye's left position (leftmost coordinate) in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-2-Position-left.
emptyoptional
Eyes-01-01The 2nd eye's top position (topmost coordinate) in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-2-Position-top.
emptyoptional
Eyes-01-02The 2nd eye's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-2-Position-width.
emptyoptional
Eyes-01-03The 2nd eye's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Eyes.
Field's class: bot-Faces-Eyes-2-Position-height.
emptyoptional
Mouth-00The mouth's left position (leftmost coordinate) in px. Refer to this template to find how you can read the data from the HTML. Number only. Type: Integer.
Row's class: bot-Faces-Mouth.
Field's class: bot-Faces-Mouth-left.
emptyrequired
Mouth-01The mouth's top position (topmost coordinate) in px. Number only. Type: Integer.
Row's class: bot-Faces-Mouth.
Field's class: bot-Faces-Mouth-top.
emptyrequired
Mouth-02The mouth's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Mouth.
Field's class: bot-Faces-Mouth-width.
emptyrequired
Mouth-03The mouth's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Mouth.
Field's class: bot-Faces-Mouth-height.
emptyrequired
Nose-00The nose's left position (leftmost coordinate) in px. Refer to this template to find how you can read the data from the HTML. Number only. Type: Integer.
Row's class: bot-Faces-Nose.
Field's class: bot-Faces-Nose-left.
emptyrequired
Nose-01The nose's top position (topmost coordinate) in px. Number only. Type: Integer.
Row's class: bot-Faces-Nose.
Field's class: bot-Faces-Nose-top.
emptyrequired
Nose-02The nose's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Nose.
Field's class: bot-Faces-Nose-width.
emptyrequired
Nose-03The nose's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Nose.
Field's class: bot-Faces-Nose-height.
emptyrequired
TypeShowing which type of detection yielded this face. Type: String.
Field's class: bot-Faces-Type.
emptyrequired

Additional information

The template is intended to be used in the following namespaces: the File namespace

The template is intended to be used by the following user groups: Bots

Placement:

inside {{FileContentsByBot}} parameter Fields

See also

Localization

This template is not intended to be localized.

Face table row's classes: bot-Faces and face-number-{{{ID}}}.

// Example reading first face's confidence
var id1 = $('.face-number-1').find('.bot-Faces-Confidence').text();

// Example reading all face's IDs
$('#fileContentsByBot').find('.bot-Faces').each(function(i, el) {
   var $el = $(el);
   alert($el.find('.bot-Faces-ID').text());
});
// Example reading all face's coordinates
$('#fileContentsByBot').find('.bot-Faces').each(function(i, el) {
   var $el = $(el),
       id = $el.find('.bot-Faces-ID').text(),
       $facePos = $el.find('.bot-Faces-Position');
       alert("Face " + id + " is at " + $facePos.find('.bot-Faces-Position-left').text() + ", "  + $facePos.find('.bot-Faces-Position-top').text() + "px.")
});
// Example reading all 1st eye's coordinates
$('#fileContentsByBot').find('.bot-Faces').each(function(i, el) {
   var $el = $(el),
       id = $el.find('.bot-Faces-ID').text(),
       $eyePos = $el.find('.bot-Faces-Eyes');
       alert("Eye 1 of face " + id + " is at " + $eyePos.find('.bot-Faces-Eyes-1-Position-left').text() + ", "  + $eyePos.find('.bot-Faces-Eyes-1-Position-top').text() + "px.")
});

Enable display of detected face icons before clicking on "View them!" already by adding the following code e.g. to your Special:MyPage/common.js:

// Show little face-icons (cf. [[MediaWiki:FileContentsByBot.js]])
$(function() {
 $('div.bot-Faces-Position-icon').each(function(i, el) {
  var $el = $(el),                                     // turn DOM-node into jQuery-object (array-like-object)
      $scaleDiv = $el.children('div:first'),           // find scale-div
      $img = $scaleDiv.find('a.image > img'),          // find image
      ratio = parseFloat($scaleDiv.attr('class'), 10); // Making explicit we want a float
 
  // Prevent running twice
  if ($el.is(':visible')) return false;
  // Scaling
  $img.width($img.width()*ratio);
  $img.height($img.height()*ratio);
 }).show(); // Finally show the image
})

Example of usage

{{FileContentsByBot/Faces|
  {{FileContentsByBot/Faces
  | Position-00 = 877
  | Position-01 = 625
  | Position-02 = 711
  | Position-03 = 711
  | Eyes-00-00 = 1047
  | Eyes-00-01 = 795
  | Eyes-00-02 = 188
  | Eyes-00-03 = 188
  | Confidence = 0.75
  | ID = 1
  | Coverage = 0.321
  }}
  ...
}}

How the bot obtained this information