-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
76 lines (63 loc) · 1.68 KB
/
main.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
73
74
75
/*
* File: main.cpp
* Author: silvea
*
* UNUSED IN LIB, NOW OUTDATED/BROKEN
* Used/working in viewerDemo branch
*
* Created on 26 January 2015, 1:55 PM
*/
#include <iostream>
#include "CamFeed.h"
#include "Viewer.h"
#include "TargetDetector.h"
using namespace std;
/*
*
*/
int main1() {
CamFeed cam("/home/silvea/Documents/Robotics/2015/OpenCV/sampleVideo/out.flv");
if (!cam.isOpened())
{
cerr << "Error opening capture device/file!" << endl;
return 1;
}
Viewer viewer, viewerA("out1");
TargetDetector detector(viewerA);
for (;;) {
cam >> viewer;
if (!viewer.data)
return 0;
viewerA = viewer.clone();
detector.prepareImage();
detector.findContours();
if (detector.filterContours())
{
LineResult detectionResult = detector.getContours();
cout << "Is good: " << detectionResult.isGood << endl;
cout << "X pos: " << detectionResult.xPos << ", Width: " << detectionResult.width << ", Rotation: ";
switch (detectionResult.rotation)
{
case NONE:
cout << "NONE";
break;
case CLOCKWISE:
cout << "CLOCKWISE";
break;
case ANTICLOCKWISE:
cout << "ANTICLOCKWISE";
break;
}
cout << endl;
}
viewer.update();
viewerA.update();
switch(cv::waitKey(100/3))
{
case 'q':
case 'Q':
return 0;
}
}
return 0;
}