如何分组的照片相似的脸孔在一起脸孔、相似、照片

2023-09-11 04:48:03 作者:独狼

在大多数面部识别SDK,它只提供了两个主要的功能

In most face recognition SDK, it only provides two major functions

检测脸部并从照片中提取模板,这就是所谓的检测。 在比较两个模板,并返回相似的分数,这就是所谓的认可。

不过,除了这两个功能,我所寻找的是分组相似面孔的照片一起,如算法或SDK基于类似的分数。

However, beyond those two functions, what I am looking for is an algorithm or SDK for grouping photos with similar faces together, e.g. based on similar scores.

感谢

推荐答案

首先,执行步骤1中提取的模板,然后将第二步中的所有可能的对,获得他们的相似度比较每个模板与所有其他人。

First, perform step 1 to extract the templates, then compare each template with all the others by applying step two on all the possible pairs, obtaining their similarity scores.

排序基于这种相似性得分的比赛中,决定一个阈值,并组合在一起那些超过它的模板。

Sort the matches based on this similarity score, decide on a threshold and group together those templates that exceed it.

举个例子,下面的案例:

Take, for instance, the following case:

十大模板: A,B,C,D,E,F,G,H,I,J 的成绩: 0和100 相似性阈值: 80

Ten templates: A, B, C, D, E, F, G, H, I, J. Scores between: 0 and 100. Similarity threshold: 80.

相似的表:

   A   B   C   D   E   F   G   H   I   J
A  100 85  8   0   1   50  55  88  90  10

B  85  100 5   30  99  60  15  23  8   2 

C  8   5   100 60  16  80  29  33  5   8

D  0   30  60  100 50  50  34  18  2   66

E  1   99  16  50  100 8   3   2   19  6

F  50  60  80  50  8   100 20  55  13  90

G  55  15  29  34  3   20  100 51  57  16

H  88  23  33  18  2   55  51  100 8   0

I  90  8   5   2   19  13  57  8   100 3

J  10  2   8   66  6   90  16  0   3   100

排序匹配列表:

AI 90 FJ 90 99 AH 88 AB 85 CF 80 -------< - 阈值截止线 DJ 66 .......

AI 90 FJ 90 BE 99 AH 88 AB 85 CF 80 ------- <-- Threshold cutoff line DJ 66 .......

遍历列表,直到门槛分界点,其中的值不会超过它,保持一个完整的模板设置和关联设置每个模板,获得最后的组:

Iterate through the list until the threshold cutoff point, where the values no longer exceed it, maintain a full templates set and association sets for each template, obtaining the final groups:

// Empty initial full templates set
fullSet = {};

// Iterate through the pairs list
foreach (templatePair : pairList)
{
  // If the full set contains the first template from the pair
  if (fullSet.contains(templatePair.first))
  {
     // Add the second template to its group
     templatePair.first.addTemplateToGroup(templatePair.second);

     // If the full set also contains the second template
     if (fullSet.contains(templatePair.second))
     {
        // The second template is removed from the full set
        fullSet.remove(templatePair.second);

        // The second template's group is added to the first template's group
        templatePair.first.addGroupToGroup(templatePair.second.group);
     }
  }
  else
  {
    // If the full set contains only the second template from the pair
    if (fullSet.contains(templatePair.second))
    {
      // Add the first template to its group
      templatePair.second.addTemplateToGroup(templatePair.first);
    }
  }
  else
  {
     // If none of the templates are present in the full set, add the first one
     // to the full set and the second one to the first one's group
     fullSet.add(templatePair.first);
     templatePair.first.addTemplateToGroup(templatePair.second);
  } 
}

的名单上执行的细节:

AI: fullSet.add(A); A.addTemplateToGroup(I);
FJ: fullSet.add(F); F.addTemplateToGroup(J);
BE: fullSet.add(B); B.addTemplateToGroup(E);
AH: A.addTemplateToGroup(H);
AB: A.addTemplateToGroup(B); fullSet.remove(B); A.addGroupToGroup(B.group);
CF: C.addTemplateToGroup(F);

在最后,你结束了以下相似组:

In the end, you end up with the following similarity groups:

A - I, H, B, E
C - F, J