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

FastTemplateMatchingDemo Pyramid Depth #9

Open
fdncred opened this issue Oct 10, 2017 · 3 comments
Open

FastTemplateMatchingDemo Pyramid Depth #9

fdncred opened this issue Oct 10, 2017 · 3 comments

Comments

@fdncred
Copy link

fdncred commented Oct 10, 2017

What's the secret sauce to getting multiple levels of the pyramid? I changed this line by adding the neighborhoodPerLevel parameter.

linPyr = LinearizedMapPyramid.CreatePyramid(grayIm, neigborhoodPerLevel: new int[] { 5, 5 }); //prepare linear-pyramid maps

And this line by adding the maxNumberOfFeaturesPerLevel parameter.

var tp = TemplatePyramid.CreatePyramidFromPreparedBWImage(preparedBWImage, new FileInfo(file).Name /*"OpenHand"*/,  maxNumberOfFeaturesPerLevel: new int[] { 100, 100 });

And what I get is Debug.Assert thrown from from the second iteration of matchTemplate->calculateSimilarityMap->neighbourMap.AddTo()->AddTo() method because src.Width does not equal dst.Width nor does src.Height equal dst.Height.

I also think I found a bug. Shouldn't sourceImage be image after the var t = new T();
Before:

public static ImageTemplatePyramid<T> CreatePyramidFromPreparedBWImage(Gray<byte>[,] sourceImage, string classLabel, int minFeatureStrength = 40, int minNumberOfFeatures = 30, int[] maxNumberOfFeaturesPerLevel = null)
{
    return CreatePyramid<Gray<byte>>(sourceImage, classLabel,
                                    (image, minFeatures, maxFeatures, label) =>
                                    {
                                        var t = new T();
                                        t.Initialize(sourceImage, minFeatureStrength, maxFeatures, label);
                                        return t;
                                    },
                                    minNumberOfFeatures, maxNumberOfFeaturesPerLevel);
}

After:

public static ImageTemplatePyramid<T> CreatePyramidFromPreparedBWImage(Gray<byte>[,] sourceImage, string classLabel, int minFeatureStrength = 40, int minNumberOfFeatures = 30, int[] maxNumberOfFeaturesPerLevel = null)
{
    return CreatePyramid<Gray<byte>>(sourceImage, classLabel,
                                    (image, minFeatures, maxFeatures, label) =>
                                    {
                                        var t = new T();
                                        t.Initialize(image, minFeatureStrength, maxFeatures, label);
                                        return t;
                                    },
                                    minNumberOfFeatures, maxNumberOfFeaturesPerLevel);
}
@fdncred
Copy link
Author

fdncred commented Oct 10, 2017

There appears to be similar bugs in LinearizedMapPyramid.cs on line 64 and 110. Line 64 should have source as the image to compute and line 110 should have image as a parameter to orientImgCalc().

As far as the secret sauce, I still haven't figured it out but it has to do with the MatchTemplate method in Dectector.cs. If anything other than the full image size is passed in as searchArea, around line 115, the matchTemplate() method on line 125 fails.

@dajuric
Copy link
Owner

dajuric commented Oct 13, 2017 via email

@fdncred
Copy link
Author

fdncred commented Oct 13, 2017

Any tips on how to get this to work? I still cannot use more than 1 level in the pyramid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants