Using OpenCV in C++:
//Subtract consecutive frames
cv::Mat matN=cv::imread("frame1.jpg");
cv::Mat matM=cv::imread("frame2.jpg");
cv::Mat matDiff=abs(matM-matN);
//Set region of interest (subframe)
int x(10),y(10),width(30),height(40);
cv::Rect myRegionOfInterest(x,y,width,height);
//Define motion
double Threshold=0.1;
double nze=cv::countNonZero( matDiff(myRegionOfInterest) );
double motionFactor=nze/(width*height*C); //C=255 for uchar, C=1 for binary, etc.
if (motionFactor>Threshold)
std::cout<<"Motion detected at specific ROI";