-
Notifications
You must be signed in to change notification settings - Fork 1
/
cvtest.cpp
72 lines (57 loc) · 1.41 KB
/
cvtest.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <cassert>
#include "data.cpp"
#include <math.h>
#include <utility>
#include <vector>
#include <iostream>
#include <time.h>
#include <string>
#include "opencv2/opencv.hpp"
#include "cv.cpp"
#define REP(i,n) for(int i=0;i<n;i++)
#define mp std::make_pair
#define pb push_back
using namespace cv;
int main()
{
VideoCapture cap(0);
assert(cap.isOpened());
Mat testFrame;
cap >> testFrame;
Mat testOut,testEdge;
downSize(testFrame, testOut);
Size outSize = Size(testOut.cols, testOut.rows);
//testEdge=hough(testOut);
//Size edgeSize=Size(testEdge.cols,testEdge.rows);
VideoWriter outVid("test.avi", CV_FOURCC('M','P','4','2'),10,outSize,true);
VideoWriter recVid("rec.avi", CV_FOURCC('M','P','4','2'),10,outSize,true);
//VideoWriter edgeVid("edge.avi", CV_FOURCC('M','P','4','2'),10,edgeSize,false);
assert(outVid.isOpened());
std::vector<int> inds;
int N,m; std::cin>>N;
REP(i,N)
{
std::cin>>m;
inds.pb(m);
}
//inds.pb(3);
for (int i = 0; i < 20; ++i)
{
Mat in;
cap >> in;
std::cout << "Grabbed frame" << std::endl;
Mat frame;
downSize(in,frame); //downsized
recVid << frame; //recorded raw video
maxFilter(frame,inds);
fill(frame,0,2);
vector<Vec4i> lines=hough(frame);
procHough(lines,frame);
//frame.copyTo(edge,emap);
outVid<<frame; //recorded processed video
struct timespec tim, tim2;
tim.tv_sec = 0;
tim.tv_nsec = 100000000;
nanosleep(&tim, &tim2);
}
}