Skip to content

Instantly share code, notes, and snippets.

@whatsnewsisyphus
Created September 19, 2019 06:27
Show Gist options
  • Save whatsnewsisyphus/b6d75a96090e00a7425d143bd61bea3f to your computer and use it in GitHub Desktop.
Save whatsnewsisyphus/b6d75a96090e00a7425d143bd61bea3f to your computer and use it in GitHub Desktop.
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