Motion detection by means of ROI grid

please show some code. relevant is where and how you define your ROIs, and where you count non-zeros.

related: python - How to use opencv functions on roi - Stack Overflow