0

How can Python detect changes in stationary objects between two images, where 2nd image may be slightly shifted and have slightly difference lighting?

Python needs to periodically compare the latest RGB image from a USB camera to a reference file image, from same camera, and detect a change in the collection of objects in the field of view? (Change meaning: object position changed, object removed, or another object added to field of view.)

Python must ignore if camera or objects have shifted an insignificant number of pixels in the x or y, and ignore changes in lighting brightness/luminosity.

BACKGROUND: I have an ELP USB camera board that is mounted 2-feet above a flat surface that contains a few stationary objects. Camera aims down at surface and objects.

First, Python takes a reference snapshot of the surface and initial objects, and stores to file. Later, Python needs to periodically take a snapshot of surface and objects and check for significant difference with reference; to check if any objects have been moved, or removed, or if a different object has been added.

Frame may sometimes have mechanical vibration that causes objects, or camera, to be slightly shifted, causing present snapshot to be slightly pixel shifted. Python must ignore these minor shifts in x or y pixel location.

Lighting may vary slightly.

Doug Null
  • 7,989
  • 15
  • 69
  • 148
  • There are probably libraries to do this. See [Extract differences between two images](https://stackoverflow.com/questions/27035672/cv-extract-differences-between-two-images) and [Checking images for similarity with OpenCV](https://stackoverflow.com/questions/11541154/checking-images-for-similarity-with-opencv) – Peter Wood Apr 28 '17 at 13:50
  • You can try to use optical flow algorithms - see http://docs.opencv.org/trunk/d7/d8b/tutorial_py_lucas_kanade.html . I would guess you could use a dense optical flow algorithm. A global image shift should clearly be distinguishable from e.g. an object being removed. – Julian S. Apr 28 '17 at 13:51

0 Answers0