Browse Source

Added unit test for SimpleBlobDetector detect function call with mask

master
Canming Huang 4 weeks ago
parent
commit
b83d7a321c
  1. 20
      Emgu.CV.Test/AutoTestFeatures2d.cs
  2. 18
      tests/cvextern_test/cvextern_test.cpp

20
Emgu.CV.Test/AutoTestFeatures2d.cs

@ -637,14 +637,20 @@ namespace Emgu.CV.Test
[Test]
public void TestSimpleBlobDetector()
{
Mat box = EmguAssert.LoadMat("box.png");
SimpleBlobDetectorParams p = new SimpleBlobDetectorParams();
p.CollectContours = true;
SimpleBlobDetector detector = new SimpleBlobDetector(p);
MKeyPoint[] keypoints = detector.Detect(box);
using (VectorOfVectorOfPoint contour = detector.GetBlobContours())
using (Mat box = EmguAssert.LoadMat("box.png"))
{
int count = contour.Size;
SimpleBlobDetectorParams p = new SimpleBlobDetectorParams();
p.CollectContours = true;
SimpleBlobDetector detector = new SimpleBlobDetector(p);
using (Mat mask = new Mat(box.Size, DepthType.Cv8U, 1))
{
mask.SetTo(new MCvScalar(255));
MKeyPoint[] keypoints = detector.Detect(box, mask);
using (VectorOfVectorOfPoint contour = detector.GetBlobContours())
{
int count = contour.Size;
}
}
}
}
}

18
tests/cvextern_test/cvextern_test.cpp

@ -3,6 +3,7 @@
#include "stdio.h"
#include <iostream>
#include "quaternions.h"
#include "opencv2/features2d.hpp"
#include "opencv2/opencv_modules.hpp"
#include "opencv2/core/core.hpp"
@ -258,6 +259,19 @@ void Test_InferenceEngine()
}
#endif
#ifdef HAVE_OPENCV_FEATURES2D
void Test_SimpleBlobDetector()
{
cv::Mat m(600, 480, CV_8UC1);
cv::Ptr<cv::SimpleBlobDetector> detector = cv::SimpleBlobDetector::create();
cv::Mat mask(m.size(), CV_8UC1);
mask.setTo(255);
std::vector<cv::KeyPoint> kps;
detector->detect(m, kps, mask);
cout << "SimpleBlobDetector: Passed";
}
#endif
int main()
{
char tmp;
@ -308,6 +322,10 @@ int main()
Test_InferenceEngine();
#endif
#ifdef HAVE_OPENCV_FEATURES2D
Test_SimpleBlobDetector();
#endif
cin >> tmp; //wait for input only if compiling with visual C++
#endif

Loading…
Cancel
Save