However, since you are using JPEG and a video source, it will have a lot of different pictures because of compression and graininess. You better be careful with that method, rather than judging how many pixels changed, judge how much the pixels changed by.