Motion detection in Python