Skip to content

Commit

Permalink
Fix swapImage and other related code
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Dec 5, 2023
1 parent 2dff6c4 commit 04a5bb2
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class WebARKitTracker::WebARKitTrackerImpl {
_isDetected = true;
numMatches = framePts.size();
perspectiveTransform(_bBox, _bBoxTransformed, m_H);
swapImagePyramid();
}
}
}
Expand All @@ -176,11 +175,6 @@ class WebARKitTracker::WebARKitTrackerImpl {
return NULL;
}

if (_prevPyramid.empty()) {
WEBARKIT_LOGe("Tracking is uninitialized!\n");
return NULL;
}

WEBARKIT_LOGi("Start tracking!\n");
clear_output();

Expand Down Expand Up @@ -244,7 +238,7 @@ class WebARKitTracker::WebARKitTrackerImpl {
}
}

swapImagePyramid();
//swapImagePyramid();

return valid;
};
Expand All @@ -255,6 +249,7 @@ class WebARKitTracker::WebARKitTrackerImpl {
} else {
this->_valid = track();
}
swapImagePyramid();
};

bool homographyValid(cv::Mat& H) {
Expand Down Expand Up @@ -293,11 +288,11 @@ class WebARKitTracker::WebARKitTrackerImpl {
output = std::vector<double>(17, 0.0);
};

void buildImagePyramid(cv::Mat frame) { cv::buildOpticalFlowPyramid(frame, _pyramid, winSize, maxLevel); }
void buildImagePyramid(cv::Mat& frame) { cv::buildOpticalFlowPyramid(frame, _pyramid, winSize, maxLevel); }

void swapImagePyramid() { _pyramid.swap(_prevPyramid); }

cv::Mat createTrackerFeatureMask(cv::Mat frame) {
cv::Mat createTrackerFeatureMask(cv::Mat& frame) {
cv::Mat featureMask;
if (featureMask.empty()) {
// Only create mask if we have something to draw in it.
Expand All @@ -310,7 +305,7 @@ class WebARKitTracker::WebARKitTrackerImpl {
return featureMask;
}

cv::Mat createFeatureMask(cv::Mat frame) {
cv::Mat createFeatureMask(cv::Mat& frame) {
cv::Mat featureMask;
if (_isDetected) {
if (featureMask.empty()) {
Expand Down

0 comments on commit 04a5bb2

Please sign in to comment.