Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Assuming that when the room is empty then there is no movement at all (no moving curtains, working production line etc.) you may compare the image sequence whether there are differences on them. If so it means that someone entered the room and moving.

I have just pasted my simple code here. It reads the images from the webcam one by one, selects one channel, smooths it and calculates the absolute difference on each pixel. Finally when the difference is above a certain level (20) then the resulting image will contain a white pixel in that position:

cvAbsDiff(image1, image2, result);
cvCmpS(result, 20, result, CV_CMP_GE);

To make the difference more visible a rectangle is drawn that creates a frame around all those pixels where there was a change (calculateMovementCoordinates).

I know that it is a naive solution but you may begin with it.