mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 21:33:04 +04:00
Merge pull request #20367 from augustinmanecy:features2d-rw
**Merge with contrib**: https://github.com/opencv/opencv_contrib/pull/3003 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV - [x] The PR is proposed to proper branch - [ ] There is reference to original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -11,12 +11,12 @@ import org.opencv.core.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.opencv.features2d.Feature2D;
|
||||
import org.opencv.features2d.SimpleBlobDetector;
|
||||
import org.opencv.features2d.SimpleBlobDetector_Params;
|
||||
|
||||
public class SIMPLEBLOBFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
Feature2D detector;
|
||||
SimpleBlobDetector detector;
|
||||
int matSize;
|
||||
KeyPoint[] truth;
|
||||
|
||||
@@ -47,8 +47,8 @@ public class SIMPLEBLOBFeatureDetectorTest extends OpenCVTestCase {
|
||||
detector = SimpleBlobDetector.create();
|
||||
matSize = 200;
|
||||
truth = new KeyPoint[] {
|
||||
new KeyPoint( 140, 100, 41.036568f, -1, 0, 0, -1),
|
||||
new KeyPoint( 60, 100, 48.538486f, -1, 0, 0, -1),
|
||||
new KeyPoint(140, 100, 41.036568f, -1, 0, 0, -1),
|
||||
new KeyPoint(60, 100, 48.538486f, -1, 0, 0, -1),
|
||||
new KeyPoint(100, 60, 36.769554f, -1, 0, 0, -1),
|
||||
new KeyPoint(100, 140, 28.635643f, -1, 0, 0, -1),
|
||||
new KeyPoint(100, 100, 20.880613f, -1, 0, 0, -1)
|
||||
@@ -91,16 +91,38 @@ public class SIMPLEBLOBFeatureDetectorTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testRead() {
|
||||
public void testReadYml() {
|
||||
Mat img = getTestImg();
|
||||
|
||||
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
|
||||
detector.detect(img, keypoints1);
|
||||
|
||||
String filename = OpenCVTestRunner.getTempFileName("yml");
|
||||
writeFile(filename, "%YAML:1.0\nthresholdStep: 10\nminThreshold: 50\nmaxThreshold: 220\nminRepeatability: 2\nfilterByArea: true\nminArea: 800\nmaxArea: 5000\n");
|
||||
writeFile(filename, "%YAML:1.0\nthresholdStep: 10.0\nminThreshold: 50\nmaxThreshold: 220\nminRepeatability: 2\nminDistBetweenBlobs: 10.\nfilterByColor: 1\nblobColor: 0\nfilterByArea: 1\nminArea: 800\nmaxArea: 6000\nfilterByCircularity: 0\nminCircularity: 0.7\nmaxCircularity: 10.\nfilterByInertia: 1\nminInertiaRatio: 0.2\nmaxInertiaRatio: 11.\nfilterByConvexity: true\nminConvexity: 0.9\nmaxConvexity: 12.\n");
|
||||
detector.read(filename);
|
||||
|
||||
SimpleBlobDetector_Params params = detector.getParams();
|
||||
assertEquals(10.0f, params.get_thresholdStep());
|
||||
assertEquals(50f, params.get_minThreshold());
|
||||
assertEquals(220f, params.get_maxThreshold());
|
||||
assertEquals(2, params.get_minRepeatability());
|
||||
assertEquals(10.0f, params.get_minDistBetweenBlobs());
|
||||
assertEquals(true, params.get_filterByColor());
|
||||
// FIXME: blobColor field has uchar type in C++ and cannot be automatically wrapped to Java as it does not support unsigned types
|
||||
//assertEquals(0, params.get_blobColor());
|
||||
assertEquals(true, params.get_filterByArea());
|
||||
assertEquals(800f, params.get_minArea());
|
||||
assertEquals(6000f, params.get_maxArea());
|
||||
assertEquals(false, params.get_filterByCircularity());
|
||||
assertEquals(0.7f, params.get_minCircularity());
|
||||
assertEquals(10.0f, params.get_maxCircularity());
|
||||
assertEquals(true, params.get_filterByInertia());
|
||||
assertEquals(0.2f, params.get_minInertiaRatio());
|
||||
assertEquals(11.0f, params.get_maxInertiaRatio());
|
||||
assertEquals(true, params.get_filterByConvexity());
|
||||
assertEquals(0.9f, params.get_minConvexity());
|
||||
assertEquals(12.0f, params.get_maxConvexity());
|
||||
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
detector.detect(img, keypoints2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user