Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2019-06-26 20:17:19 +00:00
43 changed files with 895 additions and 355 deletions

View File

@@ -112,7 +112,8 @@ imgproc = {'': ['Canny', 'GaussianBlur', 'Laplacian', 'HoughLines', 'HoughLinesP
'goodFeaturesToTrack','grabCut','initUndistortRectifyMap', 'integral','integral2', 'isContourConvex', 'line', \
'matchShapes', 'matchTemplate','medianBlur', 'minAreaRect', 'minEnclosingCircle', 'moments', 'morphologyEx', \
'pointPolygonTest', 'putText','pyrDown','pyrUp','rectangle','remap', 'resize','sepFilter2D','threshold', \
'undistort','warpAffine','warpPerspective','watershed'],
'undistort','warpAffine','warpPerspective','watershed', \
'fillPoly', 'fillConvexPoly'],
'CLAHE': ['apply', 'collectGarbage', 'getClipLimit', 'getTilesGridSize', 'setClipLimit', 'setTilesGridSize']}
objdetect = {'': ['groupRectangles'],
@@ -170,6 +171,8 @@ aruco = {'': ['detectMarkers', 'drawDetectedMarkers', 'drawAxis', 'estimatePoseS
'aruco_CharucoBoard': ['create', 'draw'],
}
calib3d = {'': ['findHomography']}
def makeWhiteList(module_list):
wl = {}
for m in module_list:
@@ -180,7 +183,7 @@ def makeWhiteList(module_list):
wl[k] = m[k]
return wl
white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, photo, aruco])
white_list = makeWhiteList([core, imgproc, objdetect, video, dnn, features2d, photo, aruco, calib3d])
# Features to be exported
export_enums = False

View File

@@ -0,0 +1,43 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
if (typeof module !== 'undefined' && module.exports) {
// The envrionment is Node.js
var cv = require('./opencv.js'); // eslint-disable-line no-var
}
QUnit.module('Camera Calibration and 3D Reconstruction', {});
QUnit.test('constants', function(assert) {
assert.strictEqual(typeof cv.LMEDS, 'number');
assert.strictEqual(typeof cv.RANSAC, 'number');
assert.strictEqual(typeof cv.RHO, 'number');
});
QUnit.test('findHomography', function(assert) {
let srcPoints = cv.matFromArray(4, 1, cv.CV_32FC2, [
56,
65,
368,
52,
28,
387,
389,
390,
]);
let dstPoints = cv.matFromArray(4, 1, cv.CV_32FC2, [
0,
0,
300,
0,
0,
300,
300,
300,
]);
const mat = cv.findHomography(srcPoints, dstPoints);
assert.ok(mat instanceof cv.Mat);
});

View File

@@ -201,6 +201,89 @@ QUnit.test('test_imgProc', function(assert) {
expected_img.delete();
compare_result.delete();
}
// fillPoly
{
let img_width = 6;
let img_height = 6;
let img = new cv.Mat.zeros(img_height, img_width, cv.CV_8UC1);
let npts = 4;
let square_point_data = new Uint8Array([
1, 1,
4, 1,
4, 4,
1, 4]);
let square_points = cv.matFromArray(npts, 1, cv.CV_32SC2, square_point_data);
let pts = new cv.MatVector();
pts.push_back (square_points);
let color = new cv.Scalar (255);
let expected_img_data = new Uint8Array([
0, 0, 0, 0, 0, 0,
0, 255, 255, 255, 255, 0,
0, 255, 255, 255, 255, 0,
0, 255, 255, 255, 255, 0,
0, 255, 255, 255, 255, 0,
0, 0, 0, 0, 0, 0]);
let expected_img = cv.matFromArray(img_height, img_width, cv.CV_8UC1, expected_img_data);
cv.fillPoly(img, pts, color);
let compare_result = new cv.Mat(img_height, img_width, cv.CV_8UC1);
cv.compare (img, expected_img, compare_result, cv.CMP_EQ);
// expect every pixels are the same.
assert.equal (cv.countNonZero(compare_result), img.total());
img.delete();
square_points.delete();
pts.delete();
expected_img.delete();
compare_result.delete();
}
// fillConvexPoly
{
let img_width = 6;
let img_height = 6;
let img = new cv.Mat.zeros(img_height, img_width, cv.CV_8UC1);
let npts = 4;
let square_point_data = new Uint8Array([
1, 1,
4, 1,
4, 4,
1, 4]);
let square_points = cv.matFromArray(npts, 1, cv.CV_32SC2, square_point_data);
let color = new cv.Scalar (255);
let expected_img_data = new Uint8Array([
0, 0, 0, 0, 0, 0,
0, 255, 255, 255, 255, 0,
0, 255, 255, 255, 255, 0,
0, 255, 255, 255, 255, 0,
0, 255, 255, 255, 255, 0,
0, 0, 0, 0, 0, 0]);
let expected_img = cv.matFromArray(img_height, img_width, cv.CV_8UC1, expected_img_data);
cv.fillConvexPoly(img, square_points, color);
let compare_result = new cv.Mat(img_height, img_width, cv.CV_8UC1);
cv.compare (img, expected_img, compare_result, cv.CMP_EQ);
// expect every pixels are the same.
assert.equal (cv.countNonZero(compare_result), img.total());
img.delete();
square_points.delete();
expected_img.delete();
compare_result.delete();
}
});
QUnit.test('test_segmentation', function(assert) {

View File

@@ -30,6 +30,7 @@
<script type="application/javascript" src="test_video.js"></script>
<script type="application/javascript" src="test_photo.js"></script>
<script type="application/javascript" src="test_features2d.js"></script>
<script type="application/javascript" src="test_calib3d.js"></script>
<script type='text/javascript'>
QUnit.config.autostart = false;

View File

@@ -46,7 +46,9 @@ testrunner.run(
code: 'opencv.js',
tests: ['test_mat.js', 'test_utils.js', 'test_imgproc.js',
'test_objdetect.js', 'test_video.js', 'test_features2d.js',
'test_photo.js'],
'test_photo.js',
'test_calib3d.js'
],
},
function(err, report) {
console.log(report.failed + ' failed, ' + report.passed + ' passed');