Add tests for features2d JavaScript bindings#12855
Conversation
ddc04b8 to
683a5d3
Compare
|
The test numbers are received from python bindings: import cv2 as cv
import numpy as np
image = np.zeros([100, 100], np.uint8)
cv.setRNGSeed(324)
cv.randu(image, 0, 255)
orb = cv.ORB_create()
kp = orb.detect(image)
print(len(kp))
mser = cv.MSER_create()
kp = mser.detect(image)
print(len(kp))
brisk = cv.BRISK_create()
kp = brisk.detect(image)
print(len(kp))
ffd = cv.FastFeatureDetector_create()
kp = ffd.detect(image)
print(len(kp))
afd = cv.AgastFeatureDetector_create()
kp = afd.detect(image)
print(len(kp))
gftt = cv.GFTTDetector_create()
kp = gftt.detect(image)
print(len(kp))
kaze = cv.KAZE_create()
kp = kaze.detect(image)
print(len(kp))
akaze = cv.AKAZE_create()
kp = akaze.detect(image)
print(len(kp)) |
|
@huningxin, May I ask you how to debug emscripten compilation? opencv/modules/js/test/test_imgproc.js Lines 477 to 484 in 2180a67 I found that the following loop is a source of wrong values in opencv/modules/core/src/arithm_core.hpp Lines 209 to 219 in 2180a67 |
modules/js/test/test_features2d.js
Outdated
| let image = new cv.Mat(100, 100, cv.CV_8UC1); | ||
| let low = new cv.Mat(1, 1, cv.CV_8UC1, [0, 0, 0, 0]); | ||
| let high = new cv.Mat(1, 1, cv.CV_8UC1, [255, 255, 255, 255]); | ||
| cv.randu(image, low, high); |
There was a problem hiding this comment.
- Avoid using of random images for keypoint detectors. Their implementations are not stable (not bit-exact between platforms).
Try to generate some synthetic frame instead:
function generateTestFrame(width, height) {
let w = width || 200;
let h = height || 200;
let img = new cv.Mat(h, w, cv.CV_8UC1, new cv.Scalar(0, 0, 0, 0));
let s0 = new cv.Scalar(0, 0, 0, 0);
let s = new cv.Scalar(255, 255, 255, 255);
let s128 = new cv.Scalar(128, 128, 128, 128);
let rect = new cv.Rect(w / 4, h / 4, w / 2, h / 2);
img.roi(rect).setTo(s);
img.roi(new cv.Rect(w / 2 - w / 8, h / 2 - h / 8, w / 4, h / 4)).setTo(s128);
cv.rectangle(img, new cv.Point(w / 8, h / 8), new cv.Point(w - w / 8, h - h / 8), s, 5);
cv.rectangle(img, new cv.Point(w / 5, h / 5), new cv.Point(w - w / 5, h - h / 5), s128, 3);
cv.line(img, new cv.Point(-w, 0), new cv.Point(w / 2, h / 2), s128, 5);
cv.line(img, new cv.Point(2*w, 0), new cv.Point(w / 2, h / 2), s, 5);
return img;
}
...
let image = generateTestFrame();
- "low", "high" are not used.
| "-DWITH_GPHOTO2=OFF", | ||
| "-DWITH_LAPACK=OFF", | ||
| "-DWITH_ITT=OFF", | ||
| "-DWITH_QUIRC=OFF", |
There was a problem hiding this comment.
quirc is a dependency of QRCodeDetector which has no wrappers yet.
@allnes, Could you wrap it to python/java and add to the following file for JS bindings:
opencv/modules/js/src/embindgen.py
Lines 118 to 120 in edacd91
|
Thank you folks! I am attending conference this week. The response is slow. Sorry for that. |
|
@sajjadt, are you able to take a look? Thanks! |
1658ea7 to
05665f3
Compare
|
@alalek, @huningxin, It looks like the problem is solved. I tried to build this branch with emscripten |
|
Updated emscipten on Tests fails with latest LTS version of node (10.15.0), so downgraded on previous |
05665f3 to
8ecc5e6
Compare
This pullrequest changes
resolves #12706
DMatchdefinition