Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. it's a clean-room rewrite, due to license issues.

  2. phash return 64 bits, that you have to compare to another phash value using e.g. the hamming norm.

while the original phash lib returns an int64(and you have to come up with your own comparison) , opencv returns a [1x8] CV_8U Mat.

you're might use it like this:

Mat img1 = ...
Mat img2 = ...

Mat hash1 = new Mat();
phash.compute(img1, hash1);

Mat hash2 = new Mat();
phash.compute(img2, hash2);

double bitDist = phash.compare(hash1, hash2);
// same as:
//double bitDist = Core.norm(hash1, hash2, Core.NORM_HAMMING);
  1. it's a clean-room rewrite, due to license issues.

  2. phash return 64 bits, that you have to compare to another phash value using e.g. the hamming norm.

while the original phash lib returns an int64(and you have to come up with your own comparison) , opencv returns a [1x8] CV_8U Mat. Mat (that's 64 bits, too !).

you're might use it like this:

Mat img1 = ...
Mat img2 = ...

Mat hash1 = new Mat();
phash.compute(img1, hash1);

Mat hash2 = new Mat();
phash.compute(img2, hash2);

double bitDist = phash.compare(hash1, hash2);
// same as:
//double bitDist = Core.norm(hash1, hash2, Core.NORM_HAMMING);
  1. it's a clean-room rewrite, due to license issues.

  2. phash return 64 bits, that you have to compare to another phash value using e.g. the hamming norm.

while the original phash lib returns an int64(and you have to come up with your own comparison) , opencv returns a [1x8] CV_8U Mat (that's 64 bits, too !).

you're might use it like this:

Mat img1 = ...
Mat img2 = ...

Mat hash1 = new Mat();
phash.compute(img1, hash1);

Mat hash2 = new Mat();
phash.compute(img2, hash2);

double bitDist = phash.compare(hash1, hash2);
// same as:
//double bitDist = Core.norm(hash1, hash2, Core.NORM_HAMMING);

edit: you can get an int64 value from the hash Mat:

Mat hash = ...
int64 H;
memcpy(&H, (void*)hash.data, 8); // 8x8bits=64
cout << H << endl;

but again, you'll have to come up with your own bitwise comparison function in java, and that'll be a drag ...

  1. it's a clean-room rewrite, due to license issues.

  2. phash return 64 bits, that you have to compare to another phash value using e.g. the hamming norm.

while the original phash lib returns an int64(and you have to come up with your own comparison) , opencv returns a [1x8] CV_8U Mat (that's 64 bits, too !).

you're might use it like this:

Mat img1 = ...
Mat img2 = ...

Mat hash1 = new Mat();
phash.compute(img1, hash1);

Mat hash2 = new Mat();
phash.compute(img2, hash2);

double bitDist = phash.compare(hash1, hash2);
// same as:
//double bitDist = Core.norm(hash1, hash2, Core.NORM_HAMMING);

edit: you can get an int64 value from the hash Mat:

Mat hash = ...
int64 H;
memcpy(&H, (void*)hash.data, 8); // 8x8bits=64
cout << H << endl;

but again, you'll have to come up with your own bitwise comparison function in java, and that'll be a drag ...