Skip to content

Commit cde1e72

Browse files
committed
compile with OpenCV3
1 parent f82afed commit cde1e72

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

cells/FeatureFinder.cpp

+22-6
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,32 @@ struct FeatureFinder {
103103
}
104104

105105
// Find keypoints in the current image
106-
cv::ORB orb;
106+
#if (CV_MAJOR_VERSION ==3)
107+
cv::Ptr<cv::ORB> orb = cv::ORB::create(*n_features_, *scale_factor_, *n_levels_);
108+
#elif (CV_MAJOR_VERSION == 2) && (CV_MINOR_VERSION >= 4)
109+
cv::ORB orb = cv::ORB(*n_features_, *scale_factor_, *n_levels_);
110+
#else
111+
cv::ORB::CommonParams orb_params;
112+
orb_params.first_level_ = 0;
113+
orb_params.n_levels_ = *n_levels_;
114+
orb_params.scale_factor_ = *scale_factor_;
115+
cv::ORB orb = cv::ORB(*n_features_, orb_params);
116+
#endif
117+
107118
cv::Mat descriptors;
108119
if (*use_fast_) {
109120
cv::FAST(*image_, *keypoints_, 30);
121+
#if (CV_MAJOR_VERSION ==3)
122+
orb->detectAndCompute(*image_, mask, *keypoints_, descriptors, true);
123+
#else
110124
orb(*image_, mask, *keypoints_, descriptors, true);
125+
#endif
111126
} else {
112-
cv::ORB orb;
113-
orb.set("nFeatures", *n_features_);
114-
orb.set("nLevels", *n_levels_);
115-
orb.set("scaleFactor", *scale_factor_);
127+
#if (CV_MAJOR_VERSION ==3)
128+
orb->detectAndCompute(*image_, mask, *keypoints_, descriptors);
129+
#else
116130
orb(*image_, mask, *keypoints_, descriptors);
131+
#endif
117132
}
118133

119134
// Remove bad keypoints
@@ -153,7 +168,8 @@ struct FeatureFinder {
153168
/** The mask of where to find keypoints in the image */
154169
ecto::spore<cv::Mat> mask_;
155170
/** ORB parameters */
156-
ecto::spore<float> n_features_, n_levels_, scale_factor_;
171+
ecto::spore<int> n_features_, n_levels_;
172+
ecto::spore<float> scale_factor_;
157173
/** The resulting descriptors */
158174
ecto::spore<cv::Mat> descriptors_;
159175
/** Thekeypoints */

0 commit comments

Comments
 (0)