如何使用定相器检测数据库中的相似图像


How to use phasher to detect similar images in database?

>我正在构建一个搜索图像引擎,所以我需要在数据库中检测相似/重复的图像,并且我找到了phasher。

此类可帮助我为每个图像创建哈希字符串。我可以轻松地比较两个图像,但现在我想在大型数据库中搜索以查找特定图像是否有任何克隆或类似图像?

如何使用图像哈希字符串进行搜索?

我想

我正在构建一个看起来像你的工具,但Facebook个人资料图片的搜索引擎我称之为FBpp ="Facebook个人资料图片";

我还没有完成它,这是我为了提高我的编程技能而构建的东西。

我认为这就是你要找的。

<?php
//Require config.php file to connect with mysql server and the db.
require_once('config.php');
//Calling PHasher class file.
include_once('phasher/phasher.class.php');
$I = PHasher::Instance();
$testImage = "./avatar/4.jpg";
$hash = $I->FastHashImage($testImage);
$hex = $I->HashAsString($hash);
$result = mysql_query("SELECT `fid`,`hash` FROM `images`");
while($row  = mysql_fetch_array($result)){
    if($row['hash'] == $hex){
        //echo $row['hash'];
        $fid = $row['fid'];
        echo "<a href='https://www.facebook.com/$fid/'><img src='https://graph.facebook.com/$fid/picture?type=large'></a>";
    }
}