5

i wanna know if there is some SURF library that is written in PHP available? From little findings that i did till now surf libraries are either in C++/C#, if some link to similar technologies that are built in PHP if provided it will be appreciated. I googled my way for some builtin features, the only thing that was close enough was Image Magick. But from comments it looks like pattern matching cannot be done in it.

Let me re define my self i just dont want to compare 2 images , lets say there is a Google logo with in an image, and there is an image of Google Logo as a separate image what i want to search if there is some image where Google's logo/image is reproduced.

temp-learn
  • 497
  • 2
  • 9
  • 31
  • Why dont you use MATLAB? It will be much easier for you unless it is mandatory to use php but to the best of my knowledge, the feature detectors you mentioned dont have library written in PHP. I suggest you to shift to matlab which make your job much easier – user2867655 Jan 30 '14 at 14:16
  • well i have kinda restriction to use PHP – temp-learn Jan 30 '14 at 14:17
  • It is probably impossible to do matrix representation of an image in PHP. Perhaps you need to sit down with your boss and ask him/her to change his requirement. – user2867655 Jan 30 '14 at 14:20
  • i assumed that comparisons done in SIFT and/OR Surf the comparisons were made mathematically, or using some certain calculations, what if i am not interested in matrix representation and just interested in actual pattern matching between two images. Sorry for my lack of info but above is what i want – temp-learn Jan 30 '14 at 14:23
  • 1
    You can use c++ OpenSURF library http://stackoverflow.com/questions/2574206/loading-c-libraries-from-php – Nodir Jan 30 '14 at 22:49

2 Answers2

2

OpenCV is a great open source library for image processing and computer vision. I found a PHP wrapper (a detailed tutorial here), BUT it I am afraid that it doesn't wrap the SIFT/SURF code...

Reading your comment I saw you need to match two images. If your objective is to match a pattern (one image) against another image, you can use this example:

<?php
use OpenCV\Image as Image;
use OpenCV\Histogram as Histogram;

echo "Loading sample\n";
$im = Image::load("elephpant_sample.jpg", Image::LOAD_IMAGE_COLOR);
$im2 = Image::load("dragonbe_elephpants.jpg", Image::LOAD_IMAGE_COLOR);

for ($i = 0; $i < 6; $i++) {
$result = $im2->matchTemplate($im, $i);
$result->save("mt_output_$i.jpg");
}

In the case you are searching for objects, you can use the Haar Cascade part. Here is an example that detects faces in images.

phyrox
  • 2,273
  • 12
  • 22
  • Let me re define my self i just dont want to compare 2 images , lets say there is a Google logo with in an image, and there is an image of Google as a separate image what i want to search if there is some image where Google's logo/image is reproduced. – temp-learn Feb 03 '14 at 13:59
  • I tried to implement your solution and links you suggested but the link you suggested is to be used with an older version of PHP mainly PHP<5.3 so this is an outdated solution , the documentation says as it is for php 5.3 but when you try to implement the code, it shows certain errors telling about functions that are not used in latest releases of PHP – temp-learn Feb 11 '14 at 11:02
  • In the end thanks for the time and effort you put in answering, but the bad luck is that in recent times no work have been done on recent libraries – temp-learn Feb 12 '14 at 17:09
  • @phyrox Hi, is it possible to get a score of how much similarity between two image? – rakibtg Oct 04 '17 at 13:05
1

You can try the phash (http://phash.org) algorithm in php. Or read this question about image fingerprint and similarities:Image fingerprint to compare similarity of many images.

Community
  • 1
  • 1
Gigamegs
  • 12,342
  • 7
  • 31
  • 71
  • pHash has the last version bugged on the php side. You can find fixes around the web. But every fix has something more or missing. Meaning, pHash didn't do the job, what it was supposed to do. I do not recommend it, if you are using it for PHP. – Kalle H. Väravas Feb 24 '15 at 15:22