Skip to content

Commit

Permalink
[fix] tracking: fix registration
Browse files Browse the repository at this point in the history
Fixed warpAffine and warpPerspective that are not in-place compatible.
  • Loading branch information
bgallois committed Jul 29, 2023
1 parent 9fd308a commit fe2c70c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/tracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ void Tracking::registration(UMat imageReference, UMat &frame, const int method)

Point2d shift = phaseCorrelate(frame, imageReference);
Mat H = (Mat_<float>(2, 3) << 1.0, 0.0, shift.x, 0.0, 1.0, shift.y);
warpAffine(frame, frame, H, frame.size());
frame.convertTo(frame, CV_8U);
UMat output;
warpAffine(frame, output, H, frame.size());
output.convertTo(frame, CV_8U);
break;
}
// ECC images alignment
Expand All @@ -307,8 +308,9 @@ void Tracking::registration(UMat imageReference, UMat &frame, const int method)
Mat warpMat = Mat::eye(2, 3, CV_32F);
TermCriteria criteria(TermCriteria::COUNT + TermCriteria::EPS, 5000, 1e-5);
findTransformECC(imageReference, frame, warpMat, warpMode, criteria);
warpAffine(frame, frame, warpMat, frame.size(), INTER_LINEAR + WARP_INVERSE_MAP);
frame.convertTo(frame, CV_8U);
UMat output;
warpAffine(frame, output, warpMat, frame.size(), INTER_LINEAR + WARP_INVERSE_MAP);
output.convertTo(frame, CV_8U);
break;
}
// Features based registration
Expand Down Expand Up @@ -338,9 +340,10 @@ void Tracking::registration(UMat imageReference, UMat &frame, const int method)
}

Mat h = findHomography(pointsFrame, pointsRef, RANSAC);
warpPerspective(frame, frame, h, frame.size());
UMat output;
warpPerspective(frame, output, h, frame.size());

frame.convertTo(frame, CV_8U);
frame.convertTo(output, CV_8U);
break;
}
}
Expand Down

0 comments on commit fe2c70c

Please sign in to comment.