# Building a Matching Assistant for Couple Avatars with pHash and Elasticsearch

DevFeed: [Building a Matching Assistant for Couple Avatars with pHash and Elasticsearch](<https://devfeed.tech/articles/article-40969.md>)

Original publisher: [Read original article](<https://blog.joway.io/posts/avatar-matcher/>)

Author: Joway

Published: 2018-09-27T00:00:00Z

Content type: tutorial

Language: zh

Sources: [Random Thoughts](<https://devfeed.tech/sources/random-thoughts.md>)

Topics: [hash](<https://devfeed.tech/topics/hash.md>), [elasticsearch](<https://devfeed.tech/topics/elasticsearch.md>)

Tags: [elasticsearch](<https://devfeed.tech/tags/elasticsearch.md>), [hash](<https://devfeed.tech/tags/hash.md>), [tech](<https://devfeed.tech/tags/tech.md>)

## AI overview

The article describes building a couple-avatar matching assistant. It uses pHash to create image fingerprints that remain relatively similar after resizing or small edits, compares fingerprints by Hamming distance, and stores and searches them with Elasticsearch and an Elasticsearch Hamming plugin. The author also discusses collecting avatar pairs from online communities and presenting the tool as a community bot.

## Source excerpt

背景 情头(情侣头像)一般指成双成对的头像，可以是真人照片，也可以是卡通人物等图片。衍生出去还有闺密头像和基友头像等等。 社交媒体上有一个非常令人费解的现象是，如果你去即刻、豆瓣、百度贴吧、微博，会发现有大量的人在上面贴了一个头像，然后寻找和它匹配的另一半头像，例如这样: 市面上的情侣头像大多是一些社区里的大佬自己制作出来的，然后发到社区里，再慢慢流传开来。这种传播方式导致了很多情头在传播时候早就被拆散了。很多人可能只找到了其中一个，但是想要找到和它配对的另一半。 还有一个问题是，当你看到一个头像时，没有人能够确定这个头像是否在制作时候就有另外一半。 一些程序员朋友最早看到这个问题时，总会天真地想去搜索引擎里识图一下就行了。但这里有两个非常有趣的问题: 第一个是目前搜索引擎的识别图片能力其实并不强，比如以 All in AI 著称的百度: 这还是在图片是原图的情况下，经常一些小朋友会在情头上自己二次创作，比如裁剪，比如压缩，比如贴上什么爱心。那样基本上识图就废了。 第二个问题更加有趣，情头的特点就是大家都在用，所以在最理想的情况下，即便搜索引擎能够识别出所有有这个头像的网站，出来的结果也并没有什么用处，无非是找到了也在用这个头像的别的网站的用户。 只有一种情况是真正能够帮助到寻找情侣头像这件事情的，那就是搜索引擎出来的结果里是专门搜集匹配好的情头的站点。那样姑且用户还能点进网页里去找到另外一半。 从上述阐述里不难发现，指望一个未成年小女生使用一系列高级互联网骚操作找一个头像是有多么不现实，何况技术上可行性还很低。