mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +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
@@ -3,5 +3,10 @@
|
||||
"QRCodeDetectorAruco": {
|
||||
"getDetectorParameters": { "declaration" : [""], "implementation" : [""] }
|
||||
}
|
||||
},
|
||||
"func_arg_fix" : {
|
||||
"Calib" : {
|
||||
"findCirclesGrid" : { "blobDetector" : {"defval" : "cv::SimpleBlobDetector::create()"} }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import XCTest
|
||||
import OpenCV
|
||||
|
||||
class ObjdetectTest: OpenCVTestCase {
|
||||
|
||||
var size = Size()
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
size = Size(width: 3, height: 3)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testFindChessboardCornersMatSizeMat() {
|
||||
let patternSize = Size(width: 9, height: 6)
|
||||
let corners = MatOfPoint2f()
|
||||
Calib.findChessboardCorners(image: grayChess, patternSize: patternSize, corners: corners)
|
||||
XCTAssertFalse(corners.empty())
|
||||
}
|
||||
|
||||
func testFindChessboardCornersMatSizeMatInt() {
|
||||
let patternSize = Size(width: 9, height: 6)
|
||||
let corners = MatOfPoint2f()
|
||||
Calib.findChessboardCorners(image: grayChess, patternSize: patternSize, corners: corners, flags: Calib.CALIB_CB_ADAPTIVE_THRESH + Calib.CALIB_CB_NORMALIZE_IMAGE + Calib.CALIB_CB_FAST_CHECK)
|
||||
XCTAssertFalse(corners.empty())
|
||||
}
|
||||
|
||||
func testFind4QuadCornerSubpix() {
|
||||
let patternSize = Size(width: 9, height: 6)
|
||||
let corners = MatOfPoint2f()
|
||||
let region_size = Size(width: 5, height: 5)
|
||||
Calib.findChessboardCorners(image: grayChess, patternSize: patternSize, corners: corners)
|
||||
Calib.find4QuadCornerSubpix(img: grayChess, corners: corners, region_size: region_size)
|
||||
XCTAssertFalse(corners.empty())
|
||||
}
|
||||
|
||||
func testFindCirclesGridMatSizeMat() {
|
||||
let size = 300
|
||||
let img = Mat(rows:Int32(size), cols:Int32(size), type:CvType.CV_8U)
|
||||
img.setTo(scalar: Scalar(255))
|
||||
let centers = Mat()
|
||||
|
||||
XCTAssertFalse(Calib.findCirclesGrid(image: img, patternSize: Size(width: 5, height: 5), centers: centers))
|
||||
|
||||
for i in 0..<5 {
|
||||
for j in 0..<5 {
|
||||
let x = Int32(size * (2 * i + 1) / 10)
|
||||
let y = Int32(size * (2 * j + 1) / 10)
|
||||
let pt = Point(x: x, y: y)
|
||||
Imgproc.circle(img: img, center: pt, radius: 10, color: Scalar(0), thickness: -1)
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssert(Calib.findCirclesGrid(image: img, patternSize:Size(width:5, height:5), centers:centers))
|
||||
|
||||
XCTAssertEqual(25, centers.rows())
|
||||
XCTAssertEqual(1, centers.cols())
|
||||
XCTAssertEqual(CvType.CV_32FC2, centers.type())
|
||||
}
|
||||
|
||||
func testFindCirclesGridMatSizeMatInt() {
|
||||
let size:Int32 = 300
|
||||
let img = Mat(rows:size, cols: size, type: CvType.CV_8U)
|
||||
img.setTo(scalar: Scalar(255))
|
||||
let centers = Mat()
|
||||
|
||||
XCTAssertFalse(Calib.findCirclesGrid(image: img, patternSize: Size(width: 3, height: 5), centers: centers, flags: Calib.CALIB_CB_CLUSTERING | Calib.CALIB_CB_ASYMMETRIC_GRID))
|
||||
|
||||
let step = size * 2 / 15
|
||||
let offsetx = size / 6
|
||||
let offsety = (size - 4 * step) / 2
|
||||
for i:Int32 in 0...2 {
|
||||
for j:Int32 in 0...4 {
|
||||
let pt = Point(x: offsetx + (2 * i + j % 2) * step, y: offsety + step * j)
|
||||
Imgproc.circle(img: img, center: pt, radius: 10, color: Scalar(0), thickness: -1)
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssert(Calib.findCirclesGrid(image: img, patternSize: Size(width: 3, height: 5), centers: centers, flags: Calib.CALIB_CB_CLUSTERING | Calib.CALIB_CB_ASYMMETRIC_GRID))
|
||||
|
||||
XCTAssertEqual(15, centers.rows())
|
||||
XCTAssertEqual(1, centers.cols())
|
||||
XCTAssertEqual(CvType.CV_32FC2, centers.type())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user