Repository navigation
Expand file tree
/
Copy pathlectVideoFrameCreate.cpp
More file actions
executable file
·95 lines (84 loc) · 2.07 KB
/
Copy pathlectVideoFrameCreate.cpp
File metadata and controls
executable file
·95 lines (84 loc) · 2.07 KB
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
87
88
89
90
91
92
93
94
// Including Boost
#include <boost/lambda/lambda.hpp>
#include <boost/thread.hpp>
#include <boost/date_time.hpp>
#include <boost/interprocess/containers/vector.hpp>
//Including C++ Libs
#include <iostream>
#include <iterator>
#include <queue>
//#include <algorithm>
#include <cstdio>
//Open CV
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "paolMat.h"
#include "buffer.h"
#include "module.h"
#include "lectVideoFrameCreate.h"
#define outWidth 640
#define outHeight 480
#define border 100
#define maxMoveSpeed 40
#define minMoveSpeed 5
//#define _debug_
using namespace cv;
void LectVideoFrameCreate::run()
{
Ptr<paolMat> previous;
Ptr<paolMat> current;
Ptr<paolMat> img;
Ptr<paolMat> cropped;
bool moveX, moveY;
int diff;
moveX = true;
moveY = true;
previous = pop();
previous->camera = previous->prof;
current = pop();
cropped = previous->cropFrame(outWidth, outHeight);
push(cropped);
while(current != NULL)
{
current->camera = previous->camera;
if(current->prof.x == -1 || current->prof.y == -1)
{
current->prof = previous->prof;
};
if(abs(previous->camera.x - current->prof.x) < minMoveSpeed)
{
moveX = false;
};
if(abs(previous->camera.y - current->prof.y) < minMoveSpeed)
{
moveY = false;
};
diff = current->prof.x - previous->camera.x;
if(abs(diff) > (outWidth/2 - border))
{
current->camera.x += diff/2;
moveX = true;
}else if(moveX)
{
current->camera.x += (diff/diff) * minMoveSpeed;
};
diff = current->prof.y - previous->camera.y;
if(abs(diff) > (outHeight/2 - border))
{
current->camera.y += diff/2;
moveY = true;
}else if(moveY)
{
current->camera.y += (diff/diff) * minMoveSpeed;
};
#ifdef _debug_
std::cout<<"LectVideoFrameCreate prof x="<<current->prof.x<<" y="<<current->prof.y<<" camera x="<<current->camera.x<<" y="<<current->camera.y<<std::endl;
#endif
cropped = current->cropFrame(outWidth, outHeight);
cropped->name = "videoFrame";
push(cropped);
previous->copy(current);
current = pop();
};
stop();
};