-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Sometime algorithm: PerceptualHash()
produces the exact same results on different images.
Is this expected behavior?
Log:
flutter: 2.png and 1.png
flutter: PerceptualHash: 39.0625%
flutter: 3.png and 1.png
flutter: PerceptualHash: 19.140625%
flutter: 4.png and 1.png
flutter: PerceptualHash: 39.0625% <= same as 2.png
flutter: 5.png and 1.png
flutter: PerceptualHash: 47.265625%
Code:
for (var i = 1; i < 6; i++) {
ByteData data = await rootBundle.load('lib/images/$i.png');
Uint8List bytes = data.buffer.asUint8List();
img.Image image = img.decodeImage(bytes)!;
if (img1 != null) {
debugPrint('$i.png and 1.png');
await imageCompareTest(img1, image);
}
img1 = image;
}
imageCompareTest(img.Image img1, img.Image img2) async {
Directory tempDir = await getTemporaryDirectory();
var url1 = '${tempDir.path}/file1.png';
var url2 = '${tempDir.path}/file2.png';
// it's a bit redundant but crucial for our use-case
Uint8List bytes1 = Uint8List.fromList(img.encodePng(img1));
Uint8List bytes2 = Uint8List.fromList(img.encodePng(img2));
var file1 = File(url1);
await file1.writeAsBytes(bytes1);
var file2 = File(url2);
await file2.writeAsBytes(bytes2);
var assetResults = await listCompare(
target: file1,
list: [
file2
],
algorithm: PerceptualHash(),
);
for (var e in assetResults) {
print('PerceptualHash: ${e * 100}%');
}
}
Metadata
Metadata
Assignees
Labels
No labels