vendor: OpenCV 5.0.0 snapshot at 40738fb16ceddb5fb3fea747585f7ce6abb0605b
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"class_ignore_list": [
|
||||
"CirclesGridFinderParameters"
|
||||
],
|
||||
"namespaces_dict": {
|
||||
"cv.fisheye": "fisheye"
|
||||
},
|
||||
"func_arg_fix" : {
|
||||
"initCameraMatrix2D" : { "objectPoints" : {"ctype" : "vector_vector_Point3f"},
|
||||
"imagePoints" : {"ctype" : "vector_vector_Point2f"} }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.opencv.test.calib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.opencv.calib.Calib;
|
||||
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.test.OpenCVTestCase;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
public class CalibTest extends OpenCVTestCase {
|
||||
|
||||
public void testConstants()
|
||||
{
|
||||
// calib3d.hpp: some constants have conflict with constants from 'fisheye' namespace
|
||||
assertEquals(1, Calib.CALIB_USE_INTRINSIC_GUESS);
|
||||
assertEquals(2, Calib.CALIB_FIX_ASPECT_RATIO);
|
||||
assertEquals(4, Calib.CALIB_FIX_PRINCIPAL_POINT);
|
||||
assertEquals(8, Calib.CALIB_ZERO_TANGENT_DIST);
|
||||
assertEquals(16, Calib.CALIB_FIX_FOCAL_LENGTH);
|
||||
assertEquals(32, Calib.CALIB_FIX_K1);
|
||||
assertEquals(64, Calib.CALIB_FIX_K2);
|
||||
assertEquals(128, Calib.CALIB_FIX_K3);
|
||||
assertEquals(0x0800, Calib.CALIB_FIX_K4);
|
||||
assertEquals(0x1000, Calib.CALIB_FIX_K5);
|
||||
assertEquals(0x2000, Calib.CALIB_FIX_K6);
|
||||
assertEquals(0x4000, Calib.CALIB_RATIONAL_MODEL);
|
||||
assertEquals(0x8000, Calib.CALIB_THIN_PRISM_MODEL);
|
||||
assertEquals(0x10000, Calib.CALIB_FIX_S1_S2_S3_S4);
|
||||
assertEquals(0x40000, Calib.CALIB_TILTED_MODEL);
|
||||
assertEquals(0x80000, Calib.CALIB_FIX_TAUX_TAUY);
|
||||
assertEquals(0x100000, Calib.CALIB_USE_QR);
|
||||
assertEquals(0x200000, Calib.CALIB_FIX_TANGENT_DIST);
|
||||
assertEquals(0x100, Calib.CALIB_FIX_INTRINSIC);
|
||||
assertEquals(0x200, Calib.CALIB_SAME_FOCAL_LENGTH);
|
||||
assertEquals(0x400, Calib.CALIB_ZERO_DISPARITY);
|
||||
assertEquals((1 << 17), Calib.CALIB_USE_LU);
|
||||
assertEquals((1 << 22), Calib.CALIB_USE_EXTRINSIC_GUESS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"whitelist":
|
||||
{
|
||||
"": [
|
||||
"calibrateCameraExtended"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"namespaces_dict": {
|
||||
"cv.fisheye": "fisheye"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Calib3dTest.swift
|
||||
//
|
||||
// Created by Giles Payne on 2020/05/26.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import OpenCV
|
||||
|
||||
class CalibTest: OpenCVTestCase {
|
||||
|
||||
func testConstants()
|
||||
{
|
||||
// calib3d.hpp: some constants have conflict with constants from 'fisheye' namespace
|
||||
XCTAssertEqual(1, Calib.CALIB_USE_INTRINSIC_GUESS)
|
||||
XCTAssertEqual(2, Calib.CALIB_FIX_ASPECT_RATIO)
|
||||
XCTAssertEqual(4, Calib.CALIB_FIX_PRINCIPAL_POINT)
|
||||
XCTAssertEqual(8, Calib.CALIB_ZERO_TANGENT_DIST)
|
||||
XCTAssertEqual(16, Calib.CALIB_FIX_FOCAL_LENGTH)
|
||||
XCTAssertEqual(32, Calib.CALIB_FIX_K1)
|
||||
XCTAssertEqual(64, Calib.CALIB_FIX_K2)
|
||||
XCTAssertEqual(128, Calib.CALIB_FIX_K3)
|
||||
XCTAssertEqual(0x0800, Calib.CALIB_FIX_K4)
|
||||
XCTAssertEqual(0x1000, Calib.CALIB_FIX_K5)
|
||||
XCTAssertEqual(0x2000, Calib.CALIB_FIX_K6)
|
||||
XCTAssertEqual(0x4000, Calib.CALIB_RATIONAL_MODEL)
|
||||
XCTAssertEqual(0x8000, Calib.CALIB_THIN_PRISM_MODEL)
|
||||
XCTAssertEqual(0x10000, Calib.CALIB_FIX_S1_S2_S3_S4)
|
||||
XCTAssertEqual(0x40000, Calib.CALIB_TILTED_MODEL)
|
||||
XCTAssertEqual(0x80000, Calib.CALIB_FIX_TAUX_TAUY)
|
||||
XCTAssertEqual(0x100000, Calib.CALIB_USE_QR)
|
||||
XCTAssertEqual(0x200000, Calib.CALIB_FIX_TANGENT_DIST)
|
||||
XCTAssertEqual(0x100, Calib.CALIB_FIX_INTRINSIC)
|
||||
XCTAssertEqual(0x200, Calib.CALIB_SAME_FOCAL_LENGTH)
|
||||
XCTAssertEqual(0x400, Calib.CALIB_ZERO_DISPARITY)
|
||||
XCTAssertEqual((1 << 17), Calib.CALIB_USE_LU)
|
||||
XCTAssertEqual((1 << 22), Calib.CALIB_USE_EXTRINSIC_GUESS)
|
||||
}
|
||||
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
camera calibration for distorted images with chess board samples
|
||||
reads distorted images, calculates the calibration and write undistorted images
|
||||
'''
|
||||
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import cv2 as cv
|
||||
|
||||
from tests_common import NewOpenCVTests
|
||||
|
||||
class calibration_test(NewOpenCVTests):
|
||||
|
||||
def test_calibration(self):
|
||||
img_names = []
|
||||
for i in range(1, 15):
|
||||
if i < 10:
|
||||
img_names.append('samples/data/left0{}.jpg'.format(str(i)))
|
||||
elif i != 10:
|
||||
img_names.append('samples/data/left{}.jpg'.format(str(i)))
|
||||
|
||||
square_size = 1.0
|
||||
pattern_size = (9, 6)
|
||||
pattern_points = np.zeros((np.prod(pattern_size), 3), np.float32)
|
||||
pattern_points[:, :2] = np.indices(pattern_size).T.reshape(-1, 2)
|
||||
pattern_points *= square_size
|
||||
|
||||
obj_points = []
|
||||
img_points = []
|
||||
h, w = 0, 0
|
||||
for fn in img_names:
|
||||
img = self.get_sample(fn, 0)
|
||||
if img is None:
|
||||
continue
|
||||
|
||||
h, w = img.shape[:2]
|
||||
found, corners = cv.findChessboardCorners(img, pattern_size)
|
||||
if found:
|
||||
term = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_COUNT, 30, 0.1)
|
||||
cv.cornerSubPix(img, corners, (5, 5), (-1, -1), term)
|
||||
|
||||
if not found:
|
||||
continue
|
||||
|
||||
img_points.append(corners.reshape(-1, 2))
|
||||
obj_points.append(pattern_points)
|
||||
|
||||
# calculate camera distortion
|
||||
rms, camera_matrix, dist_coefs, _rvecs, _tvecs = cv.calibrateCamera(obj_points, img_points, (w, h), None, None, flags = 0)
|
||||
|
||||
eps = 0.01
|
||||
normCamEps = 10.0
|
||||
normDistEps = 0.05
|
||||
|
||||
cameraMatrixTest = [[ 532.80992189, 0., 342.4952186 ],
|
||||
[ 0., 532.93346422, 233.8879292 ],
|
||||
[ 0., 0., 1. ]]
|
||||
|
||||
distCoeffsTest = [ -2.81325576e-01, 2.91130406e-02,
|
||||
1.21234330e-03, -1.40825372e-04, 1.54865844e-01]
|
||||
|
||||
self.assertLess(abs(rms - 0.196334638034), eps)
|
||||
self.assertLess(cv.norm(camera_matrix - cameraMatrixTest, cv.NORM_L1), normCamEps)
|
||||
self.assertLess(cv.norm(dist_coefs - distCoeffsTest, cv.NORM_L1), normDistEps)
|
||||
|
||||
def test_projectPoints(self):
|
||||
objectPoints = np.array([[181.24588 , 87.80361 , 11.421074],
|
||||
[ 87.17948 , 184.75563 , 37.223446],
|
||||
[ 22.558456, 45.495266, 246.05797 ]], dtype=np.float32)
|
||||
rvec = np.array([[ 0.9357548 , -0.28316498, 0.21019171],
|
||||
[ 0.30293274, 0.9505806 , -0.06803132],
|
||||
[-0.18054008, 0.12733458, 0.9752903 ]], dtype=np.float32)
|
||||
tvec = np.array([ 69.32692 , 17.602057, 135.77672 ], dtype=np.float32)
|
||||
cameraMatrix = np.array([[214.0047 , 26.98735 , 253.37799 ],
|
||||
[189.8172 , 10.038101, 18.862494],
|
||||
[114.07123 , 200.87277 , 194.56332 ]], dtype=np.float32)
|
||||
distCoeffs = distCoeffs = np.zeros((4, 1), dtype=np.float32)
|
||||
|
||||
imagePoints, jacobian = cv.projectPoints(objectPoints, rvec, tvec, cameraMatrix, distCoeffs)
|
||||
self.assertTrue(imagePoints is not None)
|
||||
self.assertTrue(jacobian is not None)
|
||||
|
||||
def test_sampsonDistance_valid2D(self):
|
||||
pt1 = (np.random.rand(3, 10) * 256).astype(np.float64)
|
||||
pt2 = (np.random.rand(3, 10) * 256).astype(np.float64)
|
||||
F = (np.random.rand(3, 3) * 256).astype(np.float64)
|
||||
dist = cv.sampsonDistance(pt1, pt2, F)
|
||||
self.assertTrue(isinstance(dist, (float, np.floating)))
|
||||
self.assertGreaterEqual(dist, 0.0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
NewOpenCVTests.bootstrap()
|
||||
Reference in New Issue
Block a user