有没有比 Perl 中的 Image::Compare 更快的比较图像的方法?



这是我目前的方法:

#Object to compare images
my $cmp = Image::Compare->new();
# Resize images
my ($image_1_resized_file, $image_2_resized_file) = resize_images($image_1_file, $image_2_file);
# Configure comparison
$cmp->set_image1(
img  => $image_1_resized_file,
type => 'png',
);
$cmp->set_image2(
img  => $image_2_resized_file,
type => 'png',
); 

$cmp->set_method(
method => &Image::Compare::EXACT,
);
# Compare
if ($cmp->compare()) {
print "[DEBUG] Images are the samen"  if ($self->{_debug_prints} eq 1);
# Remove temp files
unlink $image_1_resized_file;
unlink $image_2_resized_file;
return 1;
}
else {
print "[ERROR] Images are not the samen";
#Remove temp files
unlink $image_1_resized_file;
unlink $image_2_resized_file;
return 0;
}
}

省略我所做的调整大小,如果图像相同,有没有最快的方法可以做到这一点?目前每张图像大约需要 2-5 秒,近似尺寸为 600x600。

考虑到我想测试大约 10 张图像的块大约 40 次,有没有最快的方法来获得结果?

您可以将每个图像压缩到标量中,然后与eq运算符进行比较以查看它们是否相同。不确定这是否是您想要的。

最新更新