Created
September 19, 2019 06:27
-
-
Save whatsnewsisyphus/b6d75a96090e00a7425d143bd61bea3f to your computer and use it in GitHub Desktop.
Average videos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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