drawkeypoints是免费功能吗?当我尝试使用它时,会引发以下错误
cv.drawKeypoints is not a function
我正在尝试编写此示例
https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_feature2/py_orb/py_orb/py_orb.html#orb
我已经构建了OPENCV JS,如下所述
https://docs.opencv.org/3.4/d4/da1/tutorial_js_setup.html
然后将其连接到我的html
<script src="opencv.js"></script>
这是我使用的功能
function orbExample() {
let imgElement = document.querySelector('#imageSrc');
let img = cv.imread(imgElement);
let color = new cv.Scalar(0,255,0, 1);
// Initiate ORB detector
let orb = new cv.ORB();
let keyPoints = new cv.KeyPointVector;
// find the keypoints with ORB
orb.detect(img, keyPoints);
let des = new cv.Mat();
// compute the descriptors with ORB
orb.compute(img, keyPoints, des);
// draw only keypoints location,not size and orientation
let img2 = new cv.Mat();
cv.drawKeypoints(img, keyPoints, img2, color, 0);
cv.imshow('opencvCanvas', img2);
}
我认为您在加载opencv.js之前使用cv函数使用onload函数,该功能告诉您OpenCV.JS已加载,然后使用OpenCV函数。