have you implement motion compensation in the program?
proposal
inside the program the image path for function "imread()" should not be a char class array ,instead it should be a string class ,for example:
char buff[100];
sprintf(buff, "%s%04d.jpg",PATH, start);
std::string address = buff;
Mat frame = imread(address, IMREAD_COLOR);