1 | initial version |
the main problem here is, that a writing video file needs a constant frame size, while size of your crops will vary due to person size & distance. so try following approach:
Size dstSize(64,128); // dst video size
VideoWriter vid("my.avi", VideoWriter::fourcc('M','J','P','G'), 10, dstSize);
// later, in a loop, detect humans
Rect rec = ...
Mat cropped = frame(rec);
Mat dst;
resize(cropped, dst, dstSize);
vid.write(dst);