使用OpenCV精确比较2张图像的差异 [英] Precisely Compare 2 images for differences using OpenCV

查看:2588
本文介绍了使用OpenCV精确比较2张图像的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,以预定的时间间隔通过网络摄像头捕获图像,并将图像与模板(良好图像)进行连续比较,如果差异>公差设置,则会给出错误消息.

I am working on a project to capture images via webcam in a predefined time interval, and continuously compare the images to a template (good image) and give an error if the difference is > tolerance set.

我正在使用OpenCV进行锻炼.想咨询我应该如何做,例如最好的方法,等等.

I working out using OpenCV. Would like to have advice how should I do it, e.g. best method, etc.

如果有人可以帮助我,请感谢.谢谢.

Appreciate if any one can help me on this. Thanks.

推荐答案

一种简单的方法是在图像对之间采用L2-范数:

An easy way is to just take the L2-norm between the image pairs:

double l2_norm = cvNorm( img1, img2 );

您必须尝试设置适当的阈值.当然,这种方法对于光照变化,视点变化等并不稳健,但简单快捷.

You'll have to experiment with setting the appropriate threshold. Of course this method is not robust to lighting changes, viewpoint changes, etc but its simple and fast.

这篇关于使用OpenCV精确比较2张图像的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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