Commit a66a1a24 authored by Dmitry Kurtaev's avatar Dmitry Kurtaev

Fix drawKeypoints and drawMatches for JS

parent 099f4f9e
...@@ -141,7 +141,7 @@ features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptor ...@@ -141,7 +141,7 @@ features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptor
'AKAZE': ['create', 'setDescriptorType', 'getDescriptorType', 'setDescriptorSize', 'getDescriptorSize', 'setDescriptorChannels', 'getDescriptorChannels', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'], 'AKAZE': ['create', 'setDescriptorType', 'getDescriptorType', 'setDescriptorSize', 'getDescriptorSize', 'setDescriptorChannels', 'getDescriptorChannels', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
'DescriptorMatcher': ['add', 'clear', 'empty', 'isMaskSupported', 'train', 'match', 'knnMatch', 'radiusMatch', 'clone', 'create'], 'DescriptorMatcher': ['add', 'clear', 'empty', 'isMaskSupported', 'train', 'match', 'knnMatch', 'radiusMatch', 'clone', 'create'],
'BFMatcher': ['isMaskSupported', 'create'], 'BFMatcher': ['isMaskSupported', 'create'],
'': ['drawKeypoints', 'drawMatches']} '': ['drawKeypoints', 'drawMatches', 'drawMatchesKnn']}
calib3d = {'': ['findHomography']} calib3d = {'': ['findHomography']}
...@@ -562,7 +562,7 @@ class JSWrapperGenerator(object): ...@@ -562,7 +562,7 @@ class JSWrapperGenerator(object):
match = re.search(r'const std::vector<(.*)>&', arg_type) match = re.search(r'const std::vector<(.*)>&', arg_type)
if match: if match:
type_in_vect = match.group(1) type_in_vect = match.group(1)
if type_in_vect != 'cv::Mat': if type_in_vect in ['int', 'float', 'double', 'char', 'uchar', 'String', 'std::string']:
casted_arg_name = 'emscripten::vecFromJSArray<' + type_in_vect + '>(' + arg_name + ')' casted_arg_name = 'emscripten::vecFromJSArray<' + type_in_vect + '>(' + arg_name + ')'
arg_type = re.sub(r'std::vector<(.*)>', 'emscripten::val', arg_type) arg_type = re.sub(r'std::vector<(.*)>', 'emscripten::val', arg_type)
w_signature.append(arg_type + ' ' + arg_name) w_signature.append(arg_type + ' ' + arg_name)
......
...@@ -80,3 +80,36 @@ QUnit.test('BFMatcher', function(assert) { ...@@ -80,3 +80,36 @@ QUnit.test('BFMatcher', function(assert) {
assert.equal(dm.size(), 67); assert.equal(dm.size(), 67);
}); });
QUnit.test('Drawing', function(assert) {
// Generate key points.
let image = generateTestFrame();
let kp = new cv.KeyPointVector();
let descriptors = new cv.Mat();
let orb = new cv.ORB();
orb.detectAndCompute(image, new cv.Mat(), kp, descriptors);
assert.equal(kp.size(), 67);
let dst = new cv.Mat();
cv.drawKeypoints(image, kp, dst);
assert.equal(dst.rows, image.rows);
assert.equal(dst.cols, image.cols);
// Run a matcher.
let dm = new cv.DMatchVector();
let matcher = new cv.BFMatcher();
matcher.match(descriptors, descriptors, dm);
assert.equal(dm.size(), 67);
cv.drawMatches(image, kp, image, kp, dm, dst);
assert.equal(dst.rows, image.rows);
assert.equal(dst.cols, 2 * image.cols);
dm = new cv.DMatchVectorVector();
matcher.knnMatch(descriptors, descriptors, dm, 2);
assert.equal(dm.size(), 67);
cv.drawMatchesKnn(image, kp, image, kp, dm, dst);
assert.equal(dst.rows, image.rows);
assert.equal(dst.cols, 2 * image.cols);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment