dajuric / dot-imaging

Minimalistic .NET imaging portable platform
313 stars 37 forks source link

FastTemplateMatchingDemo Pyramid Depth #9

Open fdncred opened 6 years ago

fdncred commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Many thanks for the update!

On 10 Oct 2017 8:02 pm, "Darren Schroeder" notifications@github.com wrote:

There appears to be similar bugs in LinearizedMapPyramid.cs on line 64 and

  1. 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.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dajuric/dot-imaging/issues/9#issuecomment-335557996, or mute the thread https://github.com/notifications/unsubscribe-auth/AEMQJ5YoG-3IwfnDEENqdzyYjRovbyhiks5sq7E_gaJpZM4P0JjU .

fdncred commented 6 years ago

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