-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
86 lines (52 loc) · 1.58 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
76
77
78
79
80
81
82
83
84
85
86
#include <vector>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cv.h>
#include "ImageAnalyzer.h"
#include <unistd.h>
using namespace cv;
#include "QwopBot.h"
#include <signal.h> /* signal, raise, sig_atomic_t */
ObjectFeatures::ObjectFeatures()
{
}
ObjectFeatures::ObjectFeatures(cv::Mat image,int numFeatures)
{
loadImage(image,numFeatures);
}
void ObjectFeatures::loadImage(cv::Mat image,int numFeatures)
{
trainingImage=image.clone();
ORB orb(numFeatures,1.1f,3,8,0,2,ORB::HARRIS_SCORE,8);
orb(image,Mat(),keypoints,descriptors);
if(descriptors.type()!=CV_32F)
descriptors.convertTo(descriptors, CV_32F); // make sure it's CV_32F
drawKeypoints( trainingImage, keypoints, trainingImage, Scalar::all(255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
//std::cerr <<"descriptors: "<<descriptors.size()<<std::endl;
}
int main()
{
/*
//inRange(im, cv::Scalar(120,00,000),Scalar(130,255,255), mask); per il corpo
Mat im = imread( "/home/matteo/Progetti/QwopBot/references/qwoptest.png" );
ImageAnalyzer imageAnalyzer;
//cvtColor(im, im, COLOR_RGB2HSV);
imageAnalyzer.saveBackground(im);
im = imread( "/home/matteo/Progetti/QwopBot/references/qwoptest.png" );
/*imageAnalyzer.removeBackground(im);
Mat scarpe = imageAnalyzer.filterShoesAndSign(im);
Mat corpo = imageAnalyzer.filterBody(im);
im.setTo(Scalar(0,255,0),scarpe);
//blur( im,im, Size(3,3) );
//Canny( im,im, 80, 100, 3 );
imageAnalyzer.analyzeFrame(im);
imshow("QWOP",im);
waitKey(0);
return 0;*/
nice(1);
QwopBot bot;
while(1) {
bot.step();
usleep(5000);
}
return 0;
}