mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #28804 from asmorkalov:as/calib_boards_migration
Migrated chessboard and circles grid detectors to objdetect #28804 OpenCV Contrib: https://github.com/opencv/opencv_contrib/pull/4125 OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1375 ### 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 another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] 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:
committed by
GitHub
parent
dafe7cef97
commit
e19b0ebc5c
@@ -65,5 +65,9 @@
|
||||
"suffix": "Ljava_util_List",
|
||||
"v_type": "vector_NativeByteArray"
|
||||
}
|
||||
},
|
||||
"func_arg_fix" : {
|
||||
"findChessboardCorners" : { "corners" : {"ctype" : "vector_Point2f"} },
|
||||
"drawChessboardCorners" : { "corners" : {"ctype" : "vector_Point2f"} }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package org.opencv.test.objdetect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.opencv.cv3d.Cv3d;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDouble;
|
||||
import org.opencv.core.MatOfPoint2f;
|
||||
import org.opencv.core.MatOfPoint3f;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.objdetect.Objdetect;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
public class ObjdetectTest extends OpenCVTestCase {
|
||||
|
||||
Size size;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
size = new Size(3, 3);
|
||||
}
|
||||
|
||||
public void testFindChessboardCornersMatSizeMat() {
|
||||
Size patternSize = new Size(9, 6);
|
||||
MatOfPoint2f corners = new MatOfPoint2f();
|
||||
Objdetect.findChessboardCorners(grayChess, patternSize, corners);
|
||||
assertFalse(corners.empty());
|
||||
}
|
||||
|
||||
public void testFindChessboardCornersMatSizeMatInt() {
|
||||
Size patternSize = new Size(9, 6);
|
||||
MatOfPoint2f corners = new MatOfPoint2f();
|
||||
Objdetect.findChessboardCorners(grayChess, patternSize, corners, Objdetect.CALIB_CB_ADAPTIVE_THRESH + Objdetect.CALIB_CB_NORMALIZE_IMAGE
|
||||
+ Objdetect.CALIB_CB_FAST_CHECK);
|
||||
assertFalse(corners.empty());
|
||||
}
|
||||
|
||||
public void testFind4QuadCornerSubpix() {
|
||||
Size patternSize = new Size(9, 6);
|
||||
MatOfPoint2f corners = new MatOfPoint2f();
|
||||
Size region_size = new Size(5, 5);
|
||||
Objdetect.findChessboardCorners(grayChess, patternSize, corners);
|
||||
Objdetect.find4QuadCornerSubpix(grayChess, corners, region_size);
|
||||
assertFalse(corners.empty());
|
||||
}
|
||||
|
||||
public void testFindCirclesGridMatSizeMat() {
|
||||
int size = 300;
|
||||
Mat img = new Mat(size, size, CvType.CV_8U);
|
||||
img.setTo(new Scalar(255));
|
||||
Mat centers = new Mat();
|
||||
|
||||
assertFalse(Objdetect.findCirclesGrid(img, new Size(5, 5), centers));
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int j = 0; j < 5; j++) {
|
||||
Point pt = new Point(size * (2 * i + 1) / 10, size * (2 * j + 1) / 10);
|
||||
Imgproc.circle(img, pt, 10, new Scalar(0), -1);
|
||||
}
|
||||
|
||||
assertTrue(Objdetect.findCirclesGrid(img, new Size(5, 5), centers));
|
||||
|
||||
assertEquals(1, centers.rows());
|
||||
assertEquals(25, centers.cols());
|
||||
assertEquals(CvType.CV_32FC2, centers.type());
|
||||
}
|
||||
|
||||
public void testFindCirclesGridMatSizeMatInt() {
|
||||
int size = 300;
|
||||
Mat img = new Mat(size, size, CvType.CV_8U);
|
||||
img.setTo(new Scalar(255));
|
||||
Mat centers = new Mat();
|
||||
|
||||
assertFalse(Objdetect.findCirclesGrid(img, new Size(3, 5), centers, Objdetect.CALIB_CB_CLUSTERING
|
||||
| Objdetect.CALIB_CB_ASYMMETRIC_GRID));
|
||||
|
||||
int step = size * 2 / 15;
|
||||
int offsetx = size / 6;
|
||||
int offsety = (size - 4 * step) / 2;
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 5; j++) {
|
||||
Point pt = new Point(offsetx + (2 * i + j % 2) * step, offsety + step * j);
|
||||
Imgproc.circle(img, pt, 10, new Scalar(0), -1);
|
||||
}
|
||||
|
||||
assertTrue(Objdetect.findCirclesGrid(img, new Size(3, 5), centers, Objdetect.CALIB_CB_CLUSTERING
|
||||
| Objdetect.CALIB_CB_ASYMMETRIC_GRID));
|
||||
|
||||
assertEquals(1, centers.rows());
|
||||
assertEquals(15, centers.cols());
|
||||
assertEquals(CvType.CV_32FC2, centers.type());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user