summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/point_extractor.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-12-16 11:54:21 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-12-16 11:54:21 +0100
commit4d62adf8bc4f78f8dca8196c7f52a6a44cc5829a (patch)
tree8b07b851c334ed80054d53e11ab1f9258c76bc02 /tracker-pt/point_extractor.cpp
parentfc24671937724beb3fde6c6edfc1c124fbb0ef75 (diff)
tracker/pt: refactor camera info handling
- Pass `struct CamInfo' rather than several elements separately - Reformat - Return `struct CamInfo' together with the frame since then it's always valid - Move the focal length formula into `struct CamInfo' - Remove incorrect focal length formula rather than #if 0 - Pass some stuff by reference and not by pointer
Diffstat (limited to 'tracker-pt/point_extractor.cpp')
-rw-r--r--tracker-pt/point_extractor.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index a688faad..f7f63784 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -83,9 +83,6 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector<vec2>& points)
using std::round;
using std::sort;
- const int W = frame.cols;
- const int H = frame.rows;
-
if (frame_gray.rows != frame.rows || frame_gray.cols != frame.cols)
{
frame_gray = cv::Mat(frame.rows, frame.cols, CV_8U);
@@ -219,6 +216,9 @@ end:
sort(blobs.begin(), blobs.end(), [](const blob& b1, const blob& b2) -> bool { return b2.brightness < b1.brightness; });
+ const int W = frame.cols;
+ const int H = frame.rows;
+
for (idx = 0; idx < std::min(PointModel::N_POINTS, unsigned(blobs.size())); ++idx)
{
blob &b = blobs[idx];
@@ -253,6 +253,8 @@ end:
for (auto& b : blobs)
{
+ // note: H/W is equal to fx/fy
+
vec2 p((b.pos[0] - W/2)/W, -(b.pos[1] - H/2)/W);
points.push_back(p);
}