Last active
July 26, 2022 13:28
-
-
Save matt-42/881c84d4dee4cd32e7b1bf3e4c35d301 to your computer and use it in GitHub Desktop.
Kitti optical flow 2012 : calcOpticalFlowPyrLK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<cv::Point2f> pts; | |
std::vector<cv::Point2f> next_pts; | |
std::vector<unsigned char> status; | |
cv::Mat err; | |
int winsize = 11; | |
int nscales = 4; | |
for (auto p : i1_gl.domain()) | |
pts.push_back(cv::Point2f(p[1], p[0])); | |
calcOpticalFlowPyrLK(to_opencv(i1_gl), to_opencv(i2_gl), pts, next_pts, status, err, | |
cv::Size(winsize, winsize), nscales); | |
for (unsigned i = 0; i < pts.size(); i++) | |
{ | |
if (status[i]) | |
{ | |
vfloat2 p1(pts[i].y, pts[i].x); | |
vfloat2 p2(next_pts[i].y, next_pts[i].x); | |
flow(p1.cast<int>()) = p2 - p1; | |
has_flow(p1.cast<int>()) = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment