Template:FileContentsByBot/Faces

From Wikimedia Commons, the free media repository
Jump to: navigation, search
Faces

# Position   Confidence Eyes Coverage Mouth Nose Ears Type Pose
Documentation icon Documentation[view] [edit] [history] [purge]

This documentation is transcluded from Template:FileContentsByBot/Faces/doc.

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

Parameter Description Default Status
1 Any number of {{FileContentsByBot/Faces}} blocks. Confer example below. empty optional
ID The face's id. The numbers should start with 1. Increment 1. Type: Integer.
Field's class: bot-Faces-ID.
empty required
Confidence Showing "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.
empty required
Coverage Showing how much of the image is covered by face. Type: Float/Single. Min: 0. Max: 1.
Field's class: bot-Faces-Coverage.
empty required
Position-00 The 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.
empty required
Position-01 The 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.
empty required
Position-02 The face's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Position.
Field's class: bot-Faces-Position-width.
empty required
Position-03 The face's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Position.
Field's class: bot-Faces-Position-height.
empty required
Eyes-00-00 The 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.
empty optional
Eyes-00-01 The 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.
empty optional
Eyes-00-02 The 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.
empty optional
Eyes-00-03 The 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.
empty optional
Eyes-01-00 The 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.
empty optional
Eyes-01-01 The 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.
empty optional
Eyes-01-02 The 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.
empty optional
Eyes-01-03 The 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.
empty optional
Mouth-00 The 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.
empty required
Mouth-01 The 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.
empty required
Mouth-02 The mouth's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Mouth.
Field's class: bot-Faces-Mouth-width.
empty required
Mouth-03 The mouth's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Mouth.
Field's class: bot-Faces-Mouth-height.
empty required
Nose-00 The 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.
empty required
Nose-01 The 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.
empty required
Nose-02 The nose's width in px. Number only. Type: Integer.
Row's class: bot-Faces-Nose.
Field's class: bot-Faces-Nose-width.
empty required
Nose-03 The nose's height in px. Number only. Type: Integer.
Row's class: bot-Faces-Nose.
Field's class: bot-Faces-Nose-height.
empty required
Type Showing which type of detection yielded this face. Type: String.
Field's class: bot-Faces-Type.
empty required

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

Special:PrefixIndex/Template:FileContentsByBot

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