1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <cstdio>
#include <omp.h>
#include "cv.h"
#include "highgui.h"
#include "compute.h"
#include "stitch.h"
#include "explore.h"
int main(int argc, char** argv)
{
if (argc < 3)
{
fprintf(stderr, "Usage : %s VIDEO DIRECTION\n", argv[0]);
return -2;
}
int direction = atoi(argv[2]);
if (direction != 1 && direction != -1)
{
fprintf(stderr, "DIRECTION must be 1 or -1\n");
return -2;
}
fprintf(stderr, "Video direction %d\n", direction);
VideoCapture cap(argv[1]);
if(!cap.isOpened())
return -1;
int frames_count = cap.get(CV_CAP_PROP_FRAME_COUNT);
int width = cap.get(CV_CAP_PROP_FRAME_WIDTH);
int height = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
vector<Mat> frames (frames_count);
for(int i = 0; i < frames_count; ++i)
{
Mat frame, frame_double;
cap >> frame;
frame.convertTo(frame_double, CV_32FC3, 1.0/255.);
Mat aligned (frame_double.rows, frame_double.cols, CV_32FC4);
Mat channel4 = Mat::ones(frame_double.rows, frame_double.cols, CV_32F);
Mat in[] = {frame_double, channel4};
int from_to[] = { 0,0, 1,1, 2,2, 3,3 };
cv::mixChannels (in, 2, &aligned, 1, from_to, 4);
frames[i] = aligned.clone();
}
vector<vector<Mat> > downscaled;
vector<Mat> mosaics;
vector<Path> paths;
Mat mosaic = compute_mosaic(frames, direction, downscaled, mosaics, paths);
return 0;
}
|