Example #1
0
        private void UpdateObjectModel(Image <Gray, byte> patch, bool label)
        {
            // calculate relative similarity
            float pnnSimilarity, nnnSimilarity;
            float relativeSimilarity = _objectModel.RelativeSimilarity(patch, out pnnSimilarity, out nnnSimilarity);

            // positive patch
            if (label == true)
            {
                if (!(pnnSimilarity > _nnClassifier.PnnSimilarityThreshold && relativeSimilarity > _nnClassifier.RelativeSimilarityThreshold))
                {
                    if (pnnSimilarity < _sameSimilarityThreshold)
                    {
                        _objectModel.AddPositivePatch(patch);
                    }
                }
            }

            // negative patch
            else
            {
                if (relativeSimilarity > 0.5f)
                {
                    if (nnnSimilarity < _sameSimilarityThreshold)
                    {
                        _objectModel.AddNegativePatch(patch);
                    }
                }
            }
        }