1

Is drawKeypoints a free function? When I try to use it throws the following error

cv.drawKeypoints is not a function

I'm trying to write this example

https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_feature2d/py_orb/py_orb.html#orb

I've built OpenCV Js as it described here

https://docs.opencv.org/3.4/d4/da1/tutorial_js_setup.html

Then attached it in my HTML

<script src="opencv.js"></script>

And here is the function that I use

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);
        }
Dan Mašek
  • 17,852
  • 6
  • 57
  • 85

1 Answers1

1

i think you are using cv functions before opencv.js is loaded use onload function which tells you that opencv.js is loaded and then use opencv functions.

asif khan
  • 51
  • 6