forked from sonnyky/CameraSensing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetection.cpp
More file actions
37 lines (30 loc) · 794 Bytes
/
detection.cpp
File metadata and controls
37 lines (30 loc) · 794 Bytes
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
#include "detection.h"
#define SAMPLE_READ_WAIT_TIMEOUT 2000 //2000ms
#pragma once
/*
Calibration methods
*/
const float * _calc_homography(UPoint * src, UPoint * dst, int length) {
vector<Point2f> proj_points;
vector<Point2f> img_points;
vector<float> homographyValues;
Point2f point;
for (int i = 0; i < length; i++) {
Point2f tempSrc, tempDst;
tempSrc.x = src->x;
tempSrc.y = src->y;
proj_points.push_back(tempSrc);
tempDst.x = dst->x;
tempDst.y = dst->y;
img_points.push_back(tempDst);
src++;
dst++;
}
Mat homography = findHomography(proj_points, img_points);
for (int i = 0; i < homography.rows; i++) {
for (int j = 0; j < homography.cols; j++) {
homographyValues.push_back((float) homography.at<double>(i, j));
}
}
return &homographyValues[0];
}