Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - converting to OpenCL - 1 test #3

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Source/ARX/OCVT/HarrisDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ HarrisDetector::HarrisDetector()
{
_termcrit = cv::TermCriteria(cv::TermCriteria::COUNT|cv::TermCriteria::EPS,20,0.03);
}
std::vector<cv::Point2f> HarrisDetector::FindCorners(cv::Mat gray)

std::vector<cv::Point2f> HarrisDetector::FindCorners(cv::UMat gray)
{
cv::Mat mask = cv::Mat::zeros(gray.size(), CV_8UC1);
cv::UMat mask = cv::UMat::zeros(gray.size(), CV_8UC1);
cv::Rect innerRegion(harrisBorder,harrisBorder,gray.cols-(harrisBorder*2), gray.rows-(harrisBorder*2));
cv::Mat maskRoi = mask(innerRegion);
cv::UMat maskRoi = mask(innerRegion);
maskRoi.setTo(cv::Scalar(255));
std::vector<cv::Point2f> trackablePointsWarped;
goodFeaturesToTrack(gray, trackablePointsWarped, MAX_COUNT, 0.1, 10, mask, 3, false, 0.04);
mask.release();
return trackablePointsWarped;
}

6 changes: 3 additions & 3 deletions Source/ARX/OCVT/HarrisDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class HarrisDetector
{
private:
cv::TermCriteria _termcrit;

public:
HarrisDetector();
std::vector<cv::Point2f> FindCorners(cv::Mat gray);

std::vector<cv::Point2f> FindCorners(cv::UMat gray);
};

#endif
3 changes: 1 addition & 2 deletions Source/ARX/OCVT/OCVFeatureDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool OCVFeatureDetector::AddDescriptorsToDictionary(int id, cv::Mat descriptors)
return false;
}

std::vector<cv::KeyPoint> OCVFeatureDetector::DetectAndCompute(cv::Mat frame, cv::Mat mask, cv::Mat &desc) {
std::vector<cv::KeyPoint> OCVFeatureDetector::DetectAndCompute(cv::UMat frame, cv::UMat mask, cv::Mat &desc) {
std::vector<cv::KeyPoint> kp;
_featureDetector->detectAndCompute(frame, mask, kp, desc);
return kp;
Expand All @@ -109,4 +109,3 @@ std::vector< std::vector<cv::DMatch> > OCVFeatureDetector::MatchFeatures(cv::Ma
_matcher->knnMatch(first_desc, desc, matches, 2);
return matches;
}

14 changes: 7 additions & 7 deletions Source/ARX/OCVT/OCVFeatureDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ class OCVFeatureDetector
{
public:
OCVFeatureDetector();

bool AddDescriptorsToDictionary(int id, cv::Mat descriptors);
std::vector<cv::KeyPoint> DetectAndCompute(cv::Mat frame, cv::Mat mask, cv::Mat &desc);

std::vector<cv::KeyPoint> DetectAndCompute(cv::UMat frame, cv::UMat mask, cv::Mat &desc);

std::vector< std::vector<cv::DMatch> > MatchFeatures(cv::Mat first_desc, cv::Mat desc);

void SetFeatureDetector(int detectorType);

// static int count;

private:
void CreateAkazeFeatureDetector();
void CreateORBFeatureDetector();
void CreateKazeFeatureDetector();
void CreateBriskFeatureDetector();

std::map<int, cv::Mat> _visualDictionary;
cv::Ptr<cv::DescriptorMatcher> _matcher;
cv::Ptr<cv::Feature2D> _featureDetector;
Expand Down
Loading