mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Try to fix "enum struct" wrapping for Java
This commit is contained in:
parent
e058febaad
commit
6fbcb283b9
@ -7,11 +7,13 @@ import java.util.List;
|
|||||||
import org.opencv.calib3d.Calib3d;
|
import org.opencv.calib3d.Calib3d;
|
||||||
import org.opencv.core.CvType;
|
import org.opencv.core.CvType;
|
||||||
import org.opencv.core.Mat;
|
import org.opencv.core.Mat;
|
||||||
|
import org.opencv.core.MatOfInt;
|
||||||
import org.opencv.core.MatOfDMatch;
|
import org.opencv.core.MatOfDMatch;
|
||||||
import org.opencv.core.MatOfKeyPoint;
|
import org.opencv.core.MatOfKeyPoint;
|
||||||
import org.opencv.core.MatOfPoint2f;
|
import org.opencv.core.MatOfPoint2f;
|
||||||
import org.opencv.core.Point;
|
import org.opencv.core.Point;
|
||||||
import org.opencv.core.Range;
|
import org.opencv.core.Range;
|
||||||
|
import org.opencv.core.Scalar;
|
||||||
import org.opencv.core.DMatch;
|
import org.opencv.core.DMatch;
|
||||||
import org.opencv.features2d.DescriptorMatcher;
|
import org.opencv.features2d.DescriptorMatcher;
|
||||||
import org.opencv.features2d.Features2d;
|
import org.opencv.features2d.Features2d;
|
||||||
@ -141,4 +143,30 @@ public class Features2dTest extends OpenCVTestCase {
|
|||||||
Imgcodecs.imwrite(outputPath, outimg);
|
Imgcodecs.imwrite(outputPath, outimg);
|
||||||
// OpenCVTestRunner.Log("Output image is saved to: " + outputPath);
|
// OpenCVTestRunner.Log("Output image is saved to: " + outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDrawKeypoints()
|
||||||
|
{
|
||||||
|
Mat outImg = Mat.ones(11, 11, CvType.CV_8U);
|
||||||
|
|
||||||
|
MatOfKeyPoint kps = new MatOfKeyPoint(new KeyPoint(5, 5, 1)); // x, y, size
|
||||||
|
Features2d.drawKeypoints(new Mat(), kps, outImg, new Scalar(255),
|
||||||
|
Features2d.DrawMatchesFlags_DRAW_OVER_OUTIMG);
|
||||||
|
|
||||||
|
Mat ref = new MatOfInt(new int[] {
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 15, 54, 15, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 76, 217, 217, 221, 81, 1, 1, 1,
|
||||||
|
1, 1, 100, 224, 111, 57, 115, 225, 101, 1, 1,
|
||||||
|
1, 44, 215, 100, 1, 1, 1, 101, 214, 44, 1,
|
||||||
|
1, 54, 212, 57, 1, 1, 1, 55, 212, 55, 1,
|
||||||
|
1, 40, 215, 104, 1, 1, 1, 105, 215, 40, 1,
|
||||||
|
1, 1, 102, 221, 111, 55, 115, 222, 103, 1, 1,
|
||||||
|
1, 1, 1, 76, 218, 217, 220, 81, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 15, 55, 15, 1, 1, 1, 1,
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||||
|
}).reshape(1, 11);
|
||||||
|
ref.convertTo(ref, CvType.CV_8U);
|
||||||
|
|
||||||
|
assertMatEqual(ref, outImg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,9 +427,12 @@ class JavaWrapperGenerator(object):
|
|||||||
constinfo = ConstInfo(decl, namespaces=self.namespaces, enumType=enumType)
|
constinfo = ConstInfo(decl, namespaces=self.namespaces, enumType=enumType)
|
||||||
if constinfo.isIgnored():
|
if constinfo.isIgnored():
|
||||||
logging.info('ignored: %s', constinfo)
|
logging.info('ignored: %s', constinfo)
|
||||||
elif not self.isWrapped(constinfo.classname):
|
|
||||||
logging.info('class not found: %s', constinfo)
|
|
||||||
else:
|
else:
|
||||||
|
if not self.isWrapped(constinfo.classname):
|
||||||
|
logging.info('class not found: %s', constinfo)
|
||||||
|
constinfo.name = constinfo.classname + '_' + constinfo.name
|
||||||
|
constinfo.classname = ''
|
||||||
|
|
||||||
ci = self.getClass(constinfo.classname)
|
ci = self.getClass(constinfo.classname)
|
||||||
duplicate = ci.getConst(constinfo.name)
|
duplicate = ci.getConst(constinfo.name)
|
||||||
if duplicate:
|
if duplicate:
|
||||||
|
@ -634,6 +634,8 @@ class CppHeaderParser(object):
|
|||||||
block_type, block_name = b[self.BLOCK_TYPE], b[self.BLOCK_NAME]
|
block_type, block_name = b[self.BLOCK_TYPE], b[self.BLOCK_NAME]
|
||||||
if block_type in ["file", "enum"]:
|
if block_type in ["file", "enum"]:
|
||||||
continue
|
continue
|
||||||
|
if block_type in ["enum struct", "enum class"] and block_name == name:
|
||||||
|
continue
|
||||||
if block_type not in ["struct", "class", "namespace", "enum struct", "enum class"]:
|
if block_type not in ["struct", "class", "namespace", "enum struct", "enum class"]:
|
||||||
print("Error at %d: there are non-valid entries in the current block stack %s" % (self.lineno, self.block_stack))
|
print("Error at %d: there are non-valid entries in the current block stack %s" % (self.lineno, self.block_stack))
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
@ -58,7 +58,7 @@ class SURFFLANNMatching {
|
|||||||
//-- Draw matches
|
//-- Draw matches
|
||||||
Mat imgMatches = new Mat();
|
Mat imgMatches = new Mat();
|
||||||
Features2d.drawMatches(img1, keypoints1, img2, keypoints2, goodMatches, imgMatches, Scalar.all(-1),
|
Features2d.drawMatches(img1, keypoints1, img2, keypoints2, goodMatches, imgMatches, Scalar.all(-1),
|
||||||
Scalar.all(-1), new MatOfByte(), Features2d.NOT_DRAW_SINGLE_POINTS);
|
Scalar.all(-1), new MatOfByte(), Features2d.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS);
|
||||||
|
|
||||||
//-- Show detected matches
|
//-- Show detected matches
|
||||||
HighGui.imshow("Good Matches", imgMatches);
|
HighGui.imshow("Good Matches", imgMatches);
|
||||||
|
@ -64,7 +64,7 @@ class SURFFLANNMatchingHomography {
|
|||||||
//-- Draw matches
|
//-- Draw matches
|
||||||
Mat imgMatches = new Mat();
|
Mat imgMatches = new Mat();
|
||||||
Features2d.drawMatches(imgObject, keypointsObject, imgScene, keypointsScene, goodMatches, imgMatches, Scalar.all(-1),
|
Features2d.drawMatches(imgObject, keypointsObject, imgScene, keypointsScene, goodMatches, imgMatches, Scalar.all(-1),
|
||||||
Scalar.all(-1), new MatOfByte(), Features2d.NOT_DRAW_SINGLE_POINTS);
|
Scalar.all(-1), new MatOfByte(), Features2d.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS);
|
||||||
|
|
||||||
//-- Localize the object
|
//-- Localize the object
|
||||||
List<Point> obj = new ArrayList<>();
|
List<Point> obj = new ArrayList<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user