Merge pull request #24474 from asmorkalov:as/BOWImgDescriptorExtractoor_java_ctor

Added Java bindings for BOWImgDescriptorExtractor constructor
pull/24536/head
Alexander Smorkalov 1 year ago committed by GitHub
commit 26f3514992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/features2d/include/opencv2/features2d.hpp
  2. 48
      modules/features2d/misc/java/test/BOWImgDescriptorExtractorTest.java

@ -1544,7 +1544,7 @@ public:
@param dmatcher Descriptor matcher that is used to find the nearest word of the trained vocabulary
for each keypoint descriptor of the image.
*/
CV_WRAP BOWImgDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor,
CV_WRAP BOWImgDescriptorExtractor( const Ptr<Feature2D>& dextractor,
const Ptr<DescriptorMatcher>& dmatcher );
/** @overload */
BOWImgDescriptorExtractor( const Ptr<DescriptorMatcher>& dmatcher );

@ -0,0 +1,48 @@
package org.opencv.test.features2d;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.core.KeyPoint;
import org.opencv.features2d.ORB;
import org.opencv.features2d.DescriptorMatcher;
import org.opencv.features2d.BOWImgDescriptorExtractor;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
import org.opencv.imgproc.Imgproc;
public class BOWImgDescriptorExtractorTest extends OpenCVTestCase {
ORB extractor;
DescriptorMatcher matcher;
int matSize;
public static void assertDescriptorsClose(Mat expected, Mat actual, int allowedDistance) {
double distance = Core.norm(expected, actual, Core.NORM_HAMMING);
assertTrue("expected:<" + allowedDistance + "> but was:<" + distance + ">", distance <= allowedDistance);
}
private Mat getTestImg() {
Mat cross = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255));
Imgproc.line(cross, new Point(20, matSize / 2), new Point(matSize - 21, matSize / 2), new Scalar(100), 2);
Imgproc.line(cross, new Point(matSize / 2, 20), new Point(matSize / 2, matSize - 21), new Scalar(100), 2);
return cross;
}
@Override
protected void setUp() throws Exception {
super.setUp();
extractor = ORB.create();
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
matSize = 100;
}
public void testCreate() {
BOWImgDescriptorExtractor bow = new BOWImgDescriptorExtractor(extractor, matcher);
}
}
Loading…
Cancel
Save