Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Average videos
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
namespace cv
{
using std::vector;
}
int main(int argc, char** argv)
{
VideoCapture cap(argv[1]);
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat frameSum;
Mat frame;
int numFrames = 1;
cap.read(frameSum);
frameSum.convertTo(frameSum, CV_32SC3);
while(cap.read(frame))
{
add(frame,frameSum,frameSum,noArray(),CV_32SC3);
numFrames++;
printf("%d\n",numFrames);
}
Mat frameMean = frameSum/numFrames;
cv::vector<int> compression_params;
imwrite("outputMeanFrame.tif",frameMean);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.