比较Android的两个图像 [英] compare two images in android

查看:102
本文介绍了比较Android的两个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想捕捉使用摄像头两张图片,然后我想比较这些图像。

In my application I want to capture two images using camera and then I want to compare those images.

那么,如何可以比较两个图像?

So, how can I compare two images?

编辑: 比较第一图像精确作为第二图像像素到像素。

Compare First image is exact as second image pixel to pixel.

感谢你。

推荐答案

1 检查高度匹配,如果不返回false。然后,检查宽度匹配,如果没有,则返回false。然后检查每一个像素,直到你找到一个不匹配。当你这样做,返回false。如果每个像素相匹配,返回true。

1. Check that the height matches, if not return false. Then, check if the width matches, and if not, return false. Then check each pixel until you find one that doesn't match. When you do, return false. If every pixel matches, return true.

伪code:

bool imagesAreEqual(Image i1, Image i2)
{
    if (i1.getHeight() != i2.getHeight()) return false;
    if (i1.getWidth() != i2.getWidth()) return false;

    for (int y = 0; y < i1.getHeight(); ++y)
       for (int x = 0; x < i1.getWidth(); ++x)
            if (i1.getPixel(x, y) != i2.getPixel(x, y)) return false;

    return true;
}

在现实中,你可能需要把图像作为一个二维数组,如果你可以,只是比较字节。我不知道在Android形象的API,但getPixel可能​​是缓慢的。

in reality, you probably want to treat the image as a two dimensional array if you can, and just compare bytes. I don't know the Android image API, but getPixel might be slow.

2 也许你转换图像中byte64字符串,然后对它们进行比较。

2. maybe you convert the images in to byte64 Strings and then compare them.

3 * * OpenCV的LIB为Android:
有功能的图像融为一体pression

** A。
Core.absdiff() Core.compare()

3.**OpenCV lib for Android :
have to functions for images compression

**a.
Core.absdiff() b. Core.compare()

有关详细信息,请参阅比较两个图像

for more details see comparing two images

这篇关于比较Android的两个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆