-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpticalFlow.h
87 lines (51 loc) · 1.64 KB
/
OpticalFlow.h
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
#ifndef OPTICALFLOW_H_INCLUDED
#define OPTICALFLOW_H_INCLUDED
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <vector>
#include "common.h"
static const float MinThr = 2.5f;
inline bool IsVerySmall(const float &val)
{
return abs(val) < 1e-4;
}
void SaveOF(const cv::Mat &vx, const cv::Mat &vy, cv::Mat &output);
void Flow2RGB(const cv::Mat &vx, const cv::Mat &vy, cv::Mat &output);
class OpticalFlowComputing
{
cv::Size m_win_size;
cv::Size m_img_size;
/* Gaussian separable kernels */
// float m_GaussX[16];
// float m_GaussY[16];
std::vector<float> m_WeightX;
std::vector<float> m_WeightY;
std::vector<float> m_GaussX;
std::vector<float> m_GaussY;
float* m_MemX[2];
float* m_MemY[2];
DerProduct *m_II;
DerProduct *m_WII;//weighted
int m_step;
int m_hor_rad;
int m_ver_rad;
int m_buf_size;
unsigned char* m_ptrA;
unsigned char* m_ptrB;
bool m_UseGauss; //Decide whether the weighting function is Gaussian based weights.
public:
OpticalFlowComputing(cv::Size win, cv::Size img, int step, bool use_gauss);
void CalFirstLine();
void SetInputTwoImages(unsigned char* ia, unsigned char* ib)
{
m_ptrA = ia;
m_ptrB = ib;
}
virtual ~OpticalFlowComputing();
void DoWork(float *vx, float *vy, int step);
protected:
void CalcDerivative(HorStep& hs, VerStep& vs, int cur_memy, int & cur_addr);
void CalcHorConvolution(int & cur_addr);
void SolveLinEq(float *vx, float *vy, int cur_line);
};
#endif // OPTICALFLOW_H_INCLUDED