ethz-asl / ethzasl_brisk

Brisk. The feature.
20 stars 11 forks source link

Code will not compile in visual studio 2017 with opencv 3.4 #107

Open antithing opened 6 years ago

antithing commented 6 years ago

Hi, and thanks for making this code available. I am trying to build with newer versions of opencv, and am getting compile errors, in brute-force-matcher.cc, at line 59. The function:

namespace brisk {
// Adapted from OpenCV 2.3 features2d/matcher.hpp
cv::Ptr<cv::DescriptorMatcher> BruteForceMatcher::clone(bool emptyTrainData)
const {
  BruteForceMatcher* matcher = new BruteForceMatcher(distance_);
  if (!emptyTrainData) {
    std::transform(trainDescCollection.begin(), trainDescCollection.end(),
                   matcher->trainDescCollection.begin(), clone_op);
  }
  return matcher; //HERE GIVES ERROR
}

Gives me the intelsense and compile error:

Severity    Code    Description Project File    Line    Suppression State
Error (active)  E0415   no suitable constructor exists to convert from "brisk::BruteForceMatcher *" to "cv::Ptr<cv::DescriptorMatcher>" brisk   d:\OKVIS\build\brisk\src\brisk-2.0.3\brisk\src\brute-force-matcher.cc   59  

What can i do to get this running?

Thanks again.

antithing commented 5 years ago

Months later, i solved it.

cv::Ptr<cv::DescriptorMatcher> BruteForceMatcher::clone(bool emptyTrainData)
const {

    cv::Ptr<BruteForceMatcher> matcher = cv::makePtr<BruteForceMatcher>(distance_);
    if (!emptyTrainData)
    {
        matcher->trainDescCollection.resize(trainDescCollection.size());
        std::transform(trainDescCollection.begin(), trainDescCollection.end(),
            matcher->trainDescCollection.begin(), clone_op);
    }
    return matcher;
}