Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[Stitching_detailed.cpp] Matcher as cv::Ptr discussion thread.

Hello everyone,

I encountered a thing while fiddling around with the stitching_detailed.cpp tutorial provided on source repository. Before proceeding please note that I had to improvise myself a C++ developer expert, I hope not to be trivial on my considerations.

In the tutorial, get straight to the point where the cv::FeaturesMatcher is defined.

On Eclipse C++ IDE, with fully set up project, the following will not compile:

Ptr<FeaturesMatcher> matcher;
matcher = makePtr<BestOf2NearestMatcher>(try_cuda, match_conf);
(*matcher)(features, pairwise_matches);

The issue is on line 3, where we call the matcher as a pointer. When that happens, a conflicting declaration appears to occur within matcher and pairwise_matches.

On the other hand, the following will compile just fine:

matcher(features, pairwiseMatches);
matcher.collectGarbage();

Question: why would I need to instantiate a matcher as a pointer when it works perfectly fine otherwise?

I wouldn't bother that much myself about it, but here is another (less trivial?) question. The following code works just fine:

cv::Ptr<cv::detail::FeaturesFinder> finder;
finder = cv::makePtr<cv::detail::SurfFeaturesFinder>();
for(int currentImage=0;currentImage<imagesCount;currentImage++) {
   (*finder)(images[currentImage],features[currentImage]);
}

For sake of readability, one would expect that a similar construction is going to work even with the matcher, not only with the finder. But this is not the case. Aside question: would it be a waste of time to annotate the tutorial to explain why things have to work this way?

Thank you for your time.

[Stitching_detailed.cpp] Matcher as cv::Ptr discussion thread.

Hello everyone,

I encountered a thing while fiddling around with the stitching_detailed.cpp tutorial provided on source repository. Before proceeding please note that I had to improvise myself a C++ developer expert, I hope not to be trivial on my considerations.

In the tutorial, get straight to the point where the cv::FeaturesMatcher is defined.

On Eclipse C++ IDE, with fully set up project, the following will not compile:compile (g++):

Ptr<FeaturesMatcher> matcher;
matcher = makePtr<BestOf2NearestMatcher>(try_cuda, match_conf);
(*matcher)(features, pairwise_matches);

The issue is on line 3, where we call the matcher as a pointer. When that happens, a conflicting declaration appears to occur within matcher and pairwise_matches.

On the other hand, the following will compile just fine:

matcher(features, pairwiseMatches);
matcher.collectGarbage();

Question: why would I need to instantiate a matcher as a pointer when it works perfectly fine otherwise?

I wouldn't bother that much myself about it, but here is another (less trivial?) question. The following code works just fine:

cv::Ptr<cv::detail::FeaturesFinder> finder;
finder = cv::makePtr<cv::detail::SurfFeaturesFinder>();
for(int currentImage=0;currentImage<imagesCount;currentImage++) {
   (*finder)(images[currentImage],features[currentImage]);
}

For sake of readability, one would expect that a similar construction is going to work even with the matcher, not only with the finder. But this is not the case. Aside question: would it be a waste of time to annotate the tutorial to explain why things have to work this way?

Thank you for your time.

[Stitching_detailed.cpp] Matcher as cv::Ptr discussion thread.

Hello everyone,

I encountered a thing while fiddling around with the stitching_detailed.cpp tutorial provided on source repository. Before proceeding please note that I had to improvise myself a C++ developer expert, I hope not to be trivial on my considerations.

In the tutorial, get straight to the point where the cv::FeaturesMatcher is defined.

On Eclipse C++ IDE, with fully set up project, the following will not compile (g++):

One can define the matcher in two different ways, one being

Ptr<FeaturesMatcher> matcher;
matcher = makePtr<BestOf2NearestMatcher>(try_cuda, match_conf);
(*matcher)(features, pairwise_matches);

The issue is on line 3, where we call the matcher as a pointer. When that happens, a conflicting declaration appears to occur within matcher and pairwise_matches.

On the other hand, the following will compile just fine:

And the other, more direct, being

BestOf2NearestMatcher matcher(tryCuda,matchingConfidence);
matcher(features, pairwiseMatches);
matcher.collectGarbage();

Question: why would I need to instantiate a matcher as a pointer when it works perfectly fine otherwise?

I wouldn't bother that much myself about it, but here is another (less trivial?) question. The following code works just fine:

cv::Ptr<cv::detail::FeaturesFinder> finder;
finder = cv::makePtr<cv::detail::SurfFeaturesFinder>();
for(int currentImage=0;currentImage<imagesCount;currentImage++) {
   (*finder)(images[currentImage],features[currentImage]);
}

For sake of readability, one would expect that a similar construction is going to work even with the matcher, not only with the finder. But this is not the case. Aside question: would it be a waste of time to annotate the tutorial to explain why things have to work this way?

Thank you for your time.